summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-06-02 14:03:45 -0700
committerSamuel Just <sam.just@inktank.com>2013-06-17 14:50:52 -0700
commit53e1fda0c79f73a7168ea63bd7c51b554d9b4fa3 (patch)
treee49ee592198a0112f5c4fa375a3b197837be3782
parent39245319ef1c6e1f12bbc8926785bae3ddbabd33 (diff)
downloadceph-53e1fda0c79f73a7168ea63bd7c51b554d9b4fa3.tar.gz
FileStore: add rmkeyrange
Handling it in DBObjectMap really only has efficiency advantages if the object is a clone. Signed-off-by: Samuel Just <sam.just@inktank.com>
-rw-r--r--src/os/FileStore.cc27
-rw-r--r--src/os/FileStore.h3
-rw-r--r--src/os/ObjectStore.h22
3 files changed, 52 insertions, 0 deletions
diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc
index 4218f695bc3..9a89b95d905 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<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)
diff --git a/src/os/FileStore.h b/src/os/FileStore.h
index 78668dd92a4..5a2a0b88566 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<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,
diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h
index 9f112647f82..b5e23b16cbe 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<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