Scan metadata directories for correctness during phase 3.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
{
struct xfs_bulkstat *bstat = breq->bulkstat;
struct xfs_bulkstat *bs;
+ unsigned int flags = 0;
int i;
int error;
strerror_r(error, errbuf, DESCR_BUFSZ));
}
+ if (breq->hdr.flags & XFS_BULK_IREQ_METADIR)
+ flags |= XFS_BULK_IREQ_METADIR;
+
/*
* Check each of the stats we got back to make sure we got the inodes
* we asked for.
/* Load the one inode. */
error = -xfrog_bulkstat_single(&ctx->mnt,
- inumbers->xi_startino + i, 0, bs);
+ inumbers->xi_startino + i, flags, bs);
if (error || bs->bs_ino != inumbers->xi_startino + i) {
memset(bs, 0, sizeof(struct xfs_bulkstat));
bs->bs_ino = inumbers->xi_startino + i;
scrub_inode_iter_fn fn;
void *arg;
unsigned int nr_threads;
+ unsigned int flags;
bool aborted;
};
breq = ichunk_to_bulkstat(ichunk);
breq->hdr.icount = LIBFROG_BULKSTAT_CHUNKSIZE;
+ if (si->flags & SCRUB_SCAN_METADIR)
+ breq->hdr.flags |= XFS_BULK_IREQ_METADIR;
*ichunkp = ichunk;
return 0;
scrub_scan_all_inodes(
struct scrub_ctx *ctx,
scrub_inode_iter_fn fn,
+ unsigned int flags,
void *arg)
{
struct scan_inodes si = {
.fn = fn,
+ .flags = flags,
.arg = arg,
.nr_threads = scrub_nproc_workqueue(ctx),
};
typedef int (*scrub_inode_iter_fn)(struct scrub_ctx *ctx,
struct xfs_handle *handle, struct xfs_bulkstat *bs, void *arg);
+/* Return metadata directories too. */
+#define SCRUB_SCAN_METADIR (1 << 0)
+
int scrub_scan_all_inodes(struct scrub_ctx *ctx, scrub_inode_iter_fn fn,
- void *arg);
+ unsigned int flags, void *arg);
int scrub_open_handle(struct xfs_handle *handle);
struct scrub_inode_ctx ictx = { .ctx = ctx };
uint64_t val;
xfs_agnumber_t agno;
+ unsigned int scan_flags = 0;
int err;
err = -ptvar_alloc(scrub_nproc(ctx), sizeof(struct action_list),
goto out_ptvar;
}
+ /* Scan the metadata directory tree too. */
+ if (ctx->mnt.fsgeom.flags & XFS_FSOP_GEOM_FLAGS_METADIR)
+ scan_flags |= SCRUB_SCAN_METADIR;
+
/*
* If we already have ag/fs metadata to repair from previous phases,
* we would rather not try to repair file metadata until we've tried
ictx.always_defer_repairs = true;
}
- err = scrub_scan_all_inodes(ctx, scrub_inode, &ictx);
+ err = scrub_scan_all_inodes(ctx, scrub_inode, scan_flags, &ictx);
if (!err && ictx.aborted)
err = ECANCELED;
if (err)
unsigned int flags = 0;
int error;
+ if (ctx->mnt.fsgeom.flags & XFS_FSOP_GEOM_FLAGS_METADIR)
+ flags |= XFS_BULK_IREQ_METADIR;
+
error = -xfrog_bulkstat_single(&ctx->mnt, ino, flags, &bstat);
if (error == ENOENT) {
/* Directory is gone, mark it clear. */
pthread_mutex_init(&ncs.lock, NULL);
- ret = scrub_scan_all_inodes(ctx, check_inode_names, &ncs);
+ ret = scrub_scan_all_inodes(ctx, check_inode_names, 0, &ncs);
if (ret)
goto out_lock;
if (ncs.aborted) {
}
/* Scan for unlinked files. */
- return scrub_scan_all_inodes(ctx, report_inode_loss, vs);
+ return scrub_scan_all_inodes(ctx, report_inode_loss, 0, vs);
}
/* Schedule a read-verify of a (data block) extent. */