sbin/hammer2: Fix root blockref type in "freemap"
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 13 Aug 2019 16:00:03 +0000 (01:00 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 13 Aug 2019 16:39:30 +0000 (01:39 +0900)
The root blockref type for freemap should be
HAMMER2_BREF_TYPE_FREEMAP rather than HAMMER2_BREF_TYPE_VOLUME.
Both are pseudo types, but sync with what fchain uses.

sbin/hammer2/cmd_debug.c

index 6799d21..72a11d4 100644 (file)
@@ -417,7 +417,8 @@ cmd_show(const char *devpath, int dofreemap)
        bzero(&best, sizeof(best));
        for (i = 0; i < HAMMER2_NUM_VOLHDRS; ++i) {
                bzero(&broot, sizeof(broot));
-               broot.type = HAMMER2_BREF_TYPE_VOLUME;
+               broot.type = dofreemap ?
+                   HAMMER2_BREF_TYPE_FREEMAP : HAMMER2_BREF_TYPE_VOLUME;
                broot.data_off = (i * HAMMER2_ZONE_BYTES64) |
                                 HAMMER2_PBUFRADIX;
                lseek(fd, broot.data_off & ~HAMMER2_OFF_MASK_RADIX, 0);
@@ -751,13 +752,16 @@ show_bref(hammer2_volume_data_t *voldata, int fd, int tab,
                printf("mirror_tid=%016jx freemap_tid=%016jx ",
                        media.voldata.mirror_tid,
                        media.voldata.freemap_tid);
-               if (dofreemap) {
-                       bscan = &media.voldata.freemap_blockset.blockref[0];
-                       bcount = HAMMER2_SET_COUNT;
-               } else {
-                       bscan = &media.voldata.sroot_blockset.blockref[0];
-                       bcount = HAMMER2_SET_COUNT;
-               }
+               bscan = &media.voldata.sroot_blockset.blockref[0];
+               bcount = HAMMER2_SET_COUNT;
+               printf("{\n");
+               break;
+       case HAMMER2_BREF_TYPE_FREEMAP:
+               printf("mirror_tid=%016jx freemap_tid=%016jx ",
+                       media.voldata.mirror_tid,
+                       media.voldata.freemap_tid);
+               bscan = &media.voldata.freemap_blockset.blockref[0];
+               bcount = HAMMER2_SET_COUNT;
                printf("{\n");
                break;
        case HAMMER2_BREF_TYPE_FREEMAP_LEAF: