Skip to content

Commit cbab28f

Browse files
author
Darrick J. Wong
committed
xfs: remove xchk_parent_count_parent_dentries
This helper is now trivial, so get rid of it. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 6bb9209 commit cbab28f

1 file changed

Lines changed: 13 additions & 29 deletions

File tree

fs/xfs/scrub/parent.c

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,6 @@ xchk_parent_actor(
6363
return 0;
6464
}
6565

66-
/* Count the number of dentries in the parent dir that point to this inode. */
67-
STATIC int
68-
xchk_parent_count_parent_dentries(
69-
struct xfs_scrub *sc,
70-
struct xfs_inode *parent,
71-
xfs_nlink_t *nlink)
72-
{
73-
struct xchk_parent_ctx spc = {
74-
.sc = sc,
75-
.nlink = 0,
76-
};
77-
uint lock_mode;
78-
int error = 0;
79-
80-
lock_mode = xfs_ilock_data_map_shared(parent);
81-
error = xchk_dir_walk(sc, parent, xchk_parent_actor, &spc);
82-
xfs_iunlock(parent, lock_mode);
83-
if (error)
84-
return error;
85-
86-
*nlink = spc.nlink;
87-
return error;
88-
}
89-
9066
/*
9167
* Given the inode number of the alleged parent of the inode being
9268
* scrubbed, try to validate that the parent has exactly one directory
@@ -98,10 +74,14 @@ xchk_parent_validate(
9874
xfs_ino_t dnum,
9975
bool *try_again)
10076
{
77+
struct xchk_parent_ctx spc = {
78+
.sc = sc,
79+
.nlink = 0,
80+
};
10181
struct xfs_mount *mp = sc->mp;
10282
struct xfs_inode *dp = NULL;
10383
xfs_nlink_t expected_nlink;
104-
xfs_nlink_t nlink;
84+
uint lock_mode;
10585
int error = 0;
10686

10787
*try_again = false;
@@ -156,11 +136,13 @@ xchk_parent_validate(
156136
* the child inodes.
157137
*/
158138
if (xfs_ilock_nowait(dp, XFS_IOLOCK_SHARED)) {
159-
error = xchk_parent_count_parent_dentries(sc, dp, &nlink);
139+
lock_mode = xfs_ilock_data_map_shared(dp);
140+
error = xchk_dir_walk(sc, dp, xchk_parent_actor, &spc);
141+
xfs_iunlock(dp, lock_mode);
160142
if (!xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0,
161143
&error))
162144
goto out_unlock;
163-
if (nlink != expected_nlink)
145+
if (spc.nlink != expected_nlink)
164146
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0);
165147
goto out_unlock;
166148
}
@@ -178,7 +160,9 @@ xchk_parent_validate(
178160
goto out_rele;
179161

180162
/* Go looking for our dentry. */
181-
error = xchk_parent_count_parent_dentries(sc, dp, &nlink);
163+
lock_mode = xfs_ilock_data_map_shared(dp);
164+
error = xchk_dir_walk(sc, dp, xchk_parent_actor, &spc);
165+
xfs_iunlock(dp, lock_mode);
182166
if (!xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, &error))
183167
goto out_unlock;
184168

@@ -213,7 +197,7 @@ xchk_parent_validate(
213197
* '..' didn't change, so check that there was only one entry
214198
* for us in the parent.
215199
*/
216-
if (nlink != expected_nlink)
200+
if (spc.nlink != expected_nlink)
217201
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0);
218202
return error;
219203

0 commit comments

Comments
 (0)