sys/vfs/hammer: Rename misleading macro hammer_is_zone2_mapped_index()
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 17 Dec 2016 10:27:38 +0000 (19:27 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 17 Dec 2016 18:48:47 +0000 (03:48 +0900)
All zones are mapped to zone2 (whether directly or indirectly),
so hammer_is_zone2_mapped_index() is a misleading name.
It should have indicated it's for B-Tree records related zones.

sbin/hammer/blockmap.c
sbin/hammer/cmd_blockmap.c
sbin/hammer/cmd_strip.c
sbin/hammer/ondisk.c
sbin/newfs_hammer/newfs_hammer.c
sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_blockmap.c
sys/vfs/hammer/hammer_disk.h
sys/vfs/hammer/hammer_io.c
sys/vfs/hammer/hammer_ondisk.c

index 75712a4..1ff4eb2 100644 (file)
@@ -139,7 +139,7 @@ alloc_blockmap(int zone, int bytes, hammer_off_t *result_offp,
         */
        bytes = HAMMER_DATA_DOALIGN(bytes);
        assert(bytes > 0 && bytes <= HAMMER_BUFSIZE);  /* not HAMMER_XBUFSIZE */
-       assert(hammer_is_zone2_mapped_index(zone));
+       assert(hammer_is_index_record(zone));
 
 again:
        assert(blockmap->next_offset != HAMMER_ZONE_ENCODE(zone + 1, 0));
@@ -251,8 +251,11 @@ blockmap_lookup_save(hammer_off_t zone_offset,
        ondisk = root_volume->ondisk;
        blockmap = &ondisk->vol0_blockmap[zone];
 
-       if (zone == HAMMER_ZONE_RAW_BUFFER_INDEX) {
-               result_offset = zone_offset;
+       /*
+        * Handle blockmap offset translations.
+        */
+       if (hammer_is_index_record(zone)) {
+               result_offset = hammer_xlate_to_zone2(zone_offset);
        } else if (zone == HAMMER_ZONE_UNDO_INDEX) {
                if (zone_offset >= blockmap->alloc_offset) {
                        error = -3;
@@ -260,14 +263,15 @@ blockmap_lookup_save(hammer_off_t zone_offset,
                }
                result_offset = hammer_xlate_to_undo(ondisk, zone_offset);
        } else {
-               result_offset = hammer_xlate_to_zone2(zone_offset);
+               /* assert(zone == HAMMER_ZONE_RAW_BUFFER_INDEX); */
+               result_offset = zone_offset;
        }
 
        /*
         * The blockmap should match the requested zone (else the volume
         * header is mashed).
         */
-       if (hammer_is_zone2_mapped_index(zone) &&
+       if (hammer_is_index_record(zone) &&
            HAMMER_ZONE_DECODE(blockmap->alloc_offset) != zone) {
                error = -4;
                goto done;
index 1180a48..5ea245c 100644 (file)
@@ -581,7 +581,7 @@ dump_collect(collect_t collect, struct zone_stat *stats)
                if (DebugOpt) {
                        assert((zone == HAMMER_ZONE_UNDO_INDEX) ||
                                (zone == HAMMER_ZONE_FREEMAP_INDEX) ||
-                               hammer_is_zone2_mapped_index(zone));
+                               hammer_is_index_record(zone));
                }
                if (stats)
                        hammer_add_zone_stat_layer2(stats, layer2);
index 979397e..04160ab 100644 (file)
@@ -117,7 +117,7 @@ hammer_strip_bigblock(int zone, hammer_off_t offset)
        struct buffer_info *buffer = NULL;
        int i;
 
-       assert(hammer_is_zone2_mapped_index(zone));
+       assert(hammer_is_index_record(zone));
        assert((offset & HAMMER_BIGBLOCK_MASK64) == 0);
        assert((offset & HAMMER_BUFMASK) == 0);
        offset = hammer_xlate_to_zoneX(zone, offset);
index 8efb4e7..b499383 100644 (file)
@@ -484,7 +484,7 @@ format_blockmap(struct volume_info *root_vol, int zone, hammer_off_t offset)
        /* Only root volume needs formatting */
        assert(root_vol->vol_no == HAMMER_ROOT_VOLNO);
 
-       assert(hammer_is_zone2_mapped_index(zone));
+       assert(hammer_is_index_record(zone));
 
        blockmap = &root_vol->ondisk->vol0_blockmap[zone];
        zone_base = HAMMER_ZONE_ENCODE(zone, offset);
index b7a4011..ee5a732 100644 (file)
@@ -601,7 +601,7 @@ format_volume(struct volume_info *vol, int nvols, const char *label)
                 * Format zones that are mapped to zone-2.
                 */
                for (i = 0; i < HAMMER_MAX_ZONES; ++i) {
-                       if (hammer_is_zone2_mapped_index(i))
+                       if (hammer_is_index_record(i))
                                format_blockmap(vol, i, 0);
                }
 
index 35d7623..42929c2 100644 (file)
@@ -1565,8 +1565,7 @@ hammer_blockmap_lookup(hammer_mount_t hmp, hammer_off_t zone_offset,
                        int *errorp)
 {
 #if defined INVARIANTS
-       int zone = HAMMER_ZONE_DECODE(zone_offset);
-       KKASSERT(hammer_is_zone2_mapped_index(zone));
+       KKASSERT(hammer_is_zone_record(zone_offset));
 #endif
 
        /*
index b80ee2e..e95ef46 100644 (file)
@@ -101,7 +101,7 @@ hammer_blockmap_alloc(hammer_transaction_t trans, int zone, int bytes,
         */
        bytes = HAMMER_DATA_DOALIGN(bytes);
        KKASSERT(bytes > 0 && bytes <= HAMMER_XBUFSIZE);
-       KKASSERT(hammer_is_zone2_mapped_index(zone));
+       KKASSERT(hammer_is_index_record(zone));
 
        /*
         * Setup
@@ -429,7 +429,7 @@ hammer_blockmap_reserve(hammer_mount_t hmp, int zone, int bytes,
        /*
         * Setup
         */
-       KKASSERT(hammer_is_zone2_mapped_index(zone));
+       KKASSERT(hammer_is_index_record(zone));
        root_volume = hammer_get_root_volume(hmp, errorp);
        if (*errorp)
                return(NULL);
@@ -657,7 +657,7 @@ hammer_blockmap_reserve_dedup(hammer_mount_t hmp, int zone, int bytes,
        /*
         * Setup
         */
-       KKASSERT(hammer_is_zone2_mapped_index(zone));
+       KKASSERT(hammer_is_index_record(zone));
        root_volume = hammer_get_root_volume(hmp, errorp);
        if (*errorp)
                return (NULL);
@@ -964,7 +964,7 @@ hammer_blockmap_free(hammer_transaction_t trans,
         * Basic zone validation & locking
         */
        zone = HAMMER_ZONE_DECODE(zone_offset);
-       KKASSERT(hammer_is_zone2_mapped_index(zone));
+       KKASSERT(hammer_is_index_record(zone));
        root_volume = trans->rootvol;
        error = 0;
 
@@ -1098,7 +1098,7 @@ hammer_blockmap_dedup(hammer_transaction_t trans,
         * Basic zone validation & locking
         */
        zone = HAMMER_ZONE_DECODE(zone_offset);
-       KKASSERT(hammer_is_zone2_mapped_index(zone));
+       KKASSERT(hammer_is_index_record(zone));
        error = 0;
 
        freemap = &hmp->blockmap[HAMMER_ZONE_FREEMAP_INDEX];
@@ -1206,7 +1206,7 @@ hammer_blockmap_finalize(hammer_transaction_t trans,
         * Basic zone validation & locking
         */
        zone = HAMMER_ZONE_DECODE(zone_offset);
-       KKASSERT(hammer_is_zone2_mapped_index(zone));
+       KKASSERT(hammer_is_index_record(zone));
        root_volume = trans->rootvol;
        error = 0;
 
@@ -1325,7 +1325,7 @@ hammer_blockmap_getfree(hammer_mount_t hmp, hammer_off_t zone_offset,
        int zone;
 
        zone = HAMMER_ZONE_DECODE(zone_offset);
-       KKASSERT(hammer_is_zone2_mapped_index(zone));
+       KKASSERT(hammer_is_index_record(zone));
        root_volume = hammer_get_root_volume(hmp, errorp);
        if (*errorp) {
                *curp = 0;
index 130c411..ef16b89 100644 (file)
@@ -268,20 +268,20 @@ typedef uint32_t hammer_crc_t;
 #define hammer_is_zone_data(offset)                    \
        (hammer_is_zone_large_data(offset) || hammer_is_zone_small_data(offset))
 
-/*
- * Test if the zone is directly mapped to zone-2 offset via freemap.
- */
-#define hammer_is_zone2_mapped_index(zone)             \
+#define hammer_is_index_record(zone)                   \
        ((zone) >= HAMMER_ZONE_BTREE_INDEX &&           \
         (zone) < HAMMER_MAX_ZONES)
-/*
- * Test if the zone is directly mapped to zone-2 offset. The word
- * directly here means the zone is neither RAW_VOLUME nor UNDO zone.
- */
-#define hammer_is_direct_mapped_index(zone)            \
+
+#define hammer_is_zone_record(offset)                  \
+       hammer_is_index_record(HAMMER_ZONE_DECODE(offset))
+
+#define hammer_is_index_direct_xlated(zone)            \
        (((zone) == HAMMER_ZONE_RAW_BUFFER_INDEX) ||    \
         ((zone) == HAMMER_ZONE_FREEMAP_INDEX) ||       \
-        hammer_is_zone2_mapped_index(zone))
+        hammer_is_index_record(zone))
+
+#define hammer_is_zone_direct_xlated(offset)           \
+       hammer_is_index_direct_xlated(HAMMER_ZONE_DECODE(offset))
 
 #define HAMMER_ZONE_ENCODE(zone, ham_off)              \
        (((hammer_off_t)(zone) << 60) | (ham_off))
index b4d0c46..d0071d4 100644 (file)
@@ -1686,8 +1686,7 @@ hammer_io_direct_write(hammer_mount_t hmp, struct bio *bio,
 
        buf_offset = leaf->data_offset;
 
-       KKASSERT(hammer_is_zone2_mapped_index(
-               HAMMER_ZONE_DECODE(buf_offset)));
+       KKASSERT(hammer_is_zone_record(buf_offset));
        KKASSERT(bio->bio_buf->b_cmd == BUF_CMD_WRITE);
 
        /*
index a0193f5..49f3702 100644 (file)
@@ -585,9 +585,7 @@ hammer_get_installed_volumes(hammer_mount_t hmp)
 static __inline int
 hammer_direct_zone(hammer_off_t buf_offset)
 {
-       int zone = HAMMER_ZONE_DECODE(buf_offset);
-
-       return(hammer_is_direct_mapped_index(zone));
+       return(hammer_is_zone_direct_xlated(buf_offset));
 }
 
 hammer_buffer_t
@@ -679,7 +677,7 @@ found_aliased:
         * Handle blockmap offset translations
         */
        zone = HAMMER_ZONE_DECODE(buf_offset);
-       if (hammer_is_zone2_mapped_index(zone)) {
+       if (hammer_is_index_record(zone)) {
                zone2_offset = hammer_blockmap_lookup(hmp, buf_offset, errorp);
        } else if (zone == HAMMER_ZONE_UNDO_INDEX) {
                zone2_offset = hammer_undo_lookup(hmp, buf_offset, errorp);