]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: clamp reads to object size and bring full read trimming 58023/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 1 May 2024 14:06:29 +0000 (14:06 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Thu, 13 Jun 2024 12:37:50 +0000 (15:37 +0300)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
(cherry picked from commit 788c364de79787df5d6d808e423cb36b579f4fa7)

src/crimson/osd/pg_backend.cc

index 143f522bb37510ae4adf3914522b78be35d6e480..fdfdd179575d5de1620bffa04484988d1ff8b859 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)) {