From: John Spray Date: Mon, 5 Jun 2017 10:30:45 +0000 (+0100) Subject: client: avoid returning negative space available X-Git-Tag: v12.1.0~76^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0144fde1b1639a6917e487f78490f2b84dceeae6;p=ceph.git client: avoid returning negative space available ...when a quota is set and the used bytes exceed the quota. Fixes: http://tracker.ceph.com/issues/20178 Signed-off-by: John Spray --- diff --git a/src/client/Client.cc b/src/client/Client.cc index cbb216aa7682..9d5ad6bc140e 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -9361,8 +9361,9 @@ int Client::statfs(const char *path, struct statvfs *stbuf, // as the filesystem statistics. const fsblkcnt_t total = quota_root->quota.max_bytes >> CEPH_BLOCK_SHIFT; const fsblkcnt_t used = quota_root->rstat.rbytes >> CEPH_BLOCK_SHIFT; - const fsblkcnt_t free = total - used; - + // 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; stbuf->f_blocks = total; stbuf->f_bfree = free;