aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-05-17 22:48:13 -0400
committerEric Sandeen <sandeen@sandeen.net>2022-05-17 22:48:13 -0400
commit3bc9ea15c3cc7b4237f87dfa73e59ad55aaedf48 (patch)
tree0cc7ddd402651ab0007178fb14035293107ef7ed
parent9887f0ad7f46135b41ea2ffc124ff9bec95b9d74 (diff)
downloadxfsprogs-dev-3bc9ea15c3cc7b4237f87dfa73e59ad55aaedf48.tar.gz
xfs_scrub: collapse trivial file scrub helpers
Remove all these trivial file scrub helper functions since they make tracing code paths difficult and will become annoying in the patches that follow. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r--scrub/phase3.c33
-rw-r--r--scrub/scrub.c95
-rw-r--r--scrub/scrub.h18
3 files changed, 17 insertions, 129 deletions
diff --git a/scrub/phase3.c b/scrub/phase3.c
index c7ce0ada6f..868f444d59 100644
--- a/scrub/phase3.c
+++ b/scrub/phase3.c
@@ -20,22 +20,6 @@
/* Phase 3: Scan all inodes. */
-/*
- * Run a per-file metadata scanner. We use the ino/gen interface to
- * ensure that the inode we're checking matches what the inode scan
- * told us to look at.
- */
-static int
-scrub_fd(
- struct scrub_ctx *ctx,
- int (*fn)(struct scrub_ctx *ctx, uint64_t ino,
- uint32_t gen, struct action_list *a),
- struct xfs_bulkstat *bs,
- struct action_list *alist)
-{
- return fn(ctx, bs->bs_ino, bs->bs_gen, alist);
-}
-
struct scrub_inode_ctx {
struct ptcounter *icount;
bool aborted;
@@ -84,7 +68,7 @@ scrub_inode(
}
/* Scrub the inode. */
- error = scrub_fd(ctx, scrub_inode_fields, bstat, &alist);
+ error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_INODE, &alist);
if (error)
goto out;
@@ -93,13 +77,13 @@ scrub_inode(
goto out;
/* Scrub all block mappings. */
- error = scrub_fd(ctx, scrub_data_fork, bstat, &alist);
+ error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_BMBTD, &alist);
if (error)
goto out;
- error = scrub_fd(ctx, scrub_attr_fork, bstat, &alist);
+ error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_BMBTA, &alist);
if (error)
goto out;
- error = scrub_fd(ctx, scrub_cow_fork, bstat, &alist);
+ error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_BMBTC, &alist);
if (error)
goto out;
@@ -109,22 +93,21 @@ scrub_inode(
if (S_ISLNK(bstat->bs_mode)) {
/* Check symlink contents. */
- error = scrub_symlink(ctx, bstat->bs_ino, bstat->bs_gen,
- &alist);
+ error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_SYMLINK, &alist);
} else if (S_ISDIR(bstat->bs_mode)) {
/* Check the directory entries. */
- error = scrub_fd(ctx, scrub_dir, bstat, &alist);
+ error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_DIR, &alist);
}
if (error)
goto out;
/* Check all the extended attributes. */
- error = scrub_fd(ctx, scrub_attr, bstat, &alist);
+ error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_XATTR, &alist);
if (error)
goto out;
/* Check parent pointers. */
- error = scrub_fd(ctx, scrub_parent, bstat, &alist);
+ error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_PARENT, &alist);
if (error)
goto out;
diff --git a/scrub/scrub.c b/scrub/scrub.c
index 4ef19656dc..0034f11dd9 100644
--- a/scrub/scrub.c
+++ b/scrub/scrub.c
@@ -446,14 +446,13 @@ scrub_estimate_ag_work(
}
/*
- * Scrub inode metadata. If errors occur, this function will log them and
- * return nonzero.
+ * Scrub file metadata of some sort. If errors occur, this function will log
+ * them and return nonzero.
*/
-static int
-__scrub_file(
+int
+scrub_file(
struct scrub_ctx *ctx,
- uint64_t ino,
- uint32_t gen,
+ const struct xfs_bulkstat *bstat,
unsigned int type,
struct action_list *alist)
{
@@ -464,8 +463,8 @@ __scrub_file(
assert(xfrog_scrubbers[type].type == XFROG_SCRUB_TYPE_INODE);
meta.sm_type = type;
- meta.sm_ino = ino;
- meta.sm_gen = gen;
+ meta.sm_ino = bstat->bs_ino;
+ meta.sm_gen = bstat->bs_gen;
/* Scrub the piece of metadata. */
fix = xfs_check_metadata(ctx, &meta, true);
@@ -477,86 +476,6 @@ __scrub_file(
return scrub_save_repair(ctx, alist, &meta);
}
-int
-scrub_inode_fields(
- struct scrub_ctx *ctx,
- uint64_t ino,
- uint32_t gen,
- struct action_list *alist)
-{
- return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_INODE, alist);
-}
-
-int
-scrub_data_fork(
- struct scrub_ctx *ctx,
- uint64_t ino,
- uint32_t gen,
- struct action_list *alist)
-{
- return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_BMBTD, alist);
-}
-
-int
-scrub_attr_fork(
- struct scrub_ctx *ctx,
- uint64_t ino,
- uint32_t gen,
- struct action_list *alist)
-{
- return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_BMBTA, alist);
-}
-
-int
-scrub_cow_fork(
- struct scrub_ctx *ctx,
- uint64_t ino,
- uint32_t gen,
- struct action_list *alist)
-{
- return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_BMBTC, alist);
-}
-
-int
-scrub_dir(
- struct scrub_ctx *ctx,
- uint64_t ino,
- uint32_t gen,
- struct action_list *alist)
-{
- return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_DIR, alist);
-}
-
-int
-scrub_attr(
- struct scrub_ctx *ctx,
- uint64_t ino,
- uint32_t gen,
- struct action_list *alist)
-{
- return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_XATTR, alist);
-}
-
-int
-scrub_symlink(
- struct scrub_ctx *ctx,
- uint64_t ino,
- uint32_t gen,
- struct action_list *alist)
-{
- return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_SYMLINK, alist);
-}
-
-int
-scrub_parent(
- struct scrub_ctx *ctx,
- uint64_t ino,
- uint32_t gen,
- struct action_list *alist)
-{
- return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_PARENT, alist);
-}
-
/*
* Test the availability of a kernel scrub command. If errors occur (or the
* scrub ioctl is rejected) the errors will be logged and this function will
diff --git a/scrub/scrub.h b/scrub/scrub.h
index 537a2ebe8d..5b5f6b65b0 100644
--- a/scrub/scrub.h
+++ b/scrub/scrub.h
@@ -34,22 +34,8 @@ bool can_scrub_symlink(struct scrub_ctx *ctx);
bool can_scrub_parent(struct scrub_ctx *ctx);
bool xfs_can_repair(struct scrub_ctx *ctx);
-int scrub_inode_fields(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
- struct action_list *alist);
-int scrub_data_fork(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
- struct action_list *alist);
-int scrub_attr_fork(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
- struct action_list *alist);
-int scrub_cow_fork(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
- struct action_list *alist);
-int scrub_dir(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
- struct action_list *alist);
-int scrub_attr(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
- struct action_list *alist);
-int scrub_symlink(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
- struct action_list *alist);
-int scrub_parent(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
- struct action_list *alist);
+int scrub_file(struct scrub_ctx *ctx, const struct xfs_bulkstat *bstat,
+ unsigned int type, struct action_list *alist);
/* Repair parameters are the scrub inputs and retry count. */
struct action_item {