From c2b47d84c1f3b6fa1629a815aaecd1c2661032c6 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 2 Jan 2017 09:21:31 -0800 Subject: [PATCH] Add next_seg_seq field to super Signed-off-by: Zach Brown --- utils/src/format.h | 3 ++- utils/src/mkfs.c | 3 ++- utils/src/print.c | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/utils/src/format.h b/utils/src/format.h index c611ea32..6495d457 100644 --- a/utils/src/format.h +++ b/utils/src/format.h @@ -151,7 +151,7 @@ struct scoutfs_segment_block { __le32 crc; __le32 _padding; __le64 segno; - __le64 max_seq; + __le64 seq; __le32 nr_items; __le32 _moar_pads; struct scoutfs_segment_item items[0]; @@ -342,6 +342,7 @@ struct scoutfs_super_block { __le64 ring_blocks; __le64 ring_tail_block; __le64 ring_gen; + __le64 next_seg_seq; __le64 buddy_blocks; struct scoutfs_buddy_root buddy_root; struct scoutfs_btree_root btree_root; diff --git a/utils/src/mkfs.c b/utils/src/mkfs.c index 0a10d5d3..26560194 100644 --- a/utils/src/mkfs.c +++ b/utils/src/mkfs.c @@ -153,6 +153,7 @@ static int write_new_fs(char *path, int fd) super->ring_blocks = cpu_to_le64(ring_blocks); super->ring_tail_block = cpu_to_le64(1); super->ring_gen = cpu_to_le64(1); + super->next_seg_seq = cpu_to_le64(2); first_segno = DIV_ROUND_UP(le64_to_cpu(super->ring_blkno) + le64_to_cpu(super->ring_blocks), @@ -163,7 +164,7 @@ static int write_new_fs(char *path, int fd) /* write seg with root inode */ sblk->segno = cpu_to_le64(first_segno); - sblk->max_seq = cpu_to_le64(1); + sblk->seq = cpu_to_le64(1); sblk->nr_items = cpu_to_le32(1); ikey = (void *)&sblk->items[1]; diff --git a/utils/src/print.c b/utils/src/print.c index 14de06d7..8e756233 100644 --- a/utils/src/print.c +++ b/utils/src/print.c @@ -224,6 +224,13 @@ static void print_item(struct scoutfs_segment_block *sblk, u32 pos) printer(key, item.key_len, val, item.val_len); } +static void print_segment_block(struct scoutfs_segment_block *sblk) +{ + printf(" sblk: segno %llu seq %llu nr_items %u\n", + le64_to_cpu(sblk->segno), le64_to_cpu(sblk->seq), + le32_to_cpu(sblk->nr_items)); +} + static int print_segment(int fd, u64 segno) { struct scoutfs_segment_block *sblk; @@ -234,7 +241,7 @@ static int print_segment(int fd, u64 segno) return -ENOMEM; printf("segment segno %llu\n", segno); -// print_block_header(&sblk->hdr); + print_segment_block(sblk); for (i = 0; i < le32_to_cpu(sblk->nr_items); i++) print_item(sblk, i); @@ -376,7 +383,8 @@ static int print_super_blocks(int fd) /* XXX these are all in a crazy order */ 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", + " ring_gen %llu alloc_uninit %llu total_segs %llu\n" + " next_seg_seq %llu\n", le64_to_cpu(super->next_ino), le64_to_cpu(super->total_blocks), le64_to_cpu(super->free_blocks), @@ -385,7 +393,8 @@ static int print_super_blocks(int fd) le64_to_cpu(super->ring_tail_block), le64_to_cpu(super->ring_gen), le64_to_cpu(super->alloc_uninit), - le64_to_cpu(super->total_segs)); + le64_to_cpu(super->total_segs), + le64_to_cpu(super->next_seg_seq)); printf(" alloc root:"); print_treap_ref(&super->alloc_treap_root.ref); printf("\n");