]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix missing discard in BlueStore::_kv_sync_thread 28258/head
authorTang Junhui <tangjunhui.linux@gmail.com>
Mon, 29 Apr 2019 08:31:55 +0000 (16:31 +0800)
committerPrashant D <pdhange@redhat.com>
Mon, 27 May 2019 23:42:02 +0000 (19:42 -0400)
Discard comand should be issued before space released.

Signed-off-by: Junhui Tang <tangjunhui@sangfor.com.cn>
Fixes: https://tracker.ceph.com/issues/39621
(cherry picked from commit f6205d2eb2b8297b914afbaf54a8311f087eec90)

src/os/bluestore/BlueStore.cc

index 552625a437841e8c732b26f4c6e84c6a35fba091..ecdc3de95fcdeca80efb64e7f6150f1143546be0 100644 (file)
@@ -10555,7 +10555,20 @@ void BlueStore::_kv_sync_thread()
        if (!bluefs_extents_reclaiming.empty()) {
          dout(0) << __func__ << " releasing old bluefs 0x" << std::hex
                   << bluefs_extents_reclaiming << std::dec << dendl;
+         int r = 0;
+         if (cct->_conf->bdev_enable_discard && cct->_conf->bdev_async_discard) {
+           r = bdev->queue_discard(bluefs_extents_reclaiming);
+           if (r == 0) {
+             goto clear;
+           }
+         } else if (cct->_conf->bdev_enable_discard) {
+           for (auto p = bluefs_extents_reclaiming.begin(); p != bluefs_extents_reclaiming.end(); ++p) {
+             bdev->discard(p.get_start(), p.get_len());
+           }
+         }
+
          alloc->release(bluefs_extents_reclaiming);
+clear:
          bluefs_extents_reclaiming.clear();
        }
       }