]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: always use Collection::get_cid()
authorKefu Chai <kchai@redhat.com>
Sat, 24 Aug 2019 01:55:22 +0000 (09:55 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 27 Aug 2019 16:03:53 +0000 (00:03 +0800)
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 <kchai@redhat.com>
src/crimson/os/cyan_collection.h
src/crimson/os/cyan_store.cc
src/crimson/osd/osd_meta.cc
src/crimson/osd/pg_backend.cc
src/osd/PGLog.h

index 949003158795d8475cd92412444dcd444f850a95..1bab93fd71d01431d73e0530e1213b60fe7ae922 100644 (file)
@@ -29,7 +29,6 @@ struct Collection : public boost::intrusive_ref_counter<
   boost::thread_unsafe_counter>
 {
   using ObjectRef = boost::intrusive_ptr<Object>;
-  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<Collection>;
index b69bcd2167162831723ccfce94f05d3fe3b045eb..1afd1a90b5a1805d72c1626ad315f8e10086ed08 100644 (file)
@@ -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<ghobject_t> objects;
   objects.reserve(limit);
   ghobject_t next = ghobject_t::get_max();
@@ -177,9 +177,10 @@ seastar::future<ceph::bufferlist> 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<ceph::bufferptr> 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<ceph::bufferptr>(
@@ -222,7 +223,7 @@ seastar::future<CyanStore::attrs_t> 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));
index f8a270a833c50edf3bfab2e0b143eb7942d904da..8b449117d2ddfd4ec7a5e151973eacea32cab2e7 100644 (file)
@@ -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<bufferlist> 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<OSDSuperblock> OSDMeta::load_superblock()
index 9fe24d4e63c974f8429530c272cb581be7279e11..89b9f3f49dc0461832c9fef055ce12dc8accbda7 100644 (file)
@@ -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++;
 }
index 18babff9fe22306159d28b13888ec33231cc1c74..50a0ed42beda30e7c90309a4b03b4b661e027da8 100644 (file)
@@ -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<missing_type>{
       store, ch, info, log, missing, pgmeta_oid, dpp})->start();