Skip to contentSkip to conversation

ceph: fix statvfs fr_size

PATCH In review Sage Weil 2 participants 2 messages Feb 22, 2013 Ceph client

lore
Share & tools
lore

Sage Weil

author
#0 lore raw

PATCH 1/1 ceph: fix statvfs fr_size

Different versions of glibc are broken in different ways, but the short of it is that for the time being, frsize should == bsize, and be used as the multiple for the blocks, free, and available fields. This mirrors what is done for NFS. The previous reporting of the page size for frsize meant that newer glibc and df would report a very small value for the fs size.

Fixes http://tracker.ceph.com/issues/3793.

---
 fs/ceph/super.c |    7 ++++++-
 fs/ceph/super.h |    2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)
fs/ceph/super.c +6 -1
index e86aa99..006f94b 100644
@@ -71,8 +71,14 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
 	/*
 	 * express utilization in terms of large blocks to avoid
 	 * overflow on 32-bit machines.
+	 *
+	 * NOTE: for the time being, we make bsize == frsize so humor
+	 * not-yet-ancient versions of glibc that are broken.
+	 * Someday, we will probably want to report a real block
+	 * size...  whatever that may mean for a network file system!
 	 */
 	buf->f_bsize = 1 << CEPH_BLOCK_SHIFT;
+	buf->f_frsize = 1 << CEPH_BLOCK_SHIFT;
 	buf->f_blocks = le64_to_cpu(st.kb) >> (CEPH_BLOCK_SHIFT-10);
 	buf->f_bfree = le64_to_cpu(st.kb_avail) >> (CEPH_BLOCK_SHIFT-10);
 	buf->f_bavail = le64_to_cpu(st.kb_avail) >> (CEPH_BLOCK_SHIFT-10);
@@ -80,7 +86,6 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_files = le64_to_cpu(st.num_objects);
 	buf->f_ffree = -1;
 	buf->f_namelen = NAME_MAX;
-	buf->f_frsize = PAGE_CACHE_SIZE;
 
 	/* leave fsid little-endian, regardless of host endianness */
 	fsid = *(u64 *)(&monmap->fsid) ^ *((u64 *)&monmap->fsid + 1);
fs/ceph/super.h +1 -1
index 9861cce..604526a 100644
@@ -21,7 +21,7 @@
 
 /* large granularity for statfs utilization stats to facilitate
  * large volume sizes on 32-bit machines. */
-#define CEPH_BLOCK_SHIFT   20  /* 1 MB */
+#define CEPH_BLOCK_SHIFT   22  /* 4 MB */
 #define CEPH_BLOCK         (1 << CEPH_BLOCK_SHIFT)
 
 #define CEPH_MOUNT_OPT_DIRSTAT         (1<<4) /* `cat dirname` for stats */
Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Sage Weil

Different versions of glibc are broken in different ways, but the short of it is that for the time being, frsize should == bsize, and be used as the multiple for the blocks, free, and available fields. This mirrors what is done for NFS. The previous reporting of the page size for frsize meant that newer glibc and df would report a very small value for the fs size.

Fixes http://tracker.ceph.com/issues/3793.

---
 fs/ceph/super.c |    7 ++++++-
 fs/ceph/super.h |    2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)
fs/ceph/super.c +0 -0
index e86aa99..006f94b 100644

fs/ceph/super.c static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf) · line 75

Quoted 5 lines
fs/ceph/super.c +2 -0
@@ -71,8 +71,14 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
        /*
         * express utilization in terms of large blocks to avoid
         * overflow on 32-bit machines.
+        *
+        * NOTE: for the time being, we make bsize == frsize so humor

s/so/to :)

Quoted 22 lines
fs/ceph/super.c +4 -1
+        * not-yet-ancient versions of glibc that are broken.
+        * Someday, we will probably want to report a real block
+        * size...  whatever that may mean for a network file system!
         */
        buf->f_bsize = 1 << CEPH_BLOCK_SHIFT;
+       buf->f_frsize = 1 << CEPH_BLOCK_SHIFT;
        buf->f_blocks = le64_to_cpu(st.kb) >> (CEPH_BLOCK_SHIFT-10);
        buf->f_bfree = le64_to_cpu(st.kb_avail) >> (CEPH_BLOCK_SHIFT-10);
        buf->f_bavail = le64_to_cpu(st.kb_avail) >> (CEPH_BLOCK_SHIFT-10);
@@ -80,7 +86,6 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
        buf->f_files = le64_to_cpu(st.num_objects);
        buf->f_ffree = -1;
        buf->f_namelen = NAME_MAX;
-       buf->f_frsize = PAGE_CACHE_SIZE;
 
        /* leave fsid little-endian, regardless of host endianness */
        fsid = *(u64 *)(&monmap->fsid) ^ *((u64 *)&monmap->fsid + 1);
fs/ceph/super.h +0 -0
index 9861cce..604526a 100644

fs/ceph/super.h line 27

Quoted 8 lines
fs/ceph/super.h +1 -1
@@ -21,7 +21,7 @@
 
 /* large granularity for statfs utilization stats to facilitate
  * large volume sizes on 32-bit machines. */
-#define CEPH_BLOCK_SHIFT   20  /* 1 MB */
+#define CEPH_BLOCK_SHIFT   22  /* 4 MB */
 #define CEPH_BLOCK         (1 << CEPH_BLOCK_SHIFT)
 
 #define CEPH_MOUNT_OPT_DIRSTAT         (1<<4) /* `cat dirname` for stats */

I've already voiced my concerns about this (basically de-tuning the stack above us with the large block sizes), but I dunno that they have much validity and this should work from the POV of our code correctness, so other than the typo above