Skip to content

Commit 7d59db1

Browse files
committed
tools/cephfs/DataScan: create all ancestors during scan_inodes
When arbitrary PGs are lost which consequently lose random dirfrag objects, we may need to recover the full ancestry when the immediate parent exists. So, always recover the ancestry and fixup the potential duplicate linkages to a directory during scan_links. Fixes: https://tracker.ceph.com/issues/69692 Signed-off-by: Patrick Donnelly <[email protected]>
1 parent 593a8c5 commit 7d59db1

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/tools/cephfs/DataScan.cc

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,19 +2046,13 @@ int MetadataDriver::inject_with_backtrace(
20462046
}
20472047
}
20482048

2049-
if (!created_dirfrag) {
2050-
// If the parent dirfrag already existed, then stop traversing the
2051-
// backtrace: assume that the other ancestors already exist too. This
2052-
// is an assumption rather than a truth, but it's a convenient way
2053-
// to avoid the risk of creating multiply-linked directories while
2054-
// injecting data. If there are in fact missing ancestors, this
2055-
// should be fixed up using a separate tool scanning the metadata
2056-
// pool.
2057-
break;
2058-
} else {
2059-
// Proceed up the backtrace, creating parents
2060-
ino = parent_ino;
2061-
}
2049+
// N.B.: when the metadata pool has suffered a partial loss (like one PG), then
2050+
// an arbitrary ancestor dirfrag may be missing. We need to traverse up the
2051+
// backtrace ancestry to create those missing dirfrags/links. There is a risk
2052+
// that we create duplicate primary links to a directory this way. scan_links
2053+
// will catch this and pick either a legitimate link (with a version >1) or
2054+
// an arbitrary injected link, removing the others.
2055+
ino = parent_ino;
20622056
}
20632057

20642058
return 0;

0 commit comments

Comments
 (0)