]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: avoid returning negative space available 15481/head
authorJohn Spray <john.spray@redhat.com>
Mon, 5 Jun 2017 10:30:45 +0000 (11:30 +0100)
committerJohn Spray <john.spray@redhat.com>
Mon, 5 Jun 2017 20:08:37 +0000 (21:08 +0100)
...when a quota is set and the used bytes exceed
the quota.

Fixes: http://tracker.ceph.com/issues/20178
Signed-off-by: John Spray <john.spray@redhat.com>
src/client/Client.cc

index cbb216aa76822c2540782295ef1913dd9149786a..9d5ad6bc140eceed2ae367d7267644dc75fce536 100644 (file)
@@ -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;