From: Darrick J. Wong Date: Thu, 21 Nov 2024 00:24:40 +0000 (-0800) Subject: xfs_scrub: check rtgroup metadata directory connections X-Git-Tag: v6.13.0~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=816f973a8ff64f1385bd644ee5124d493cadeeda;p=thirdparty%2Fxfsprogs-dev.git xfs_scrub: check rtgroup metadata directory connections Run the rtgroup metapath scrubber during phase 5 to ensure that any rtgroup metadata files are still connected to the metadir tree after we've pruned any bad links. Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- diff --git a/scrub/phase5.c b/scrub/phase5.c index 4d0a76a5..22a22915 100644 --- a/scrub/phase5.c +++ b/scrub/phase5.c @@ -750,6 +750,7 @@ static int queue_metapath_scan( struct workqueue *wq, bool *abortedp, + xfs_rgnumber_t rgno, uint64_t type) { struct fs_scan_item *item; @@ -762,7 +763,7 @@ queue_metapath_scan( str_liberror(ctx, ret, _("setting up metapath scan")); return ret; } - scrub_item_init_metapath(&item->sri, type); + scrub_item_init_metapath(&item->sri, rgno, type); scrub_item_schedule(&item->sri, XFS_SCRUB_TYPE_METAPATH); item->abortedp = abortedp; @@ -785,6 +786,7 @@ run_kernel_metadir_path_scrubbers( const struct xfrog_scrub_descr *sc; uint64_t type; unsigned int nr_threads = scrub_nproc_workqueue(ctx); + xfs_rgnumber_t rgno; bool aborted = false; int ret, ret2; @@ -804,7 +806,7 @@ run_kernel_metadir_path_scrubbers( if (sc->group != XFROG_SCRUB_GROUP_FS) continue; - ret = queue_metapath_scan(&wq, &aborted, type); + ret = queue_metapath_scan(&wq, &aborted, 0, type); if (ret) { str_liberror(ctx, ret, _("queueing metapath scrub work")); @@ -812,6 +814,24 @@ run_kernel_metadir_path_scrubbers( } } + /* Scan all rtgroup metadata files */ + for (rgno = 0; + rgno < ctx->mnt.fsgeom.rgcount && !aborted; + rgno++) { + for (type = 0; type < XFS_SCRUB_METAPATH_NR; type++) { + sc = &xfrog_metapaths[type]; + if (sc->group != XFROG_SCRUB_GROUP_RTGROUP) + continue; + + ret = queue_metapath_scan(&wq, &aborted, rgno, type); + if (ret) { + str_liberror(ctx, ret, + _("queueing metapath scrub work")); + goto wait; + } + } + } + wait: ret2 = -workqueue_terminate(&wq); if (ret2) { diff --git a/scrub/scrub.h b/scrub/scrub.h index bb94a11d..24b5ad62 100644 --- a/scrub/scrub.h +++ b/scrub/scrub.h @@ -118,9 +118,11 @@ scrub_item_init_file(struct scrub_item *sri, const struct xfs_bulkstat *bstat) } static inline void -scrub_item_init_metapath(struct scrub_item *sri, uint64_t metapath) +scrub_item_init_metapath(struct scrub_item *sri, xfs_rgnumber_t rgno, + uint64_t metapath) { memset(sri, 0, sizeof(*sri)); + sri->sri_agno = rgno; sri->sri_ino = metapath; }