]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: simplify write handling in PG::do_osd_ops.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 10 May 2019 17:51:41 +0000 (13:51 -0400)
committerKefu Chai <kchai@redhat.com>
Sun, 12 May 2019 14:40:35 +0000 (22:40 +0800)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/pg.cc
src/crimson/osd/pg_backend.cc
src/crimson/osd/pg_backend.h

index 81db65b79308bb4a5d8a1de9793222b50b4c2821..087ce896f28745700dd2654ecc64239e300ac21d 100644 (file)
@@ -1015,18 +1015,14 @@ seastar::future<Ref<MOSDOpReply>> PG::do_osd_ops(Ref<MOSDOp> m)
       // TODO: issue requests in parallel if they don't write,
       // with writes being basically a synchronization barrier
       return seastar::do_for_each(std::begin(m->ops), std::end(m->ops),
-                                  [m,&txn,this,os](OSDOp& osd_op) {
-        return do_osd_op(*os, osd_op, txn);
-      }).then([m,&txn,this,os=std::move(os)] {
-        // XXX: the entire lambda can be scheduled conditionally
-        // XXX: I'm not txn.empty() is what we want here
-        return !txn.empty() ? backend->store_object_state(os, *m, txn)
-                            : seastar::now();
+                                  [m,&txn,this,pos=os.get()](OSDOp& osd_op) {
+        return do_osd_op(*pos, osd_op, txn);
+      }).then([&txn,m,this,os=std::move(os)]() mutable {
+        // XXX: the entire lambda could be scheduled conditionally. ::if_then()?
+        return txn.empty() ? seastar::now()
+                           : backend->mutate_object(std::move(os), std::move(txn), *m);
       });
-    }).then([&] {
-      return txn.empty() ? seastar::now()
-                         : backend->submit_transaction(std::move(txn));
-    }).then([=] {
+    }).then([m,this] {
       auto reply = make_message<MOSDOpReply>(m.get(), 0, get_osdmap_epoch(),
                                              0, false);
       reply->add_flags(CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK);
index 79651b78ef8522b6efb101a7ea1805a807e2ac9c..9867d87f1cea398588282d304a1361f43595ae52 100644 (file)
@@ -152,12 +152,12 @@ PGBackend::_load_ss(const hobject_t& oid)
 }
 
 seastar::future<>
-PGBackend::store_object_state(
-  //const hobject_t& oid,
-  const cached_os_t os,
-  const MOSDOp& m,
-  ceph::os::Transaction& txn)
+PGBackend::mutate_object(
+  cached_os_t&& os,
+  ceph::os::Transaction&& txn,
+  const MOSDOp& m)
 {
+  logger().trace("mutate_object: num_ops={}", txn.get_num_ops());
   if (os->exists) {
 #if 0
     os.oi.version = ctx->at_version;
@@ -179,7 +179,7 @@ PGBackend::store_object_state(
     // reset cached ObjectState without enforcing eviction
     os->oi = object_info_t(os->oi.soid);
   }
-  return seastar::now();
+  return store->do_transaction(coll, std::move(txn));
 }
 
 seastar::future<>
@@ -271,9 +271,3 @@ seastar::future<> PGBackend::writefull(
   }
   return seastar::now();
 }
-
-seastar::future<> PGBackend::submit_transaction(ceph::os::Transaction&& txn)
-{
-  logger().trace("submit_transaction: num_ops={}", txn.get_num_ops());
-  return store->do_transaction(coll, std::move(txn));
-}
index ddde848018c9f0a99e559ca0fc6e8028703a85ab..75b5182ab9bb338479b3ae83d1dc5ac430f7f68b 100644 (file)
@@ -33,9 +33,6 @@ public:
                                           ceph::os::CyanStore* store,
                                           const ec_profile_t& ec_profile);
   using cached_os_t = boost::local_shared_ptr<ObjectState>;
-  seastar::future<> store_object_state(const cached_os_t os,
-                                      const MOSDOp& m,
-                                      ceph::os::Transaction& txn);
   seastar::future<cached_os_t> get_object_state(const hobject_t& oid);
   seastar::future<> evict_object_state(const hobject_t& oid);
   seastar::future<bufferlist> read(const object_info_t& oi,
@@ -48,7 +45,10 @@ public:
     ObjectState& os,
     const OSDOp& osd_op,
     ceph::os::Transaction& trans);
-  seastar::future<> submit_transaction(ceph::os::Transaction&& txn);
+  seastar::future<> mutate_object(
+    cached_os_t&& os,
+    ceph::os::Transaction&& txn,
+    const MOSDOp& m);
 
 protected:
   const shard_id_t shard;