Describe ring log with index,nr

Update mkfs and print to describe the ring blocks with a starting index
and number of blocks instead of a head and tail index.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2016-12-08 11:16:05 -08:00
parent 19b674cb38
commit c3b6dd0763
3 changed files with 17 additions and 16 deletions

View File

@@ -316,9 +316,9 @@ struct scoutfs_super_block {
__le64 free_blocks;
__le64 ring_blkno;
__le64 ring_blocks;
__le64 ring_head_index;
__le64 ring_tail_index;
__le64 ring_head_seq;
__le64 ring_index;
__le64 ring_nr;
__le64 ring_seq;
__le64 buddy_blocks;
struct scoutfs_buddy_root buddy_root;
struct scoutfs_btree_root btree_root;

View File

@@ -146,7 +146,8 @@ static int write_new_fs(char *path, int fd)
super->alloc_uninit = cpu_to_le64(SCOUTFS_ALLOC_REGION_BITS);
super->ring_blkno = cpu_to_le64(SCOUTFS_SUPER_BLKNO + 2);
super->ring_blocks = cpu_to_le64(ring_blocks);
super->ring_head_seq = cpu_to_le64(1);
super->ring_nr = cpu_to_le64(1);
super->ring_seq = cpu_to_le64(1);
first_segno = DIV_ROUND_UP(le64_to_cpu(super->ring_blkno) +
le64_to_cpu(super->ring_blocks),

View File

@@ -323,25 +323,23 @@ static int print_ring_blocks(int fd, struct scoutfs_super_block *super,
{
int ret = 0;
u64 blkno;
u16 index;
u16 tail;
u64 index;
u64 nr;
int err;
index = le64_to_cpu(super->ring_head_index);
tail = le64_to_cpu(super->ring_tail_index);
index = le64_to_cpu(super->ring_index);
nr = le64_to_cpu(super->ring_nr);
for(;;) {
while (nr) {
blkno = le64_to_cpu(super->ring_blkno) + index;
err = print_ring_block(fd, seg_map, blkno);
if (err && !ret)
ret = err;
if (index == tail)
break;
if (++index == le64_to_cpu(super->ring_blocks))
index = 0;
nr--;
};
return ret;
@@ -371,15 +369,17 @@ static int print_super_blocks(int fd)
le64_to_cpu(super->id), uuid_str);
/* 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_head %llu\n"
" ring_tail %llu alloc_uninit %llu total_segs %llu\n",
" ring_blkno %llu ring_blocks %llu ring_index %llu\n"
" ring_nr %llu ring_seq %llu alloc_uninit %llu\n"
" total_segs %llu\n",
le64_to_cpu(super->next_ino),
le64_to_cpu(super->total_blocks),
le64_to_cpu(super->free_blocks),
le64_to_cpu(super->ring_blkno),
le64_to_cpu(super->ring_blocks),
le64_to_cpu(super->ring_head_index),
le64_to_cpu(super->ring_tail_index),
le64_to_cpu(super->ring_index),
le64_to_cpu(super->ring_nr),
le64_to_cpu(super->ring_seq),
le64_to_cpu(super->alloc_uninit),
le64_to_cpu(super->total_segs));