From: Sage Weil Date: Thu, 8 Oct 2015 19:34:40 +0000 (-0400) Subject: osd: support new alloc_hint flags X-Git-Tag: v11.0.0~466^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c7b6e456703855e5514fb2de3889e8d91c40b9ba;p=ceph.git osd: support new alloc_hint flags Pass these through to the ObjectStore. Signed-off-by: Sage Weil --- diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index aacf642d546c..516761087859 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -426,7 +426,14 @@ public: __le32 dest_cid; __le32 dest_oid; //OP_CLONE, OP_CLONERANGE __le64 dest_off; //OP_CLONERANGE - __le32 hint_type; //OP_COLL_HINT + union { + struct { + __le32 hint_type; //OP_COLL_HINT + }; + struct { + __le32 alloc_hint_flags; //OP_SETALLOCHINT + }; + }; __le64 expected_object_size; //OP_SETALLOCHINT __le64 expected_write_size; //OP_SETALLOCHINT __le32 split_bits; //OP_SPLIT_COLLECTION2 @@ -1722,7 +1729,8 @@ public: coll_t cid, const ghobject_t &oid, uint64_t expected_object_size, - uint64_t expected_write_size + uint64_t expected_write_size, + uint32_t flags ) { if (use_tbl) { __u32 op = OP_SETALLOCHINT; @@ -1738,6 +1746,7 @@ public: _op->oid = _get_object_id(oid); _op->expected_object_size = expected_object_size; _op->expected_write_size = expected_write_size; + _op->alloc_hint_flags = flags; } data.ops++; } diff --git a/src/os/Transaction.cc b/src/os/Transaction.cc index 60281049634b..68ff6d6a8379 100644 --- a/src/os/Transaction.cc +++ b/src/os/Transaction.cc @@ -506,7 +506,7 @@ void ObjectStore::Transaction::_build_actions_from_tbl() ::decode(expected_object_size, p); ::decode(expected_write_size, p); - set_alloc_hint(cid, oid, expected_object_size, expected_write_size); + set_alloc_hint(cid, oid, expected_object_size, expected_write_size, 0); } break; diff --git a/src/osd/ECTransaction.cc b/src/osd/ECTransaction.cc index 64dd89feac2c..7661ddcd8b9c 100644 --- a/src/osd/ECTransaction.cc +++ b/src/osd/ECTransaction.cc @@ -265,7 +265,7 @@ struct TransGenerator : public boost::static_visitor { i->second.set_alloc_hint( get_coll_ct(i->first, op.oid), ghobject_t(op.oid, ghobject_t::NO_GEN, i->first), - object_size, write_size); + object_size, write_size, op.flags); } } void operator()(const ECTransaction::NoOp &op) {} diff --git a/src/osd/ECTransaction.h b/src/osd/ECTransaction.h index 17be72265cba..236da7600221 100644 --- a/src/osd/ECTransaction.h +++ b/src/osd/ECTransaction.h @@ -79,11 +79,15 @@ public: hobject_t oid; uint64_t expected_object_size; uint64_t expected_write_size; + uint32_t flags; AllocHintOp(const hobject_t &oid, uint64_t expected_object_size, - uint64_t expected_write_size) - : oid(oid), expected_object_size(expected_object_size), - expected_write_size(expected_write_size) {} + uint64_t expected_write_size, + uint32_t flags) + : oid(oid), + expected_object_size(expected_object_size), + expected_write_size(expected_write_size), + flags(flags) {} }; struct NoOp {}; typedef boost::variant< @@ -158,8 +162,10 @@ public: void set_alloc_hint( const hobject_t &hoid, uint64_t expected_object_size, - uint64_t expected_write_size) { - ops.push_back(AllocHintOp(hoid, expected_object_size, expected_write_size)); + uint64_t expected_write_size, + uint32_t flags) { + ops.push_back(AllocHintOp(hoid, expected_object_size, expected_write_size, + flags)); } void append(PGTransaction *_to_append) { diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index f88c1a08af76..8dad866766df 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -400,7 +400,8 @@ struct shard_info_wrapper; virtual void set_alloc_hint( const hobject_t &hoid, uint64_t expected_object_size, - uint64_t expected_write_size + uint64_t expected_write_size, + uint32_t flags ) = 0; /// Optional, not supported on ec-pool diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 1411126e8684..28295cde838d 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -473,10 +473,11 @@ public: void set_alloc_hint( const hobject_t &hoid, uint64_t expected_object_size, - uint64_t expected_write_size + uint64_t expected_write_size, + uint32_t flags ) { t.set_alloc_hint(get_coll(hoid), ghobject_t(hoid), expected_object_size, - expected_write_size); + expected_write_size, flags); } using PGBackend::PGTransaction::append; diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 43ef40ffb998..51fe13112cbc 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4962,7 +4962,8 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) t->touch(soid); } t->set_alloc_hint(soid, op.alloc_hint.expected_object_size, - op.alloc_hint.expected_write_size); + op.alloc_hint.expected_write_size, + op.alloc_hint.flags); ctx->delta_stats.num_wr++; result = 0; } diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 9a5de2e629f3..98b02d271709 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -3588,7 +3588,7 @@ TEST_P(StoreTest, SetAllocHint) { } { ObjectStore::Transaction t; - t.set_alloc_hint(cid, hoid, 4*1024*1024, 1024*4); + t.set_alloc_hint(cid, hoid, 4*1024*1024, 1024*4, 0); r = apply_transaction(store, &osr, std::move(t)); ASSERT_EQ(r, 0); } @@ -3600,7 +3600,7 @@ TEST_P(StoreTest, SetAllocHint) { } { ObjectStore::Transaction t; - t.set_alloc_hint(cid, hoid, 4*1024*1024, 1024*4); + t.set_alloc_hint(cid, hoid, 4*1024*1024, 1024*4, 0); r = apply_transaction(store, &osr, std::move(t)); ASSERT_EQ(r, 0); }