From: Xiubo Li Date: Tue, 28 Jun 2022 02:42:10 +0000 (+0800) Subject: client: set total and used to 4KB if quota size less than 4KB X-Git-Tag: v19.0.0~1459^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7490cc52119dedc7aae9eeaa87b407b0c9cebf4e;p=ceph.git client: set total and used to 4KB if quota size less than 4KB For quota size less than 4KB, report the total=used=4KB,free=0 when quota is full and total=free=4KB, used=0 otherwise. This is from Kotresh's kceph's fix. Fixes: https://tracker.ceph.com/issues/56397 Signed-off-by: Xiubo Li --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 88cb711bf360..752aea9186f5 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -11221,7 +11221,6 @@ int Client::statfs(const char *path, struct statvfs *stbuf, * actually *is* the (ceph) default block size. */ stbuf->f_frsize = CEPH_4M_BLOCK_SIZE; - stbuf->f_bsize = CEPH_4M_BLOCK_SIZE; stbuf->f_files = total_files_on_fs; stbuf->f_ffree = -1; stbuf->f_favail = -1; @@ -11261,11 +11260,19 @@ int Client::statfs(const char *path, struct statvfs *stbuf, // Special case: if there is a size quota set on the Inode acting // as the root for this client mount, then report the quota status // as the filesystem statistics. - const fsblkcnt_t total = quota_root->quota.max_bytes >> CEPH_4M_BLOCK_SHIFT; + fsblkcnt_t total = quota_root->quota.max_bytes >> CEPH_4M_BLOCK_SHIFT; const fsblkcnt_t used = quota_root->rstat.rbytes >> CEPH_4M_BLOCK_SHIFT; // It is possible for a quota to be exceeded: arithmetic here must // handle case where used > total. - const fsblkcnt_t free = total > used ? total - used : 0; + fsblkcnt_t free = total > used ? total - used : 0; + + // For quota size less than 4KB, report the total=used=4KB,free=0 + // when quota is full and total=free=4KB, used=0 otherwise. + if (!total) { + total = 1; + free = quota_root->quota.max_bytes > quota_root->rstat.rbytes ? 1 : 0; + stbuf->f_frsize = CEPH_4K_BLOCK_SIZE; + } stbuf->f_blocks = total; stbuf->f_bfree = free; @@ -11278,6 +11285,7 @@ int Client::statfs(const char *path, struct statvfs *stbuf, stbuf->f_bfree = stats.kb_avail >> CEPH_4K_BLOCK_SHIFT; stbuf->f_bavail = stats.kb_avail >> CEPH_4K_BLOCK_SHIFT; } + stbuf->f_bsize = stbuf->f_frsize; return rval; }