From: Kefu Chai Date: Sat, 24 Aug 2019 01:55:22 +0000 (+0800) Subject: crimson: always use Collection::get_cid() X-Git-Tag: v15.1.0~1751^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=da7aa4c5e2fc2722dc9ccf02ac90bb164ddf5470;p=ceph.git crimson: always use Collection::get_cid() prepare for the futurized Collection, which will be an abstract interface allowing us to talk to BlueStore with one of its concrete subclass. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/os/cyan_collection.h b/src/crimson/os/cyan_collection.h index 949003158795..1bab93fd71d0 100644 --- a/src/crimson/os/cyan_collection.h +++ b/src/crimson/os/cyan_collection.h @@ -29,7 +29,6 @@ struct Collection : public boost::intrusive_ref_counter< boost::thread_unsafe_counter> { using ObjectRef = boost::intrusive_ptr; - const coll_t cid; int bits = 0; // always use bufferlist object for testing bool use_page_set = false; @@ -52,6 +51,8 @@ struct Collection : public boost::intrusive_ref_counter< void encode(bufferlist& bl) const; void decode(bufferlist::const_iterator& p); +private: + const coll_t cid; }; using CollectionRef = boost::intrusive_ptr; diff --git a/src/crimson/os/cyan_store.cc b/src/crimson/os/cyan_store.cc index b69bcd216716..1afd1a90b5a1 100644 --- a/src/crimson/os/cyan_store.cc +++ b/src/crimson/os/cyan_store.cc @@ -131,7 +131,7 @@ CyanStore::list_objects(CollectionRef c, uint64_t limit) const { logger().debug("{} {} {} {} {}", - __func__, c->cid, start, end, limit); + __func__, c->get_cid(), start, end, limit); std::vector objects; objects.reserve(limit); ghobject_t next = ghobject_t::get_max(); @@ -177,9 +177,10 @@ seastar::future CyanStore::read(CollectionRef c, uint32_t op_flags) { logger().debug("{} {} {} {}~{}", - __func__, c->cid, oid, offset, len); + __func__, c->get_cid(), oid, offset, len); if (!c->exists) { - throw std::runtime_error(fmt::format("collection does not exist: {}", c->cid)); + throw std::runtime_error(fmt::format("collection does not exist: {}", + c->get_cid())); } ObjectRef o = c->get_object(oid); if (!o) { @@ -204,7 +205,7 @@ seastar::future CyanStore::get_attr(CollectionRef c, std::string_view name) const { logger().debug("{} {} {}", - __func__, c->cid, oid); + __func__, c->get_cid(), oid); auto o = c->get_object(oid); if (!o) { return seastar::make_exception_future( @@ -222,7 +223,7 @@ seastar::future CyanStore::get_attrs(CollectionRef c, const ghobject_t& oid) { logger().debug("{} {} {}", - __func__, c->cid, oid); + __func__, c->get_cid(), oid); auto o = c->get_object(oid); if (!o) { throw std::runtime_error(fmt::format("object does not exist: {}", oid)); @@ -236,7 +237,7 @@ CyanStore::omap_get_values(CollectionRef c, const omap_keys_t& keys) { logger().debug("{} {} {}", - __func__, c->cid, oid); + __func__, c->get_cid(), oid); auto o = c->get_object(oid); if (!o) { throw std::runtime_error(fmt::format("object does not exist: {}", oid)); @@ -258,7 +259,7 @@ CyanStore::omap_get_values( ) { logger().debug( "{} {} {}", - __func__, c->cid, oid); + __func__, c->get_cid(), oid); auto o = c->get_object(oid); if (!o) { throw std::runtime_error(fmt::format("object does not exist: {}", oid)); diff --git a/src/crimson/osd/osd_meta.cc b/src/crimson/osd/osd_meta.cc index f8a270a833c5..8b449117d2dd 100644 --- a/src/crimson/osd/osd_meta.cc +++ b/src/crimson/osd/osd_meta.cc @@ -8,13 +8,13 @@ void OSDMeta::create(ceph::os::Transaction& t) { - t.create_collection(coll->cid, 0); + t.create_collection(coll->get_cid(), 0); } void OSDMeta::store_map(ceph::os::Transaction& t, epoch_t e, const bufferlist& m) { - t.write(coll->cid, osdmap_oid(e), 0, m.length(), m); + t.write(coll->get_cid(), osdmap_oid(e), 0, m.length(), m); } seastar::future OSDMeta::load_map(epoch_t e) @@ -29,7 +29,7 @@ void OSDMeta::store_superblock(ceph::os::Transaction& t, { bufferlist bl; encode(superblock, bl); - t.write(coll->cid, superblock_oid(), 0, bl.length(), bl); + t.write(coll->get_cid(), superblock_oid(), 0, bl.length(), bl); } seastar::future OSDMeta::load_superblock() diff --git a/src/crimson/osd/pg_backend.cc b/src/crimson/osd/pg_backend.cc index 9fe24d4e63c9..89b9f3f49dc0 100644 --- a/src/crimson/osd/pg_backend.cc +++ b/src/crimson/osd/pg_backend.cc @@ -187,7 +187,7 @@ PGBackend::mutate_object( ceph::bufferlist osv; encode(os->oi, osv, 0); // TODO: get_osdmap()->get_features(CEPH_ENTITY_TYPE_OSD, nullptr)); - txn.setattr(coll->cid, ghobject_t{os->oi.soid}, OI_ATTR, osv); + txn.setattr(coll->get_cid(), ghobject_t{os->oi.soid}, OI_ATTR, osv); } } else { // reset cached ObjectState without enforcing eviction @@ -271,7 +271,7 @@ bool PGBackend::maybe_create_new_object( os.exists = true; os.oi.new_object(); - txn.touch(coll->cid, ghobject_t{os.oi.soid}); + txn.touch(coll->get_cid(), ghobject_t{os.oi.soid}); // TODO: delta_stats.num_objects++ return false; } else if (os.oi.is_whiteout()) { @@ -308,7 +308,8 @@ seastar::future<> PGBackend::write( } else if (op.extent.truncate_seq > seq) { // write arrives before trimtrunc if (os.exists && !os.oi.is_whiteout()) { - txn.truncate(coll->cid, ghobject_t{os.oi.soid}, op.extent.truncate_size); + txn.truncate(coll->get_cid(), + ghobject_t{os.oi.soid}, op.extent.truncate_size); } os.oi.truncate_seq = op.extent.truncate_seq; os.oi.truncate_size = op.extent.truncate_size; @@ -316,12 +317,12 @@ seastar::future<> PGBackend::write( maybe_create_new_object(os, txn); if (length == 0) { if (offset > os.oi.size) { - txn.truncate(coll->cid, ghobject_t{os.oi.soid}, op.extent.offset); + txn.truncate(coll->get_cid(), ghobject_t{os.oi.soid}, op.extent.offset); } else { txn.nop(); } } else { - txn.write(coll->cid, ghobject_t{os.oi.soid}, + txn.write(coll->get_cid(), ghobject_t{os.oi.soid}, offset, length, std::move(buf), op.flags); } return seastar::now(); @@ -339,10 +340,10 @@ seastar::future<> PGBackend::writefull( const bool existing = maybe_create_new_object(os, txn); if (existing && op.extent.length < os.oi.size) { - txn.truncate(coll->cid, ghobject_t{os.oi.soid}, op.extent.length); + txn.truncate(coll->get_cid(), ghobject_t{os.oi.soid}, op.extent.length); } if (op.extent.length) { - txn.write(coll->cid, ghobject_t{os.oi.soid}, 0, op.extent.length, + txn.write(coll->get_cid(), ghobject_t{os.oi.soid}, 0, op.extent.length, osd_op.indata, op.flags); os.oi.size = op.extent.length; } @@ -353,7 +354,8 @@ seastar::future<> PGBackend::remove(ObjectState& os, ceph::os::Transaction& txn) { // todo: snapset - txn.remove(coll->cid, ghobject_t{os.oi.soid, ghobject_t::NO_GEN, shard}); + txn.remove(coll->get_cid(), + ghobject_t{os.oi.soid, ghobject_t::NO_GEN, shard}); os.oi.size = 0; os.oi.new_object(); os.exists = false; @@ -421,7 +423,7 @@ seastar::future<> PGBackend::setxattr( bp.copy(osd_op.op.xattr.value_len, val); } - txn.setattr(coll->cid, ghobject_t{os.oi.soid}, name, val); + txn.setattr(coll->get_cid(), ghobject_t{os.oi.soid}, name, val); return seastar::now(); //ctx->delta_stats.num_wr++; } diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h index 18babff9fe22..50a0ed42beda 100644 --- a/src/osd/PGLog.h +++ b/src/osd/PGLog.h @@ -1701,7 +1701,7 @@ public: const DoutPrefixProvider *dpp = nullptr ) { ldpp_dout(dpp, 20) << "read_log_and_missing coll " - << ch->cid + << ch->get_cid() << " " << pgmeta_oid << dendl; return (new FuturizedStoreLogReader{ store, ch, info, log, missing, pgmeta_oid, dpp})->start();