]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix improper offset calculation when repairing. 43731/head
authorIgor Fedotov <ifedotov@suse.com>
Thu, 15 Jul 2021 12:10:14 +0000 (15:10 +0300)
committerIgor Fedotov <ifed@suse.com>
Mon, 8 Nov 2021 21:18:03 +0000 (00:18 +0300)
While repairing misreferenced blobs BlueStore could improperly calculate
an offset within a blob being fixed. This could happen when single
physical extent has been replaced by multiple ones - the following
pextent (if any in the current blob) would be treated with the improper offset within the blob. Offset calculation didn't account for each of that new pextents but the last one only.

Fixes: https://tracker.ceph.com/issues/51682
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit ca4b6675fc3fd2f4cadad58044c97c5bb23d5938)

src/os/bluestore/BlueStore.cc

index 5d50ff5b55bb7c9bef65bbb27dcaf8b45b4fef34..53c44f048cace530c0f79160d212144dfc6f883c 100644 (file)
@@ -8569,7 +8569,9 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
          pext_to_release.reserve(pextents.size());
          // rewriting all valid pextents
          for (auto e = pextents.begin(); e != pextents.end();
-                b_off += e->length, e++) {
+                e++) {
+           auto b_off_cur = b_off;
+           b_off += e->length;
            if (!e->is_valid()) {
              continue;
            }
@@ -8607,7 +8609,8 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
            e = pextents.erase(e);
            e = pextents.insert(e, exts.begin(), exts.end());
            b->get_blob().map_bl(
-             b_off, bl,
+             b_off_cur,
+             bl,
              [&](uint64_t offset, bufferlist& t) {
                int r = bdev->write(offset, t, false);
                ceph_assert(r == 0);