]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: use db->rm_range_keys to delete range of keys 18279/head
authorlisali <xiaoyan.li@intel.com>
Fri, 13 Oct 2017 09:51:39 +0000 (05:51 -0400)
committerlisali <xiaoyan.li@intel.com>
Tue, 17 Oct 2017 10:56:44 +0000 (06:56 -0400)
As Key Value DB provides the rm_range_keys interface to remove
some range of keys, BlueStore should use the interface. DB can
provide more efficient ways.

Signed-off-by: Xiaoyan Li <xiaoyan.li@intel.com>
src/os/bluestore/BlueStore.cc

index 97179348b5b6e02e8a4565f18b61622b54ed4f05..6fc24a1af33e3f7dc71f5f091836d187a22c0358 100644 (file)
@@ -10877,17 +10877,10 @@ void BlueStore::_do_omap_clear(TransContext *txc, const string& omap_prefix,
   string prefix, tail;
   get_omap_header(id, &prefix);
   get_omap_tail(id, &tail);
-  it->lower_bound(prefix);
-  while (it->valid()) {
-    if (it->key() >= tail) {
-      dout(30) << __func__ << "  stop at " << pretty_binary_string(tail)
-              << dendl;
-      break;
-    }
-    txc->t->rmkey(omap_prefix, it->key());
-    dout(30) << __func__ << "  rm " << pretty_binary_string(it->key()) << dendl;
-    it->next();
-  }
+  txc->t->rm_range_keys(omap_prefix, prefix, tail);
+  dout(30) << __func__ << "remove range start: "
+           << pretty_binary_string(prefix) << " end: "
+           << pretty_binary_string(tail) << dendl;
 }
 
 int BlueStore::_omap_clear(TransContext *txc,
@@ -11027,21 +11020,12 @@ int BlueStore::_omap_rmkey_range(TransContext *txc,
     const string& prefix =
       o->onode.is_pgmeta_omap() ? PREFIX_PGMETA_OMAP : PREFIX_OMAP;
     o->flush();
-    it = db->get_iterator(prefix);
     get_omap_key(o->onode.nid, first, &key_first);
     get_omap_key(o->onode.nid, last, &key_last);
-    it->lower_bound(key_first);
-    while (it->valid()) {
-      if (it->key() >= key_last) {
-       dout(30) << __func__ << "  stop at " << pretty_binary_string(key_last)
-                << dendl;
-       break;
-      }
-      txc->t->rmkey(prefix, it->key());
-      dout(30) << __func__ << "  rm " << pretty_binary_string(it->key())
-              << dendl;
-      it->next();
-    }
+    txc->t->rm_range_keys(prefix, key_first, key_last);
+    dout(30) << __func__ << "remove range start: "
+             << pretty_binary_string(key_first) << " end: "
+             << pretty_binary_string(key_last) << dendl;
   }
   txc->note_modified_object(o);