From: Guang Yang Date: Mon, 7 Jul 2014 07:37:02 +0000 (+0000) Subject: Add a new transaction OP (collection hint) to ObjectStore. X-Git-Tag: v0.86~240^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7d266d1304574a7a5603da63e44813dec016b0b6;p=ceph.git Add a new transaction OP (collection hint) to ObjectStore. Signed-off-by: Guang Yang (yguang@yahoo-inc.com) --- diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 3a0c1412746a..1c11c0960cac 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -368,6 +368,7 @@ public: OP_COLL_MOVE_RENAME = 38, // oldcid, oldoid, newcid, newoid OP_SETALLOCHINT = 39, // cid, oid, object_size, write_size + OP_COLL_HINT = 40, // cid, type, bl }; private: @@ -823,6 +824,24 @@ public: ::encode(cid, tbl); ops++; } + + /** + * Give the collection a hint. + * + * @param cid - collection id. + * @param type - hint type. + * @param hint - the hint payload, which contains the customized + * data along with the hint type. + */ + void collection_hint(coll_t cid, uint32_t type, const bufferlist& hint) { + __u32 op = OP_COLL_HINT; + ::encode(op, tbl); + ::encode(cid, tbl); + ::encode(type, tbl); + ::encode(hint, tbl); + ops++; + } + /// remove the collection, the collection must be empty void remove_collection(coll_t cid) { __u32 op = OP_RMCOLL; diff --git a/src/os/Transaction.cc b/src/os/Transaction.cc index 668b8fb54331..4bf12fa7af54 100644 --- a/src/os/Transaction.cc +++ b/src/os/Transaction.cc @@ -205,6 +205,16 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f) } break; + case Transaction::OP_COLL_HINT: + { + coll_t cid = i.decode_cid(); + uint32_t type = i.decode_u32(); + f->dump_string("op_name", "coll_hint"); + f->dump_stream("collection") << cid; + f->dump_unsigned("type", type); + } + break; + case Transaction::OP_RMCOLL: { coll_t cid = i.decode_cid(); diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index a9b40026cb0f..b4149b604717 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -157,6 +157,7 @@ CompatSet OSD::get_osd_initial_compat_set() { ceph_osd_feature_incompat.insert(CEPH_OSD_FEATURE_INCOMPAT_LEVELDBINFO); ceph_osd_feature_incompat.insert(CEPH_OSD_FEATURE_INCOMPAT_LEVELDBLOG); ceph_osd_feature_incompat.insert(CEPH_OSD_FEATURE_INCOMPAT_SNAPMAPPER); + ceph_osd_feature_incompat.insert(CEPH_OSD_FEATURE_INCOMPAT_HINTS); return CompatSet(ceph_osd_feature_compat, ceph_osd_feature_ro_compat, ceph_osd_feature_incompat); } diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index deb30f480cbc..4dab643f137e 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -54,6 +54,7 @@ #define CEPH_OSD_FEATURE_INCOMPAT_LEVELDBLOG CompatSet::Feature(9, "leveldblog") #define CEPH_OSD_FEATURE_INCOMPAT_SNAPMAPPER CompatSet::Feature(10, "snapmapper") #define CEPH_OSD_FEATURE_INCOMPAT_SHARDS CompatSet::Feature(11, "sharded objects") +#define CEPH_OSD_FEATURE_INCOMPAT_HINTS CompatSet::Feature(12, "transaction hints") /// max recovery priority for MBackfillReserve