From: Tang Junhui Date: Mon, 29 Apr 2019 08:31:55 +0000 (+0800) Subject: os/bluestore: fix missing discard in BlueStore::_kv_sync_thread X-Git-Tag: v15.1.0~2724^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f6205d2eb2b8297b914afbaf54a8311f087eec90;p=ceph-ci.git os/bluestore: fix missing discard in BlueStore::_kv_sync_thread Discard comand should be issued before space released. Signed-off-by: Junhui Tang Fixes: https://tracker.ceph.com/issues/39621 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index e0de190a1dd..1fb13f409a0 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -9874,7 +9874,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(); } }