Project

General

Profile

Actions

Bug #81432

closed
ML ML

BlueStore repair: shared blob rebuild keeps only the first pextent and frees in-use extents

Bug #81432: BlueStore repair: shared blob rebuild keeps only the first pextent and frees in-use extents

Added by Ming Lei about 2 months ago. Updated about 1 month ago.

Status:
Resolved
Priority:
Normal
Assignee:
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
Regression:
No
Severity:
2 - major
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Tags (freeform):
Fixed In:
v22.0.0-378-gb5b3a26edd
Released In:
Upkeep Timestamp:
2026-11-03T14:56:18+00:00

Description

Affects: main and released versions since Quincy (introduced by a902d22b6c7, PR 43667 (https://github.com/ceph/ceph/pull/43667); in v17.2.0 through v20.2.0; reproduced on main), default config: any shared blob (clone/snapshot) with two or more valid pextents whose record repair rewrites. Reached by ceph-bluestore-tool repair on a store whose shared blob reference counts don't match the objects.

_fsck_repair_shared_blobs() rebuilds the ref_map of each broken shared blob from the blobs that reference it, but stops after the first valid pextent of each blob:

for (auto& p : b.get_extents()) {
  if (p.is_valid()) {
    it->second.get(p.offset, p.length);
    break;                // only the first valid pextent
  }
}

fsck counts a reference for every valid pextent, so repair writes a record without the other extents, reports success, and the next fsck again finds the references mismatching.

Worse, the record is committed before phase 2 of the shared blob check, which marks the extents listed in each shared blob record as used. In the same repair run the missing extents are reported as leaked and released in the freelist, and statfs is adjusted to match, although the head and the clone still reference them: later allocations can overwrite that data, and the next fsck, reading the same incomplete record, does not report the released extent. Removing the clone or the head then aborts in bluestore_extent_ref_map_t::put() with "put on missing extent (gap)", e.g. in an OSD trimming the snapshot.

gtest StoreTestSpecificAUSize.BluestoreRepairSharedBlobMultiPextent (test.cc): clone an object whose blob has two pextents, add a wrong reference to the shared blob record, repair, check the ref_map and fsck, then remove the clone and the head. The broken record is injected with a BlueStore test hook (inject_broken_shared_blob_key), so there is no live-OSD reproducer. repro.sh runs the gtest (output in repro-output.txt); without the fix:

fsck error:*2 shared blob references aren't matching, at least 2 found
fsck error: actual store_statfs(0x0/0x0/0x0, data 0x5000/0x3000, compress 0x0/0x0/0x0, omap 0x0, meta 0x0) != expected store_statfs(0x0/0x0/0x0, data 0x5000/0x2000, compress 0x0/0x0/0x0, omap 0x0, meta 0x0) for pool 22b
fsck error: leaked extent 0x434000~1000
src/test/objectstore/store_test.cc:11288: Failure
Expected equality of these values:
    Which is: ref_map(0x432000~1000=2,0x434000~1000=2)
    Which is: ref_map(0x432000~1000=2)
src/test/objectstore/store_test.cc:11291: Failure
    Which is: 2
src/os/bluestore/bluestore_types.cc: 263: ceph_abort_msg("put on missing extent (gap)")
*** Caught signal (Aborted) **

The first line is the injected damage. The statfs and leaked-extent errors come from the repair run itself: the in-use extent 0x434000 is released. After repair the ref_map lacks that extent and fsck still finds 2 errors; removing the objects aborts. With the fix the ref_map is restored, fsck is clean and both objects are removed.

Fix (fix.patch, applies to main): reference every valid pextent in the rebuild; the break belongs only in the first pass, which just detects the broken shared blobs. Separately, the stray-record removal in the same function has an empty if (cnt >= max_transactions) {}, so each stray record is removed with its own submit_transaction_sync (performance only).


Files

test.cc (2.99 KB) test.cc Ming Lei, 10/05/2026 02:20 PM
repro.sh (1.48 KB) repro.sh Ming Lei, 10/05/2026 02:20 PM
repro-output.txt (1.8 KB) repro-output.txt Ming Lei, 10/05/2026 02:20 PM
fix.patch (1.92 KB) fix.patch Ming Lei, 10/05/2026 02:20 PM

ML Updated by Ming Lei about 2 months ago Actions #1

  • Status changed from New to Fix Under Review
  • Assignee set to Ming Lei
  • Pull request ID set to 72812

AK Updated by Adam Kupczyk about 1 month ago Actions #2

  • Description updated (diff)

Fixed PR link.

UB Updated by Upkeep Bot about 1 month ago Actions #3

  • Status changed from Fix Under Review to Resolved
  • Merge Commit set to b5b3a26edd50cba1b279e2989dfe0df7e7aa5871
  • Fixed In set to v22.0.0-378-gb5b3a26edd
  • Upkeep Timestamp set to 2026-11-03T14:56:18+00:00
Actions

Also available in: PDF Atom