]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: refactor PGBackend::read() to pass os and op
authorKefu Chai <kchai@redhat.com>
Fri, 21 Aug 2020 06:27:56 +0000 (14:27 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 24 Aug 2020 09:51:32 +0000 (17:51 +0800)
prepare for the table based op lookup/execution.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/ops_executer.cc
src/crimson/osd/pg_backend.cc
src/crimson/osd/pg_backend.h

index bf7ea33feb912ad15b0596114e46530b3a3fd36a..6547b1530e25f5dca560a87a3b71a1ab815a09e9 100644 (file)
@@ -435,17 +435,7 @@ OpsExecuter::execute_op(OSDOp& osd_op)
     [[fallthrough]];
   case CEPH_OSD_OP_READ:
     return do_read_op([&osd_op] (auto& backend, const auto& os) {
-      return backend.read(os.oi,
-                          osd_op.op.extent.offset,
-                          osd_op.op.extent.length,
-                          osd_op.op.extent.truncate_size,
-                          osd_op.op.extent.truncate_seq,
-                          osd_op.op.flags).safe_then(
-        [&osd_op](ceph::bufferlist&& bl) {
-          osd_op.rval = bl.length();
-          osd_op.outdata = std::move(bl);
-          return osd_op_errorator::now();
-        });
+      return backend.read(os, osd_op);
     });
   case CEPH_OSD_OP_SPARSE_READ:
     return do_read_op([&osd_op] (auto& backend, const auto& os) {
index 38ac951a3e1d850af1f7f4c8e7d33e703d03200c..1bd15a52bf3a5a85a1ee6dc05805b13d983e691e 100644 (file)
@@ -181,39 +181,40 @@ static inline bool _read_verify_data(
   return true;
 }
 
-PGBackend::read_errorator::future<ceph::bufferlist>
-PGBackend::read(const object_info_t& oi,
-                const size_t offset,
-                size_t length,
-                const size_t truncate_size,
-                const uint32_t truncate_seq,
-                const uint32_t flags)
+PGBackend::read_errorator::future<>
+PGBackend::read(const ObjectState& os, OSDOp& osd_op)
 {
+  const auto& oi = os.oi;
+  const ceph_osd_op& op = osd_op.op;
+  const uint64_t offset = op.extent.offset;
+  uint64_t length = op.extent.length;
   logger().trace("read: {} {}~{}", oi.soid, offset, length);
+
   // are we beyond truncate_size?
   size_t size = oi.size;
-  if ((truncate_seq > oi.truncate_seq) &&
-      (truncate_size < offset + length) &&
-      (truncate_size < size)) {
-    size = truncate_size;
+  if ((op.extent.truncate_seq > oi.truncate_seq) &&
+      (op.extent.truncate_size < offset + length) &&
+      (op.extent.truncate_size < size)) {
+    size = op.extent.truncate_size;
+  }
+  if (offset >= size) {
+    // read size was trimmed to zero and it is expected to do nothing,
+    return read_errorator::now();
   }
   if (!length) {
     // read the whole object if length is 0
     length = size;
   }
-  if (offset >= size) {
-    // read size was trimmed to zero and it is expected to do nothing,
-    return read_errorator::make_ready_future<bufferlist>();
-  }
-  return _read(oi.soid, offset, length, flags).safe_then(
-    [&oi](auto&& bl) -> read_errorator::future<ceph::bufferlist> {
-      if (const bool is_fine = _read_verify_data(oi, bl); is_fine) {
-       logger().debug("read: data length: {}", bl.length());
-        return read_errorator::make_ready_future<bufferlist>(std::move(bl));
-      } else {
-        return crimson::ct_error::object_corrupted::make();
-      }
-    });
+  return _read(oi.soid, offset, length, op.flags).safe_then(
+    [&oi, &osd_op](auto&& bl) -> read_errorator::future<> {
+    if (!_read_verify_data(oi, bl)) {
+      return crimson::ct_error::object_corrupted::make();
+    }
+    logger().debug("read: data length: {}", bl.length());
+    osd_op.rval = bl.length();
+    osd_op.outdata = std::move(bl);
+    return read_errorator::now();
+  });
 }
 
 PGBackend::read_errorator::future<>
index 8efb012e5150da6445d0caa194c0566c31797d3a..accfd260db8f89ce104e7b7ea75b17cc218eb12d 100644 (file)
@@ -55,13 +55,9 @@ public:
     std::map<std::string, ceph::bufferptr, std::less<>>;
   using read_errorator = ll_read_errorator::extend<
     crimson::ct_error::object_corrupted>;
-  read_errorator::future<ceph::bufferlist> read(
-    const object_info_t& oi,
-    uint64_t off,
-    uint64_t len,
-    size_t truncate_size,
-    uint32_t truncate_seq,
-    uint32_t flags);
+  read_errorator::future<> read(
+    const ObjectState& os,
+    OSDOp& osd_op);
   read_errorator::future<> sparse_read(
     const ObjectState& os,
     OSDOp& osd_op);