Commit cbab28f4 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: remove xchk_parent_count_parent_dentries

This helper is now trivial, so get rid of it.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 6bb9209c
...@@ -63,30 +63,6 @@ xchk_parent_actor( ...@@ -63,30 +63,6 @@ xchk_parent_actor(
return 0; return 0;
} }
/* Count the number of dentries in the parent dir that point to this inode. */
STATIC int
xchk_parent_count_parent_dentries(
struct xfs_scrub *sc,
struct xfs_inode *parent,
xfs_nlink_t *nlink)
{
struct xchk_parent_ctx spc = {
.sc = sc,
.nlink = 0,
};
uint lock_mode;
int error = 0;
lock_mode = xfs_ilock_data_map_shared(parent);
error = xchk_dir_walk(sc, parent, xchk_parent_actor, &spc);
xfs_iunlock(parent, lock_mode);
if (error)
return error;
*nlink = spc.nlink;
return error;
}
/* /*
* Given the inode number of the alleged parent of the inode being * Given the inode number of the alleged parent of the inode being
* scrubbed, try to validate that the parent has exactly one directory * scrubbed, try to validate that the parent has exactly one directory
...@@ -98,10 +74,14 @@ xchk_parent_validate( ...@@ -98,10 +74,14 @@ xchk_parent_validate(
xfs_ino_t dnum, xfs_ino_t dnum,
bool *try_again) bool *try_again)
{ {
struct xchk_parent_ctx spc = {
.sc = sc,
.nlink = 0,
};
struct xfs_mount *mp = sc->mp; struct xfs_mount *mp = sc->mp;
struct xfs_inode *dp = NULL; struct xfs_inode *dp = NULL;
xfs_nlink_t expected_nlink; xfs_nlink_t expected_nlink;
xfs_nlink_t nlink; uint lock_mode;
int error = 0; int error = 0;
*try_again = false; *try_again = false;
...@@ -156,11 +136,13 @@ xchk_parent_validate( ...@@ -156,11 +136,13 @@ xchk_parent_validate(
* the child inodes. * the child inodes.
*/ */
if (xfs_ilock_nowait(dp, XFS_IOLOCK_SHARED)) { if (xfs_ilock_nowait(dp, XFS_IOLOCK_SHARED)) {
error = xchk_parent_count_parent_dentries(sc, dp, &nlink); lock_mode = xfs_ilock_data_map_shared(dp);
error = xchk_dir_walk(sc, dp, xchk_parent_actor, &spc);
xfs_iunlock(dp, lock_mode);
if (!xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, if (!xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0,
&error)) &error))
goto out_unlock; goto out_unlock;
if (nlink != expected_nlink) if (spc.nlink != expected_nlink)
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0); xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0);
goto out_unlock; goto out_unlock;
} }
...@@ -178,7 +160,9 @@ xchk_parent_validate( ...@@ -178,7 +160,9 @@ xchk_parent_validate(
goto out_rele; goto out_rele;
/* Go looking for our dentry. */ /* Go looking for our dentry. */
error = xchk_parent_count_parent_dentries(sc, dp, &nlink); lock_mode = xfs_ilock_data_map_shared(dp);
error = xchk_dir_walk(sc, dp, xchk_parent_actor, &spc);
xfs_iunlock(dp, lock_mode);
if (!xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, &error)) if (!xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, &error))
goto out_unlock; goto out_unlock;
...@@ -213,7 +197,7 @@ xchk_parent_validate( ...@@ -213,7 +197,7 @@ xchk_parent_validate(
* '..' didn't change, so check that there was only one entry * '..' didn't change, so check that there was only one entry
* for us in the parent. * for us in the parent.
*/ */
if (nlink != expected_nlink) if (spc.nlink != expected_nlink)
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0); xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0);
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment