]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: clamp reads to object size and bring full read trimming 57204/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 1 May 2024 14:06:29 +0000 (14:06 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 1 May 2024 14:06:59 +0000 (14:06 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/pg_backend.cc

index ab60cfd12730837037730c8ad34ff26bd1fb4ce3..c420d37d5962c19998d6fd64d3e119489678b124 100644 (file)
@@ -241,14 +241,20 @@ PGBackend::read(const ObjectState& os, OSDOp& osd_op,
       (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::now();
+  } else if (offset + length > size) {
+    length = size - op.extent.offset;
+    if (!length) {
+      // this is the second trimmed_read case
+      return read_errorator::now();
+    }
+  }
   return _read(oi.soid, offset, length, op.flags).safe_then_interruptible_tuple(
     [&delta_stats, &oi, &osd_op](auto&& bl) -> read_errorator::future<> {
     if (!_read_verify_data(oi, bl)) {