From f6d29b27491ba551e2a3365ed684a10f4b3b804e Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Sat, 17 Dec 2016 19:27:38 +0900 Subject: [PATCH] sys/vfs/hammer: Rename misleading macro hammer_is_zone2_mapped_index() 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 | 14 +++++++++----- sbin/hammer/cmd_blockmap.c | 2 +- sbin/hammer/cmd_strip.c | 2 +- sbin/hammer/ondisk.c | 2 +- sbin/newfs_hammer/newfs_hammer.c | 2 +- sys/vfs/hammer/hammer.h | 3 +-- sys/vfs/hammer/hammer_blockmap.c | 14 +++++++------- sys/vfs/hammer/hammer_disk.h | 20 ++++++++++---------- sys/vfs/hammer/hammer_io.c | 3 +-- sys/vfs/hammer/hammer_ondisk.c | 6 ++---- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/sbin/hammer/blockmap.c b/sbin/hammer/blockmap.c index 75712a46bb..1ff4eb2071 100644 --- a/sbin/hammer/blockmap.c +++ b/sbin/hammer/blockmap.c @@ -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; diff --git a/sbin/hammer/cmd_blockmap.c b/sbin/hammer/cmd_blockmap.c index 1180a48373..5ea245cb5d 100644 --- a/sbin/hammer/cmd_blockmap.c +++ b/sbin/hammer/cmd_blockmap.c @@ -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); diff --git a/sbin/hammer/cmd_strip.c b/sbin/hammer/cmd_strip.c index 979397e283..04160abc7f 100644 --- a/sbin/hammer/cmd_strip.c +++ b/sbin/hammer/cmd_strip.c @@ -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); diff --git a/sbin/hammer/ondisk.c b/sbin/hammer/ondisk.c index 8efb4e717a..b499383fb8 100644 --- a/sbin/hammer/ondisk.c +++ b/sbin/hammer/ondisk.c @@ -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); diff --git a/sbin/newfs_hammer/newfs_hammer.c b/sbin/newfs_hammer/newfs_hammer.c index b7a4011f13..ee5a73269e 100644 --- a/sbin/newfs_hammer/newfs_hammer.c +++ b/sbin/newfs_hammer/newfs_hammer.c @@ -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); } diff --git a/sys/vfs/hammer/hammer.h b/sys/vfs/hammer/hammer.h index 35d7623c1a..42929c28e8 100644 --- a/sys/vfs/hammer/hammer.h +++ b/sys/vfs/hammer/hammer.h @@ -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 /* diff --git a/sys/vfs/hammer/hammer_blockmap.c b/sys/vfs/hammer/hammer_blockmap.c index b80ee2e196..e95ef465ac 100644 --- a/sys/vfs/hammer/hammer_blockmap.c +++ b/sys/vfs/hammer/hammer_blockmap.c @@ -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; diff --git a/sys/vfs/hammer/hammer_disk.h b/sys/vfs/hammer/hammer_disk.h index 130c411907..ef16b89f0a 100644 --- a/sys/vfs/hammer/hammer_disk.h +++ b/sys/vfs/hammer/hammer_disk.h @@ -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)) diff --git a/sys/vfs/hammer/hammer_io.c b/sys/vfs/hammer/hammer_io.c index b4d0c4624d..d0071d40a8 100644 --- a/sys/vfs/hammer/hammer_io.c +++ b/sys/vfs/hammer/hammer_io.c @@ -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); /* diff --git a/sys/vfs/hammer/hammer_ondisk.c b/sys/vfs/hammer/hammer_ondisk.c index a0193f54a7..49f3702c41 100644 --- a/sys/vfs/hammer/hammer_ondisk.c +++ b/sys/vfs/hammer/hammer_ondisk.c @@ -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); -- 2.11.4.GIT