Add support for free_segs in super

The allocator records the total number of free segments in the super
block.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2017-04-18 14:20:43 -07:00
parent 44f8551fb6
commit acda5a3bf1
3 changed files with 7 additions and 2 deletions
+3
View File
@@ -23,6 +23,8 @@
#define SCOUTFS_SEGMENT_MASK (SCOUTFS_SEGMENT_SIZE - 1)
#define SCOUTFS_SEGMENT_PAGES (SCOUTFS_SEGMENT_SIZE / PAGE_SIZE)
#define SCOUTFS_SEGMENT_BLOCKS (SCOUTFS_SEGMENT_SIZE / SCOUTFS_BLOCK_SIZE)
#define SCOUTFS_SEGMENT_BLOCK_SHIFT \
(SCOUTFS_SEGMENT_SHIFT - SCOUTFS_BLOCK_SHIFT)
#define SCOUTFS_PAGES_PER_BLOCK (SCOUTFS_BLOCK_SIZE / PAGE_SIZE)
#define SCOUTFS_BLOCK_PAGE_ORDER (SCOUTFS_BLOCK_SHIFT - PAGE_SHIFT)
@@ -350,6 +352,7 @@ struct scoutfs_super_block {
__le64 next_ino;
__le64 alloc_uninit;
__le64 total_segs;
__le64 free_segs;
__le64 total_blocks;
__le64 free_blocks;
__le64 ring_blkno;
+1
View File
@@ -159,6 +159,7 @@ static int write_new_fs(char *path, int fd)
/* alloc from uninit, don't need regions yet */
super->alloc_uninit = cpu_to_le64(first_segno + 1);
super->free_segs = cpu_to_le64(total_segs - (first_segno + 1));
/* write seg with root inode */
sblk->segno = cpu_to_le64(first_segno);
+3 -2
View File
@@ -408,7 +408,7 @@ static int print_super_blocks(int fd)
printf(" next_ino %llu total_blocks %llu free_blocks %llu\n"
" ring_blkno %llu ring_blocks %llu ring_tail_block %llu\n"
" ring_gen %llu alloc_uninit %llu total_segs %llu\n"
" next_seg_seq %llu\n",
" next_seg_seq %llu free_segs %llu\n",
le64_to_cpu(super->next_ino),
le64_to_cpu(super->total_blocks),
le64_to_cpu(super->free_blocks),
@@ -418,7 +418,8 @@ static int print_super_blocks(int fd)
le64_to_cpu(super->ring_gen),
le64_to_cpu(super->alloc_uninit),
le64_to_cpu(super->total_segs),
le64_to_cpu(super->next_seg_seq));
le64_to_cpu(super->next_seg_seq),
le64_to_cpu(super->free_segs));
printf(" alloc root:");
print_treap_ref(&super->alloc_treap_root.ref);
printf("\n");