]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: prevent statfs available from going negative
authorSage Weil <sage@redhat.com>
Mon, 19 Feb 2018 16:16:24 +0000 (10:16 -0600)
committerPrashant D <pdhange@redhat.com>
Fri, 23 Feb 2018 03:29:58 +0000 (22:29 -0500)
Fixes: https://tracker.ceph.com/issues/23040
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 8709cbc2ecb207b622529f4813f06af3ccfca814)

src/os/bluestore/BlueStore.cc

index 66f21c598dfdbfd5170e6f31dfb466f8f18301a6..6a98ac0ec04ea9bc58144b69cd1ac4d73fb5294f 100644 (file)
@@ -6217,10 +6217,14 @@ int BlueStore::statfs(struct store_statfs_t *buf)
   buf->available = alloc->get_free();
 
   if (bluefs) {
-    // part of our shared device is "free" according to BlueFS
-    // Don't include bluestore_bluefs_min because that space can't
-    // be used for any other purpose.
-    buf->available += bluefs->get_free(bluefs_shared_bdev) - cct->_conf->bluestore_bluefs_min;
+    // part of our shared device is "free" according to BlueFS, but we
+    // can't touch bluestore_bluefs_min of it.
+    int64_t shared_available = std::min(
+      bluefs->get_free(bluefs_shared_bdev),
+      bluefs->get_total(bluefs_shared_bdev) - cct->_conf->bluestore_bluefs_min);
+    if (shared_available > 0) {
+      buf->available += shared_available;
+    }
 
     // include dedicated db, too, if that isn't the shared device.
     if (bluefs_shared_bdev != BlueFS::BDEV_DB) {