From ab271f4682af8279ddf4a772810f0f225eb4ff12 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Fri, 3 Jul 2020 16:17:47 -0700 Subject: [PATCH] scoutfs: report sm metadata blocks in statfs The conversion of the super block metadata block counters to units of large metadata blocks forgot to scale back to the small block size when filling out the block count fields in the statfs rpc. This resulted in the free and total metadata use being off by the factor of large to small block size (default of ~16x at the moment). Signed-off-by: Zach Brown --- kmod/src/server.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kmod/src/server.c b/kmod/src/server.c index cb85fb24..ad21587f 100644 --- a/kmod/src/server.c +++ b/kmod/src/server.c @@ -849,6 +849,11 @@ out: &last_seq, sizeof(last_seq)); } +static inline __le64 le64_lg_to_sm(__le64 lg) +{ + return cpu_to_le64(le64_to_cpu(lg) << SCOUTFS_BLOCK_SM_LG_SHIFT); +} + /* * Sample the super stats that the client wants for statfs by serializing * with each component. @@ -872,10 +877,10 @@ static int server_statfs(struct super_block *sb, spin_unlock(&sbi->next_ino_lock); down_read(&server->alloc_rwsem); - nstatfs.total_blocks = super->total_meta_blocks; + nstatfs.total_blocks = le64_lg_to_sm(super->total_meta_blocks); le64_add_cpu(&nstatfs.total_blocks, le64_to_cpu(super->total_data_blocks)); - nstatfs.bfree = super->free_meta_blocks; + nstatfs.bfree = le64_lg_to_sm(super->free_meta_blocks); le64_add_cpu(&nstatfs.bfree, le64_to_cpu(super->free_data_blocks)); up_read(&server->alloc_rwsem);