From ec782fff8dd7a1407e197c830fd400911583345b Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sun, 23 Feb 2020 20:12:40 -0800 Subject: [PATCH] scoutfs-utils: meta and data free blocks The super block now tracks free metadata and data blocks in separate counters. Signed-off-by: Zach Brown --- utils/src/format.h | 3 ++- utils/src/mkfs.c | 3 ++- utils/src/print.c | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/utils/src/format.h b/utils/src/format.h index 6cfb7322..42eecc90 100644 --- a/utils/src/format.h +++ b/utils/src/format.h @@ -481,10 +481,11 @@ struct scoutfs_super_block { __le64 total_meta_blocks; /* both static and dynamic */ __le64 first_meta_blkno; /* first dynamically allocated */ __le64 last_meta_blkno; + __le64 free_meta_blocks; __le64 total_data_blocks; __le64 first_data_blkno; __le64 last_data_blkno; - __le64 free_blocks; + __le64 free_data_blocks; __le64 quorum_fenced_term; __le64 quorum_server_term; __le64 unmount_barrier; diff --git a/utils/src/mkfs.c b/utils/src/mkfs.c index 63a97aec..ac3393f6 100644 --- a/utils/src/mkfs.c +++ b/utils/src/mkfs.c @@ -457,7 +457,8 @@ static int write_new_fs(char *path, int fd, u8 quorum_count) } /* fill out allocator fields now that we've written our blocks */ - super->free_blocks = cpu_to_le64(total_blocks - next_meta); + super->free_meta_blocks = cpu_to_le64(last_meta - next_meta + 1); + super->free_data_blocks = cpu_to_le64(last_data - next_data + 1); /* write the super block */ super->hdr.seq = cpu_to_le64(1); diff --git a/utils/src/print.c b/utils/src/print.c index b755d65d..29c3ff3b 100644 --- a/utils/src/print.c +++ b/utils/src/print.c @@ -681,9 +681,8 @@ static void print_super_block(struct scoutfs_super_block *super, u64 blkno) /* XXX these are all in a crazy order */ printf(" next_ino %llu next_trans_seq %llu\n" - " total_meta_blocks %llu first_meta_blkno %llu last_meta_blkno %llu\n" - " total_data_blocks %llu first_data_blkno %llu last_data_blkno %llu\n" - " free_blocks %llu\n" + " total_meta_blocks %llu first_meta_blkno %llu last_meta_blkno %llu free_meta_blocks %llu\n" + " total_data_blocks %llu first_data_blkno %llu last_data_blkno %llu free_data_blocks %llu\n" " quorum_fenced_term %llu quorum_server_term %llu unmount_barrier %llu\n" " quorum_count %u server_addr %s\n" " core_meta_avail: "RADROOT_F"\n" @@ -699,10 +698,11 @@ static void print_super_block(struct scoutfs_super_block *super, u64 blkno) le64_to_cpu(super->total_meta_blocks), le64_to_cpu(super->first_meta_blkno), le64_to_cpu(super->last_meta_blkno), + le64_to_cpu(super->free_meta_blocks), le64_to_cpu(super->total_data_blocks), le64_to_cpu(super->first_data_blkno), le64_to_cpu(super->last_data_blkno), - le64_to_cpu(super->free_blocks), + le64_to_cpu(super->free_data_blocks), le64_to_cpu(super->quorum_fenced_term), le64_to_cpu(super->quorum_server_term), le64_to_cpu(super->unmount_barrier),