From: Sage Weil Date: Sun, 2 Jun 2013 21:03:45 +0000 (-0700) Subject: FileStore: add rmkeyrange X-Git-Tag: v0.66~50^2~16 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=53e1fda0c79f73a7168ea63bd7c51b554d9b4fa3;p=ceph.git FileStore: add rmkeyrange Handling it in DBObjectMap really only has efficiency advantages if the object is a clone. Signed-off-by: Samuel Just --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 4218f695bc34..9a89b95d9053 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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 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) diff --git a/src/os/FileStore.h b/src/os/FileStore.h index 78668dd92a41..5a2a0b88566f 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -486,6 +486,9 @@ private: const SequencerPosition &spos); int _omap_rmkeys(coll_t cid, const hobject_t &hoid, const set &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, diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 9f112647f823..b5e23b16cbe9 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -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& 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