[PATCH 3/4] xfs: rename xchk_get_inode -> xchk_iget_for_scrubbing

Darrick J. Wong
2022-12-30T22:45:43Z

Dave Chinner suggested renaming this function to make more obvious what
it does. The function returns an incore inode to callers that want to
scrub a metadata structure that hangs off an inode. If the iget fails
with EINVAL, it will single-step the loading process to distinguish
between actually free inodes or impossible inumbers (ENOENT);
discrepancies between the inobt freemask and the free status in the
inode record (EFSCORRUPTED). Any other negative errno is returned
unchanged.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/scrub/bmap.c | 2 +-
fs/xfs/scrub/common.c | 12 +++++++-----
fs/xfs/scrub/common.h | 2 +-
fs/xfs/scrub/inode.c | 2 +-
4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
index b195bc0e09a4..fe13da54e133 100644
--- a/fs/xfs/scrub/bmap.c
+++ b/fs/xfs/scrub/bmap.c
@@ -34,7 +34,7 @@ xchk_setup_inode_bmap(
if (xchk_need_fshook_drain(sc))
xchk_fshooks_enable(sc, XCHK_FSHOOKS_DRAIN);

- error = xchk_get_inode(sc);
+ error = xchk_iget_for_scrubbing(sc);
if (error)
goto out;

diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
index 70ee293bc58f..90f53f415d99 100644
--- a/fs/xfs/scrub/common.c
+++ b/fs/xfs/scrub/common.c
@@ -807,12 +807,14 @@ xchk_install_handle_inode(
}

/*
- * Given an inode and the scrub control structure, grab either the
- * inode referenced in the control structure or the inode passed in.
- * The inode is not locked.
+ * In preparation to scrub metadata structures that hang off of an inode,
+ * grab either the inode referenced in the scrub control structure or the
+ * inode passed in. If the inumber does not reference an allocated inode
+ * record, the function returns ENOENT to end the scrub early. The inode
+ * is not locked.
*/
int
-xchk_get_inode(
+xchk_iget_for_scrubbing(
struct xfs_scrub *sc)
{
struct xfs_imap imap;
@@ -961,7 +963,7 @@ xchk_setup_inode_contents(
{
int error;

- error = xchk_get_inode(sc);
+ error = xchk_iget_for_scrubbing(sc);
if (error)
return error;

diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h
index 6a7fe2596841..5ef27e6bdac6 100644
--- a/fs/xfs/scrub/common.h
+++ b/fs/xfs/scrub/common.h
@@ -135,7 +135,7 @@ int xchk_count_rmap_ownedby_ag(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
const struct xfs_owner_info *oinfo, xfs_filblks_t *blocks);

int xchk_setup_ag_btree(struct xfs_scrub *sc, bool force_log);
-int xchk_get_inode(struct xfs_scrub *sc);
+int xchk_iget_for_scrubbing(struct xfs_scrub *sc);
int xchk_setup_inode_contents(struct xfs_scrub *sc, unsigned int resblks);
void xchk_buffer_recheck(struct xfs_scrub *sc, struct xfs_buf *bp);

diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c
index 3b272c86d0ad..39ac7cc09fbd 100644
--- a/fs/xfs/scrub/inode.c
+++ b/fs/xfs/scrub/inode.c
@@ -39,7 +39,7 @@ xchk_setup_inode(
* Try to get the inode. If the verifiers fail, we try again
* in raw mode.
*/
- error = xchk_get_inode(sc);
+ error = xchk_iget_for_scrubbing(sc);
switch (error) {
case 0:
break;