From c9da3076d67d562b0c93894897a2f17576e426f5 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Mon, 20 Jun 2011 12:17:24 -0700 Subject: [PATCH] uclient: Update statfs to match the kernel client and its block sizing. 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 --- src/client/Client.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index f189a50236a3c..774be08af8bcf 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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; -- 2.39.5