From 5f0dbc5f85d48c72a00028251ecc4c5c8c7bdcfe Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 11 May 2020 16:57:00 -0700 Subject: [PATCH] scoutfs-utils: remove radix _first fields The recent cleanup of the radix allocator included removing tracking of the first set bits or references in blocks. Signed-off-by: Zach Brown --- utils/src/format.h | 2 -- utils/src/mkfs.c | 37 ++++++++++++------------------------- utils/src/print.c | 2 -- 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/utils/src/format.h b/utils/src/format.h index dc83c506..8418a638 100644 --- a/utils/src/format.h +++ b/utils/src/format.h @@ -167,8 +167,6 @@ struct scoutfs_key { struct scoutfs_radix_block { struct scoutfs_block_header hdr; - __le32 sm_first; - __le32 lg_first; union { struct scoutfs_radix_ref { __le64 blkno; diff --git a/utils/src/mkfs.c b/utils/src/mkfs.c index 1aa46700..d6932b61 100644 --- a/utils/src/mkfs.c +++ b/utils/src/mkfs.c @@ -102,17 +102,7 @@ static void update_parent_ref(struct scoutfs_radix_ref *ref, ref->sm_total = cpu_to_le64(0); ref->lg_total = cpu_to_le64(0); - rdx->sm_first = cpu_to_le32(SCOUTFS_RADIX_REFS); - rdx->lg_first = cpu_to_le32(SCOUTFS_RADIX_REFS); - for (i = 0; i < SCOUTFS_RADIX_REFS; i++) { - if (le32_to_cpu(rdx->sm_first) == SCOUTFS_RADIX_REFS && - rdx->refs[i].sm_total != 0) - rdx->sm_first = cpu_to_le32(i); - if (le32_to_cpu(rdx->lg_first) == SCOUTFS_RADIX_REFS && - rdx->refs[i].lg_total != 0) - rdx->lg_first = cpu_to_le32(i); - le64_add_cpu(&ref->sm_total, le64_to_cpu(rdx->refs[i].sm_total)); le64_add_cpu(&ref->lg_total, @@ -138,6 +128,7 @@ static void set_radix_path(struct scoutfs_super_block *super, int *inds, u64 first, u64 last) { struct scoutfs_radix_block *rdx; + bool shared; int lg_ind; int lg_after; u64 bno; @@ -160,24 +151,24 @@ static void set_radix_path(struct scoutfs_super_block *super, int *inds, if (ref->sm_total == 0) { for (i = 0; i < SCOUTFS_RADIX_REFS; i++) radix_init_ref(&rdx->refs[i], level - 1, false); + shared = false; + } else { + shared = true; } if (left) { /* initialize full refs from left to end */ for (i = ind + 1; i < SCOUTFS_RADIX_REFS; i++) radix_init_ref(&rdx->refs[i], level - 1, true); - } else { - /* initialize full refs from start or left to right */ - for (i = le32_to_cpu(rdx->sm_first) != - SCOUTFS_RADIX_REFS ? - le32_to_cpu(rdx->sm_first) + 1 : 0; - i < ind; i++) - radix_init_ref(&rdx->refs[i], level - 1, true); - /* wipe full refs from right (maybe including) to end */ - for (i = le64_to_cpu(rdx->refs[ind].blkno) == U64_MAX ? - ind : ind + 1; i < SCOUTFS_RADIX_REFS; i++) + } else if (shared) { + /* wipe full refs including right to end */ + for (i = ind; i < SCOUTFS_RADIX_REFS; i++) radix_init_ref(&rdx->refs[i], level - 1, false); + } else { + /* initialize full refs from start to right */ + for (i = 0; i < ind - 1; i++) + radix_init_ref(&rdx->refs[i], level - 1, true); } set_radix_path(super, inds, &rdx->refs[ind], level - 1, left, @@ -185,21 +176,17 @@ static void set_radix_path(struct scoutfs_super_block *super, int *inds, update_parent_ref(ref, rdx); } else { + ind = first - radix_calc_leaf_bit(first); end = last - radix_calc_leaf_bit(last); for (i = ind; i <= end; i++) set_bit_le(i, rdx->bits); - rdx->sm_first = cpu_to_le32(ind); ref->sm_total = cpu_to_le64(end - ind + 1); lg_ind = round_up(ind, SCOUTFS_RADIX_LG_BITS); lg_after = round_down(end + 1, SCOUTFS_RADIX_LG_BITS); - if (lg_ind < SCOUTFS_RADIX_BITS) - rdx->lg_first = cpu_to_le32(lg_ind); - else - rdx->lg_first = cpu_to_le32(SCOUTFS_RADIX_BITS); ref->lg_total = cpu_to_le64(lg_after - lg_ind); } } diff --git a/utils/src/print.c b/utils/src/print.c index 9040611c..ecf4e862 100644 --- a/utils/src/print.c +++ b/utils/src/print.c @@ -554,8 +554,6 @@ static int print_radix_block(int fd, struct scoutfs_radix_ref *par, int level) printf("radix parent block blkno %llu\n", le64_to_cpu(par->blkno)); print_block_header(&rdx->hdr, SCOUTFS_BLOCK_LG_SIZE); - printf(" sm_first %u lg_first %u\n", - le32_to_cpu(rdx->sm_first), le32_to_cpu(rdx->lg_first)); prev = 0; for (i = 0; i < SCOUTFS_RADIX_REFS; i++) {