From fda601976bace2b84b230de0c1fb863ed43090b5 Mon Sep 17 00:00:00 2001 From: Dong Yuan Date: Wed, 10 Dec 2014 11:56:49 +0000 Subject: [PATCH] osd: add feature CEPH_FEATURE_OSD_TRANSACTION_MAY_LAYOUT (1ULL<<47)>>) This feature determine whether we use tbl encode for transaction of use the new map layout. The primary uses peer_features to determine whether transaction should use tbl, while the replica just follow the primary. Change-Id: I92ca6e5b59bd1acde6007ad0dffc085be17accab Signed-off-by: Dong Yuan --- src/include/ceph_features.h | 2 ++ src/os/ObjectStore.h | 14 ++++++++++---- src/osd/ECBackend.cc | 1 + src/osd/PGBackend.h | 2 ++ src/osd/ReplicatedBackend.cc | 9 ++++++--- src/osd/ReplicatedPG.cc | 1 + src/osd/ReplicatedPG.h | 5 +++++ 7 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/include/ceph_features.h b/src/include/ceph_features.h index a723b97dca48e..0812911455227 100644 --- a/src/include/ceph_features.h +++ b/src/include/ceph_features.h @@ -57,6 +57,7 @@ #define CEPH_FEATURE_OSD_FADVISE_FLAGS (1ULL<<46) #define CEPH_FEATURE_OSD_REPOP (1ULL<<46) /* overlap with fadvise */ #define CEPH_FEATURE_OSD_OBJECT_DIGEST (1ULL<<46) /* overlap with fadvise */ +#define CEPH_FEATURE_OSD_TRANSACTION_MAY_LAYOUT (1ULL<<46) /* overlap w/ fadvise */ #define CEPH_FEATURE_MDS_QUOTA (1ULL<<47) #define CEPH_FEATURE_RESERVED2 (1ULL<<61) /* slow down, we are almost out... */ @@ -139,6 +140,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) { CEPH_FEATURE_OSD_FADVISE_FLAGS | \ CEPH_FEATURE_OSD_REPOP | \ CEPH_FEATURE_OSD_OBJECT_DIGEST | \ + CEPH_FEATURE_OSD_TRANSACTION_MAY_LAYOUT | \ CEPH_FEATURE_MDS_QUOTA | \ 0ULL) diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index f7c1970c7d326..dde987431cd0a 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -507,9 +507,15 @@ public: void set_fadvise_flag(uint32_t flag) { data.fadvise_flags = data.fadvise_flags | flag; } - uint32_t get_fadvise_flags() { return data.fadvise_flags; } + void set_use_tbl(bool value) { + use_tbl = value; + } + bool get_use_tbl() { + return use_tbl; + } + void swap(Transaction& other) { std::swap(data, other.data); std::swap(on_applied, other.on_applied); @@ -1506,13 +1512,13 @@ public: // etc. Transaction() : osr(NULL), - use_tbl(true), + use_tbl(false), coll_id(0), object_id(0) { } Transaction(bufferlist::iterator &dp) : osr(NULL), - use_tbl(true), + use_tbl(false), coll_id(0), object_id(0) { decode(dp); @@ -1520,7 +1526,7 @@ public: Transaction(bufferlist &nbl) : osr(NULL), - use_tbl(true), + use_tbl(false), coll_id(0), object_id(0) { bufferlist::iterator dp = nbl.begin(); diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index a984887b1837c..ca39c20ae95f5 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -1516,6 +1516,7 @@ void ECBackend::start_write(Op *op) { i != get_parent()->get_actingbackfill_shards().end(); ++i) { trans[i->shard]; + trans[i->shard].set_use_tbl(parent->transaction_use_tbl()); } op->t->generate_transactions( op->unstable_hash_infos, diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index 3a99c53832a39..2b2102a1a605a 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -206,6 +206,8 @@ virtual uint64_t min_peer_features() const = 0; + virtual bool transaction_use_tbl() = 0; + virtual void send_message_osd_cluster( int peer, Message *m, epoch_t from_epoch) = 0; virtual void send_message_osd_cluster( diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 13e0852091255..3a76a65e458d7 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -313,9 +313,11 @@ class RPGTransaction : public PGBackend::PGTransaction { return coll; } public: - RPGTransaction(coll_t coll, coll_t temp_coll) + RPGTransaction(coll_t coll, coll_t temp_coll, bool use_tbl) : coll(coll), temp_coll(temp_coll), t(new ObjectStore::Transaction), written(0) - {} + { + t->set_use_tbl(use_tbl); + } /// Yields ownership of contained transaction ObjectStore::Transaction *get_transaction() { @@ -489,7 +491,7 @@ public: PGBackend::PGTransaction *ReplicatedBackend::get_transaction() { - return new RPGTransaction(coll, get_temp_coll()); + return new RPGTransaction(coll, get_temp_coll(), parent->transaction_use_tbl()); } class C_OSD_OnOpCommit : public Context { @@ -570,6 +572,7 @@ void ReplicatedBackend::submit_transaction( op_t); ObjectStore::Transaction local_t; + local_t.set_use_tbl(op_t->get_use_tbl()); if (t->get_temp_added().size()) { get_temp_coll(&local_t); add_temp_objs(t->get_temp_added()); diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 485e6c1a4bee9..e897d6c5922a3 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -8222,6 +8222,7 @@ void ReplicatedBackend::sub_op_modify_impl(OpRequestRef op) bufferlist::iterator p = m->get_data().begin(); ::decode(rm->opt, p); + rm->localt.set_use_tbl(rm->opt.get_use_tbl()); if (m->new_temp_oid != hobject_t()) { dout(20) << __func__ << " start tracking temp " << m->new_temp_oid << dendl; diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 687455826b3ac..53480e0271b91 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -418,6 +418,11 @@ public: return get_min_peer_features(); } + bool transaction_use_tbl() { + uint64_t min_features = get_min_peer_features(); + return !(min_features & CEPH_FEATURE_OSD_TRANSACTION_MAY_LAYOUT); + } + void send_message_osd_cluster( int peer, Message *m, epoch_t from_epoch); void send_message_osd_cluster( -- 2.39.5