]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
uclient: Update statfs to match the kernel client and its block sizing.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Mon, 20 Jun 2011 19:17:24 +0000 (12:17 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Wed, 22 Jun 2011 21:22:54 +0000 (14:22 -0700)
Make it better match the kernel client, and its scheme to use a large
block size so we don't overflow 32-bit systems. This isn't presently
a serious concern since FUSE doesn't work on 32-bit systems anyway,
but the output of df should match even so.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/client/Client.cc

index f189a50236a3c50b3289340207b62c345d17fb76..774be08af8bcf7631c92fc1845c15f9ef28c12c6 100644 (file)
@@ -5316,13 +5316,17 @@ int Client::statfs(const char *path, struct statvfs *stbuf)
   client_lock.Lock();
 
   memset(stbuf, 0, sizeof(*stbuf));
-  //divide the results by 4 to give them as Posix expects
-  stbuf->f_blocks = stats.kb/4;
-  stbuf->f_bfree = stats.kb_avail/4;
-  stbuf->f_bavail = stats.kb_avail/4;
+
+  /* we're going to set a block size of 1MB so we can represent larger
+   * FSes without overflowing. Additionally convert the space measurements
+   * from KB to bytes while making them in terms of blocks.
+   */
+  const int CEPH_BLOCK_SHIFT = 20;
+  stbuf->f_bsize = 1 << CEPH_BLOCK_SHIFT;
+  stbuf->f_blocks = stats.kb >> (CEPH_BLOCK_SHIFT - 10);
+  stbuf->f_bfree = stats.kb_avail >> (CEPH_BLOCK_SHIFT - 10);
+  stbuf->f_bavail = stats.kb_avail >> (CEPH_BLOCK_SHIFT - 10);
   stbuf->f_files = stats.num_objects;
-  //fill in rest to make Posix happy
-  stbuf->f_bsize = PAGE_SIZE;
   stbuf->f_frsize = PAGE_SIZE;
   stbuf->f_ffree = -1;
   stbuf->f_favail = -1;