]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs/DataScan: create all ancestors during scan_inodes
authorPatrick Donnelly <pdonnell@ibm.com>
Tue, 28 Jan 2025 16:24:18 +0000 (11:24 -0500)
committerPatrick Donnelly <pdonnell@ibm.com>
Thu, 30 Jan 2025 04:19:53 +0000 (23:19 -0500)
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 <pdonnell@ibm.com>
src/tools/cephfs/DataScan.cc

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