]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore: add rmkeyrange
authorSage Weil <sage@inktank.com>
Sun, 2 Jun 2013 21:03:45 +0000 (14:03 -0700)
committerSamuel Just <sam.just@inktank.com>
Mon, 17 Jun 2013 21:50:52 +0000 (14:50 -0700)
Handling it in DBObjectMap really only has efficiency
advantages if the object is a clone.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/os/FileStore.cc
src/os/FileStore.h
src/os/ObjectStore.h

index 4218f695bc347d1d969b95900cd174058d3b74bf..9a89b95d9053189185e5b5ed462a398baa2ebb13 100644 (file)
@@ -2595,6 +2595,16 @@ unsigned FileStore::_do_transaction(Transaction& t, uint64_t op_seq, int trans_n
        r = _omap_rmkeys(cid, oid, keys, spos);
       }
       break;
+    case Transaction::OP_OMAP_RMKEYRANGE:
+      {
+       coll_t cid(i.get_cid());
+       hobject_t oid = i.get_oid();
+       string first, last;
+       first = i.get_key();
+       last = i.get_key();
+       r = _omap_rmkeyrange(cid, oid, first, last, spos);
+      }
+      break;
     case Transaction::OP_OMAP_SETHEADER:
       {
        coll_t cid(i.get_cid());
@@ -4651,6 +4661,23 @@ int FileStore::_omap_rmkeys(coll_t cid, const hobject_t &hoid,
   return 0;
 }
 
+int FileStore::_omap_rmkeyrange(coll_t cid, const hobject_t &hoid,
+                               const string& first, const string& last,
+                               const SequencerPosition &spos) {
+  dout(15) << __func__ << " " << cid << "/" << hoid << " [" << first << "," << last << "]" << dendl;
+  set<string> keys;
+  {
+    ObjectMap::ObjectMapIterator iter = get_omap_iterator(cid, hoid);
+    if (!iter)
+      return -ENOENT;
+    for (iter->lower_bound(first); iter->valid() && iter->key() < last;
+        iter->next()) {
+      keys.insert(iter->key());
+    }
+  }
+  return _omap_rmkeys(cid, hoid, keys, spos);
+}
+
 int FileStore::_omap_setheader(coll_t cid, const hobject_t &hoid,
                               const bufferlist &bl,
                               const SequencerPosition &spos)
index 78668dd92a41afce674ec1354ce55db46b2ffe3e..5a2a0b88566f67134a76f01c45006b346851b0e4 100644 (file)
@@ -486,6 +486,9 @@ private:
                    const SequencerPosition &spos);
   int _omap_rmkeys(coll_t cid, const hobject_t &hoid, const set<string> &keys,
                   const SequencerPosition &spos);
+  int _omap_rmkeyrange(coll_t cid, const hobject_t &hoid,
+                      const string& first, const string& last,
+                      const SequencerPosition &spos);
   int _omap_setheader(coll_t cid, const hobject_t &hoid, const bufferlist &bl,
                      const SequencerPosition &spos);
   int _split_collection(coll_t cid, uint32_t bits, uint32_t rem, coll_t dest,
index 9f112647f8235fb16fa48b1e65cbe59e0fa36a87..b5e23b16cbe9f50602408d7f52c27932c7eb099a 100644 (file)
@@ -155,6 +155,7 @@ public:
       OP_SPLIT_COLLECTION = 35, // cid, bits, destination
       OP_SPLIT_COLLECTION2 = 36, /* cid, bits, destination
                                    doesn't create the destination */
+      OP_OMAP_RMKEYRANGE = 37,  // cid, oid, firstkey, lastkey
     };
 
   private:
@@ -357,6 +358,11 @@ public:
        ::decode(s, p);
        return s;
       }
+      string get_key() {
+       string s;
+       ::decode(s, p);
+       return s;
+      }
       void get_attrset(map<string,bufferptr>& aset) {
        ::decode(aset, p);
       }
@@ -606,6 +612,22 @@ public:
       ops++;
     }
 
+    /// Remove key range from hoid omap
+    void omap_rmkeyrange(
+      coll_t cid,             ///< [in] Collection containing hoid
+      const hobject_t &hoid,  ///< [in] Object from which to remove the omap
+      const string& first,    ///< [in] first key in range
+      const string& last      ///< [in] first key past range
+      ) {
+      __u32 op = OP_OMAP_RMKEYRANGE;
+      ::encode(op, tbl);
+      ::encode(cid, tbl);
+      ::encode(hoid, tbl);
+      ::encode(first, tbl);
+      ::encode(last, tbl);
+      ops++;
+    }
+
     /// Set omap header
     void omap_setheader(
       coll_t cid,             ///< [in] Collection containing hoid