xfs: get rid of the ip parameter to xchk_setup_*
PATCH 1/1 xfs: get rid of the ip parameter to xchk_setup_*
From: Darrick J. Wong <[email protected]>
Now that the scrub context stores a pointer to the file that was used to invoke the scrub call, the struct xfs_inode pointer that we passed to all the setup functions is no longer necessary. This is only ever used if the caller wants us to scrub the metadata of the open file.
--- fs/xfs/scrub/alloc.c | 5 ++-- fs/xfs/scrub/attr.c | 5 ++-- fs/xfs/scrub/bmap.c | 5 ++-- fs/xfs/scrub/common.c | 13 ++++------- fs/xfs/scrub/common.h | 53 +++++++++++++++++---------------------------- fs/xfs/scrub/dir.c | 5 ++-- fs/xfs/scrub/fscounters.c | 3 +-- fs/xfs/scrub/ialloc.c | 5 ++-- fs/xfs/scrub/inode.c | 5 ++-- fs/xfs/scrub/parent.c | 5 ++-- fs/xfs/scrub/quota.c | 5 ++-- fs/xfs/scrub/refcount.c | 5 ++-- fs/xfs/scrub/repair.c | 5 ++-- fs/xfs/scrub/repair.h | 6 +++-- fs/xfs/scrub/rmap.c | 5 ++-- fs/xfs/scrub/rtbitmap.c | 5 ++-- fs/xfs/scrub/scrub.c | 11 ++++----- fs/xfs/scrub/scrub.h | 3 +-- fs/xfs/scrub/symlink.c | 5 ++-- 19 files changed, 61 insertions(+), 93 deletions(-)
fs/xfs/scrub/alloc.c +2 -3
@@ -21,10 +21,9 @@*/ int xchk_setup_ag_allocbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, false); +return xchk_setup_ag_btree (sc, false); }/* Free space btree scrubber. */
fs/xfs/scrub/attr.c +2 -3
@@ -69,8 +69,7 @@ xchk_setup_xattr_buf(/* Set us up to scrub an inode's extended attributes. */ int xchk_setup_xattr ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error;
@@ -85,7 +84,7 @@ xchk_setup_xattr(return error; } -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Extended Attributes */
fs/xfs/scrub/bmap.c +2 -3
@@ -26,12 +26,11 @@/* Set us up with an inode's bmap. */ int xchk_setup_inode_bmap ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error; - error =xchk_get_inode (sc, ip); + error =xchk_get_inode (sc);if (error) goto out;
fs/xfs/scrub/common.c +5 -8
@@ -593,8 +593,7 @@ xchk_trans_alloc(/* Set us up with a transaction and an empty context. */ int xchk_setup_fs ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {uint resblks;
@@ -606,7 +605,6 @@ xchk_setup_fs(int xchk_setup_ag_btree (struct xfs_scrub *sc, -struct xfs_inode *ip,bool force_log) {struct xfs_mount *mp = sc->mp;
@@ -624,7 +622,7 @@ xchk_setup_ag_btree(return error; } - error =xchk_setup_fs (sc, ip); + error =xchk_setup_fs (sc);if (error)return error;
@@ -652,11 +650,11 @@ xchk_checkpoint_log(*/ int xchk_get_inode ( -struct xfs_scrub *sc, -struct xfs_inode *ip_in) +struct xfs_scrub *sc) {struct xfs_imap imap;struct xfs_mount *mp = sc->mp; +struct xfs_inode *ip_in =XFS_I (file_inode (sc->filp));struct xfs_inode *ip =NULL ;int error;
@@ -717,12 +715,11 @@ xchk_get_inode(int xchk_setup_inode_contents (struct xfs_scrub *sc, -struct xfs_inode *ip,unsigned int resblks) {int error; - error =xchk_get_inode (sc, ip); + error =xchk_get_inode (sc);if (error)return error;
fs/xfs/scrub/common.h +20 -33
79 lines not on this page · raw message
fs/xfs/scrub/dir.c +2 -3
@@ -22,10 +22,9 @@/* Set us up to scrub directories. */ int xchk_setup_directory ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Directories */
fs/xfs/scrub/fscounters.c +1 -2
@@ -116,8 +116,7 @@ xchk_fscount_warmup(int xchk_setup_fscounters ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {struct xchk_fscounters *fsc;int error;
fs/xfs/scrub/ialloc.c +2 -3
@@ -29,10 +29,9 @@*/ int xchk_setup_ag_iallocbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, sc->flags &XCHK_TRY_HARDER ); +return xchk_setup_ag_btree (sc, sc->flags &XCHK_TRY_HARDER ); }/* Inode btree scrubber. */
fs/xfs/scrub/inode.c +2 -3
@@ -28,8 +28,7 @@*/ int xchk_setup_inode ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error;
@@ -37,7 +36,7 @@ xchk_setup_inode(* Try to get the inode. If the verifiers fail, we try again * in raw mode. */ - error =xchk_get_inode (sc, ip); + error =xchk_get_inode (sc);switch (error) {case 0 :break ;
fs/xfs/scrub/parent.c +2 -3
@@ -20,10 +20,9 @@/* Set us up to scrub parents. */ int xchk_setup_parent ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Parent pointers */
fs/xfs/scrub/quota.c +2 -3
@@ -37,8 +37,7 @@ xchk_quota_to_dqtype(/* Set us up to scrub a quota. */ int xchk_setup_quota ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {xfs_dqtype_t dqtype;int error;
@@ -53,7 +52,7 @@ xchk_setup_quota(mutex_lock (&sc->mp->m_quotainfo->qi_quotaofflock);if (!xfs_this_quota_on (sc->mp, dqtype))return -ENOENT ; - error =xchk_setup_fs (sc, ip); + error =xchk_setup_fs (sc);if (error)return error; sc->ip =xfs_quota_inode (sc->mp, dqtype);
fs/xfs/scrub/refcount.c +2 -3
@@ -19,10 +19,9 @@*/ int xchk_setup_ag_refcountbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, false); +return xchk_setup_ag_btree (sc, false); }/* Reference count btree scrubber. */
fs/xfs/scrub/repair.c +2 -3
@@ -37,19 +37,18 @@*/ int xrep_attempt ( -struct xfs_inode *ip,struct xfs_scrub *sc) {int error =0 ; -trace_xrep_attempt (ip, sc->sm, error); +trace_xrep_attempt (XFS_I (file_inode (sc->filp)), sc->sm, error);xchk_ag_btcur_free (&sc->sa);/* Repair whatever's broken. */ ASSERT (sc->ops->repair); error = sc->ops->repair (sc); -trace_xrep_done (ip, sc->sm, error); +trace_xrep_done (XFS_I (file_inode (sc->filp)), sc->sm, error);switch (error) {case 0 :/*
fs/xfs/scrub/repair.h +3 -3
@@ -17,7 +17,7 @@ static inline int xrep_notsupported(struct xfs_scrub *sc)/* Repair helpers */ -int xrep_attempt (struct xfs_inode *ip,struct xfs_scrub *sc); +int xrep_attempt (struct xfs_scrub *sc);void xrep_failure (struct xfs_mount *mp);int xrep_roll_ag_trans (struct xfs_scrub *sc); bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
@@ -64,8 +64,8 @@ int xrep_agi(struct xfs_scrub *sc);#else -static inline int xrep_attempt ( -struct xfs_inode *ip, +static inline int +xrep_attempt (struct xfs_scrub *sc) {return -EOPNOTSUPP ;
fs/xfs/scrub/rmap.c +2 -3
@@ -21,10 +21,9 @@*/ int xchk_setup_ag_rmapbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, false); +return xchk_setup_ag_btree (sc, false); }/* Reverse-mapping scrubber. */
fs/xfs/scrub/rtbitmap.c +2 -3
@@ -20,12 +20,11 @@/* Set us up with the realtime metadata locked. */ int xchk_setup_rt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error; - error =xchk_setup_fs (sc, ip); + error =xchk_setup_fs (sc);if (error)return error;
fs/xfs/scrub/scrub.c +5 -6
@@ -468,8 +468,7 @@ xfs_scrub_metadata( .agno = NULLAGNUMBER, }, }; -struct xfs_inode *ip =XFS_I (file_inode (filp)); -struct xfs_mount *mp = ip->i_mount; +struct xfs_mount *mp =XFS_I (file_inode (filp))->i_mount;int error =0 ; sc.mp = mp;
@@ -477,7 +476,7 @@ xfs_scrub_metadata(BUILD_BUG_ON (sizeof (meta_scrub_ops) != (sizeof (struct xchk_meta_ops ) *XFS_SCRUB_TYPE_NR )); -trace_xchk_start (ip, sm, error); +trace_xchk_start (XFS_I (file_inode (filp)), sm, error);/* Forbidden if we are shut down or mounted norecovery. */ error = -ESHUTDOWN ;
@@ -507,7 +506,7 @@ xfs_scrub_metadata( }/* Set up for the operation. */ - error = sc.ops->setup (&sc, ip); + error = sc.ops->setup (&sc);if (error) goto out_teardown;
@@ -553,7 +552,7 @@ xfs_scrub_metadata(* If it's broken, userspace wants us to fix it, and we haven't * already tried to fix it, then attempt a repair. */ - error =xrep_attempt (ip, &sc); + error =xrep_attempt (&sc);if (error == -EAGAIN ) {/* * Either the repair function succeeded or it couldn't
@@ -574,7 +573,7 @@ xfs_scrub_metadata( out_teardown: error =xchk_teardown (&sc, error); out: -trace_xchk_done (ip, sm, error); +trace_xchk_done (XFS_I (file_inode (filp)), sm, error);if (error == -EFSCORRUPTED || error == -EFSBADCRC ) { sm->sm_flags |=XFS_SCRUB_OFLAG_CORRUPT ; error =0 ;
fs/xfs/scrub/scrub.h +1 -2
@@ -18,8 +18,7 @@ enum xchk_type {struct xchk_meta_ops {/* Acquire whatever resources are needed for the operation. */ -int (*setup)(struct xfs_scrub *, -struct xfs_inode *); +int (*setup)(struct xfs_scrub *sc);/* Examine metadata for errors. */ int (*scrub)(struct xfs_scrub *);
fs/xfs/scrub/symlink.c +2 -3
@@ -18,15 +18,14 @@/* Set us up to scrub a symbolic link. */ int xchk_setup_symlink ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {/* Allocate the buffer without the inode lock held. */ sc->buf =kvzalloc (XFS_SYMLINK_MAXLEN +1 ,GFP_KERNEL );if (!sc->buf)return -ENOMEM ; -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Symbolic links. */
Quoted 7 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Now that the scrub context stores a pointer to the file that was used to invoke the scrub call, the struct
xfs_inodepointer that we passed to all the setup functions is no longer necessary. This is only ever used if the caller wants us to scrub the metadata of the open file.
The changes made are straightforward.
Quoted 526 lines
Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/scrub/alloc.c | 5 ++-- fs/xfs/scrub/attr.c | 5 ++-- fs/xfs/scrub/bmap.c | 5 ++-- fs/xfs/scrub/common.c | 13 ++++------- fs/xfs/scrub/common.h | 53 +++++++++++++++++---------------------------- fs/xfs/scrub/dir.c | 5 ++-- fs/xfs/scrub/fscounters.c | 3 +-- fs/xfs/scrub/ialloc.c | 5 ++-- fs/xfs/scrub/inode.c | 5 ++-- fs/xfs/scrub/parent.c | 5 ++-- fs/xfs/scrub/quota.c | 5 ++-- fs/xfs/scrub/refcount.c | 5 ++-- fs/xfs/scrub/repair.c | 5 ++-- fs/xfs/scrub/repair.h | 6 +++-- fs/xfs/scrub/rmap.c | 5 ++-- fs/xfs/scrub/rtbitmap.c | 5 ++-- fs/xfs/scrub/scrub.c | 11 ++++----- fs/xfs/scrub/scrub.h | 3 +-- fs/xfs/scrub/symlink.c | 5 ++-- 19 files changed, 61 insertions(+), 93 deletions(-)fs/xfs/scrub/alloc.c +2
-3@@ -21,10 +21,9 @@*/ int xchk_setup_ag_allocbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, false); +return xchk_setup_ag_btree (sc, false); }/* Free space btree scrubber. */ fs/xfs/scrub/attr.c +2
-3@@ -69,8 +69,7 @@ xchk_setup_xattr_buf(/* Set us up to scrub an inode's extended attributes. */ int xchk_setup_xattr ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error;@@ -85,7 +84,7 @@ xchk_setup_xattr(return error; } -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Extended Attributes */ fs/xfs/scrub/bmap.c +2
-3@@ -26,12 +26,11 @@/* Set us up with an inode's bmap. */ int xchk_setup_inode_bmap ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error; - error =xchk_get_inode (sc, ip); + error =xchk_get_inode (sc);if (error) goto out;fs/xfs/scrub/common.c +5
-8@@ -593,8 +593,7 @@ xchk_trans_alloc(/* Set us up with a transaction and an empty context. */ int xchk_setup_fs ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {uint resblks;@@ -606,7 +605,6 @@ xchk_setup_fs(int xchk_setup_ag_btree (struct xfs_scrub *sc, -struct xfs_inode *ip,bool force_log) {struct xfs_mount *mp = sc->mp;@@ -624,7 +622,7 @@ xchk_setup_ag_btree(return error; } - error =xchk_setup_fs (sc, ip); + error =xchk_setup_fs (sc);if (error)return error;@@ -652,11 +650,11 @@ xchk_checkpoint_log(*/ int xchk_get_inode ( -struct xfs_scrub *sc, -struct xfs_inode *ip_in) +struct xfs_scrub *sc) {struct xfs_imap imap;struct xfs_mount *mp = sc->mp; +struct xfs_inode *ip_in =XFS_I (file_inode (sc->filp));struct xfs_inode *ip =NULL ;int error;@@ -717,12 +715,11 @@ xchk_get_inode(int xchk_setup_inode_contents (struct xfs_scrub *sc, -struct xfs_inode *ip,unsigned int resblks) {int error; - error =xchk_get_inode (sc, ip); + error =xchk_get_inode (sc);if (error)return error;fs/xfs/scrub/common.h +20
-33@@ -72,48 +72,37 @@ bool xchk_should_check_xref(struct xfs_scrub *sc, int *error, struct xfs_btree_cur **curpp);/* Setup functions */ -int xchk_setup_fs (struct xfs_scrub *sc,struct xfs_inode *ip); -int xchk_setup_ag_allocbt (struct xfs_scrub *sc, -struct xfs_inode *ip); -int xchk_setup_ag_iallocbt (struct xfs_scrub *sc, -struct xfs_inode *ip); -int xchk_setup_ag_rmapbt (struct xfs_scrub *sc, -struct xfs_inode *ip); -int xchk_setup_ag_refcountbt (struct xfs_scrub *sc, -struct xfs_inode *ip); -int xchk_setup_inode (struct xfs_scrub *sc, -struct xfs_inode *ip); -int xchk_setup_inode_bmap (struct xfs_scrub *sc, -struct xfs_inode *ip); -int xchk_setup_inode_bmap_data (struct xfs_scrub *sc, -struct xfs_inode *ip); -int xchk_setup_directory (struct xfs_scrub *sc, -struct xfs_inode *ip); -int xchk_setup_xattr (struct xfs_scrub *sc, -struct xfs_inode *ip); -int xchk_setup_symlink (struct xfs_scrub *sc, -struct xfs_inode *ip); -int xchk_setup_parent (struct xfs_scrub *sc, -struct xfs_inode *ip); +int xchk_setup_fs (struct xfs_scrub *sc); +int xchk_setup_ag_allocbt (struct xfs_scrub *sc); +int xchk_setup_ag_iallocbt (struct xfs_scrub *sc); +int xchk_setup_ag_rmapbt (struct xfs_scrub *sc); +int xchk_setup_ag_refcountbt (struct xfs_scrub *sc); +int xchk_setup_inode (struct xfs_scrub *sc); +int xchk_setup_inode_bmap (struct xfs_scrub *sc); +int xchk_setup_inode_bmap_data (struct xfs_scrub *sc); +int xchk_setup_directory (struct xfs_scrub *sc); +int xchk_setup_xattr (struct xfs_scrub *sc); +int xchk_setup_symlink (struct xfs_scrub *sc); +int xchk_setup_parent (struct xfs_scrub *sc);#ifdef CONFIG_XFS_RT -int xchk_setup_rt (struct xfs_scrub *sc,struct xfs_inode *ip); +int xchk_setup_rt (struct xfs_scrub *sc);#else static inline int -xchk_setup_rt (struct xfs_scrub *sc,struct xfs_inode *ip) +xchk_setup_rt (struct xfs_scrub *sc) {return -ENOENT ; }#endif #ifdef CONFIG_XFS_QUOTA -int xchk_setup_quota (struct xfs_scrub *sc,struct xfs_inode *ip); +int xchk_setup_quota (struct xfs_scrub *sc);#else static inline int -xchk_setup_quota (struct xfs_scrub *sc,struct xfs_inode *ip) +xchk_setup_quota (struct xfs_scrub *sc) {return -ENOENT ; }#endif -int xchk_setup_fscounters (struct xfs_scrub *sc,struct xfs_inode *ip); +int xchk_setup_fscounters (struct xfs_scrub *sc);void xchk_ag_free (struct xfs_scrub *sc,struct xchk_ag *sa); int xchk_ag_init(struct xfs_scrub *sc, xfs_agnumber_t agno,@@ -126,11 +115,9 @@ void xchk_ag_btcur_init(struct xfs_scrub *sc, struct xchk_ag *sa);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,struct xfs_inode *ip, -bool force_log); -int xchk_get_inode (struct xfs_scrub *sc,struct xfs_inode *ip_in); -int xchk_setup_inode_contents (struct xfs_scrub *sc,struct xfs_inode *ip, -unsigned int resblks); +int xchk_setup_ag_btree (struct xfs_scrub *sc,bool force_log); +int xchk_get_inode (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);/* fs/xfs/scrub/dir.c +2
-3@@ -22,10 +22,9 @@/* Set us up to scrub directories. */ int xchk_setup_directory ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Directories */ fs/xfs/scrub/fscounters.c +1
-2@@ -116,8 +116,7 @@ xchk_fscount_warmup(int xchk_setup_fscounters ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {struct xchk_fscounters *fsc;int error;fs/xfs/scrub/ialloc.c +2
-3@@ -29,10 +29,9 @@*/ int xchk_setup_ag_iallocbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, sc->flags &XCHK_TRY_HARDER ); +return xchk_setup_ag_btree (sc, sc->flags &XCHK_TRY_HARDER ); }/* Inode btree scrubber. */ fs/xfs/scrub/inode.c +2
-3@@ -28,8 +28,7 @@*/ int xchk_setup_inode ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error;@@ -37,7 +36,7 @@ xchk_setup_inode(* Try to get the inode. If the verifiers fail, we try again * in raw mode. */ - error =xchk_get_inode (sc, ip); + error =xchk_get_inode (sc);switch (error) {case 0 :break ;fs/xfs/scrub/parent.c +2
-3@@ -20,10 +20,9 @@/* Set us up to scrub parents. */ int xchk_setup_parent ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Parent pointers */ fs/xfs/scrub/quota.c +2
-3@@ -37,8 +37,7 @@ xchk_quota_to_dqtype(/* Set us up to scrub a quota. */ int xchk_setup_quota ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {xfs_dqtype_t dqtype;int error;@@ -53,7 +52,7 @@ xchk_setup_quota(mutex_lock (&sc->mp->m_quotainfo->qi_quotaofflock);if (!xfs_this_quota_on (sc->mp, dqtype))return -ENOENT ; - error =xchk_setup_fs (sc, ip); + error =xchk_setup_fs (sc);if (error)return error; sc->ip =xfs_quota_inode (sc->mp, dqtype);fs/xfs/scrub/refcount.c +2
-3@@ -19,10 +19,9 @@*/ int xchk_setup_ag_refcountbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, false); +return xchk_setup_ag_btree (sc, false); }/* Reference count btree scrubber. */ fs/xfs/scrub/repair.c +2
-3@@ -37,19 +37,18 @@*/ int xrep_attempt ( -struct xfs_inode *ip,struct xfs_scrub *sc) {int error =0 ; -trace_xrep_attempt (ip, sc->sm, error); +trace_xrep_attempt (XFS_I (file_inode (sc->filp)), sc->sm, error);xchk_ag_btcur_free (&sc->sa);/* Repair whatever's broken. */ ASSERT (sc->ops->repair); error = sc->ops->repair (sc); -trace_xrep_done (ip, sc->sm, error); +trace_xrep_done (XFS_I (file_inode (sc->filp)), sc->sm, error);switch (error) {case 0 :/* fs/xfs/scrub/repair.h +3
-3@@ -17,7 +17,7 @@ static inline int xrep_notsupported(struct xfs_scrub *sc)/* Repair helpers */ -int xrep_attempt (struct xfs_inode *ip,struct xfs_scrub *sc); +int xrep_attempt (struct xfs_scrub *sc);void xrep_failure (struct xfs_mount *mp);int xrep_roll_ag_trans (struct xfs_scrub *sc); bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,@@ -64,8 +64,8 @@ int xrep_agi(struct xfs_scrub *sc);#else -static inline int xrep_attempt ( -struct xfs_inode *ip, +static inline int +xrep_attempt (struct xfs_scrub *sc) {return -EOPNOTSUPP ;fs/xfs/scrub/rmap.c +2
-3@@ -21,10 +21,9 @@*/ int xchk_setup_ag_rmapbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, false); +return xchk_setup_ag_btree (sc, false); }/* Reverse-mapping scrubber. */ fs/xfs/scrub/rtbitmap.c +2
-3@@ -20,12 +20,11 @@/* Set us up with the realtime metadata locked. */ int xchk_setup_rt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error; - error =xchk_setup_fs (sc, ip); + error =xchk_setup_fs (sc);if (error)return error;fs/xfs/scrub/scrub.c +5
-6@@ -468,8 +468,7 @@ xfs_scrub_metadata( .agno = NULLAGNUMBER, }, }; -struct xfs_inode *ip =XFS_I (file_inode (filp)); -struct xfs_mount *mp = ip->i_mount; +struct xfs_mount *mp =XFS_I (file_inode (filp))->i_mount;int error =0 ; sc.mp = mp;@@ -477,7 +476,7 @@ xfs_scrub_metadata(BUILD_BUG_ON (sizeof (meta_scrub_ops) != (sizeof (struct xchk_meta_ops ) *XFS_SCRUB_TYPE_NR )); -trace_xchk_start (ip, sm, error); +trace_xchk_start (XFS_I (file_inode (filp)), sm, error);/* Forbidden if we are shut down or mounted norecovery. */ error = -ESHUTDOWN ;@@ -507,7 +506,7 @@ xfs_scrub_metadata( }/* Set up for the operation. */ - error = sc.ops->setup (&sc, ip); + error = sc.ops->setup (&sc);if (error) goto out_teardown;@@ -553,7 +552,7 @@ xfs_scrub_metadata(* If it's broken, userspace wants us to fix it, and we haven't * already tried to fix it, then attempt a repair. */ - error =xrep_attempt (ip, &sc); + error =xrep_attempt (&sc);if (error == -EAGAIN ) {/* * Either the repair function succeeded or it couldn't @@ -574,7 +573,7 @@ xfs_scrub_metadata( out_teardown: error =xchk_teardown (&sc, error); out: -trace_xchk_done (ip, sm, error); +trace_xchk_done (XFS_I (file_inode (filp)), sm, error);if (error == -EFSCORRUPTED || error == -EFSBADCRC ) { sm->sm_flags |=XFS_SCRUB_OFLAG_CORRUPT ; error =0 ;fs/xfs/scrub/scrub.h +1
-2@@ -18,8 +18,7 @@ enum xchk_type {struct xchk_meta_ops {/* Acquire whatever resources are needed for the operation. */ -int (*setup)(struct xfs_scrub *, -struct xfs_inode *); +int (*setup)(struct xfs_scrub *sc);/* Examine metadata for errors. */ int (*scrub)(struct xfs_scrub *);fs/xfs/scrub/symlink.c +2
-3@@ -18,15 +18,14 @@/* Set us up to scrub a symbolic link. */ int xchk_setup_symlink ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {/* Allocate the buffer without the inode lock held. */ sc->buf =kvzalloc (XFS_SYMLINK_MAXLEN +1 ,GFP_KERNEL );if (!sc->buf)return -ENOMEM ; -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Symbolic links. */
Signature · 1 line
chandan
Quoted 6 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Now that the scrub context stores a pointer to the file that was used to invoke the scrub call, the struct
xfs_inodepointer that we passed to all the setup functions is no longer necessary. This is only ever used if the caller wants us to scrub the metadata of the open file.
Even before we had the xfs_inode in struct xfs_scrub, so why detour through struct file?
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Now that the scrub context stores a pointer to the file that was used to invoke the scrub call, the struct
xfs_inodepointer that we passed to all the setup functions is no longer necessary. This is only ever used if the caller wants us to scrub the metadata of the open file.Even before we had the
xfs_inodein structxfs_scrub, so why detour through struct file?
xfs_scrub.fil[ep] is the file corresponding to the fd that userspace used to call scrub.
xfs_scrub.ip is the file that we're actively checking, if applicable. This can be a different file than filp if we're checking file-based metadata such as the rt bitmap and summary files; or if the caller is doing scrub-by-handle for a non-regular file (e.g. open the root directory and pass in the ino/gen of a symlink file to check that the symlink is ok).
Let me respin this with added struct commentary in scrub.h.
--D
PATCH v2 1/1 xfs: get rid of the ip parameter to xchk_setup_*
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Now that the scrub context stores a pointer to the file that was used to invoke the scrub call, the struct xfs_inode pointer that we passed to all the setup functions is no longer necessary. This is only ever used if the caller wants us to scrub the metadata of the open file.
---
v2: rebase off of filp -> file name change in previous patch
--- fs/xfs/scrub/alloc.c | 5 ++-- fs/xfs/scrub/attr.c | 5 ++-- fs/xfs/scrub/bmap.c | 5 ++-- fs/xfs/scrub/common.c | 13 ++++------- fs/xfs/scrub/common.h | 53 +++++++++++++++++---------------------------- fs/xfs/scrub/dir.c | 5 ++-- fs/xfs/scrub/fscounters.c | 3 +-- fs/xfs/scrub/ialloc.c | 5 ++-- fs/xfs/scrub/inode.c | 5 ++-- fs/xfs/scrub/parent.c | 5 ++-- fs/xfs/scrub/quota.c | 5 ++-- fs/xfs/scrub/refcount.c | 5 ++-- fs/xfs/scrub/repair.c | 5 ++-- fs/xfs/scrub/repair.h | 6 +++-- fs/xfs/scrub/rmap.c | 5 ++-- fs/xfs/scrub/rtbitmap.c | 5 ++-- fs/xfs/scrub/scrub.c | 11 ++++----- fs/xfs/scrub/scrub.h | 3 +-- fs/xfs/scrub/symlink.c | 5 ++-- 19 files changed, 61 insertions(+), 93 deletions(-)
fs/xfs/scrub/alloc.c +2 -3
@@ -21,10 +21,9 @@*/ int xchk_setup_ag_allocbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, false); +return xchk_setup_ag_btree (sc, false); }/* Free space btree scrubber. */
fs/xfs/scrub/attr.c +2 -3
@@ -69,8 +69,7 @@ xchk_setup_xattr_buf(/* Set us up to scrub an inode's extended attributes. */ int xchk_setup_xattr ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error;
@@ -85,7 +84,7 @@ xchk_setup_xattr(return error; } -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Extended Attributes */
fs/xfs/scrub/bmap.c +2 -3
@@ -26,12 +26,11 @@/* Set us up with an inode's bmap. */ int xchk_setup_inode_bmap ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error; - error =xchk_get_inode (sc, ip); + error =xchk_get_inode (sc);if (error) goto out;
fs/xfs/scrub/common.c +5 -8
@@ -593,8 +593,7 @@ xchk_trans_alloc(/* Set us up with a transaction and an empty context. */ int xchk_setup_fs ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {uint resblks;
@@ -606,7 +605,6 @@ xchk_setup_fs(int xchk_setup_ag_btree (struct xfs_scrub *sc, -struct xfs_inode *ip,bool force_log) {struct xfs_mount *mp = sc->mp;
@@ -624,7 +622,7 @@ xchk_setup_ag_btree(return error; } - error =xchk_setup_fs (sc, ip); + error =xchk_setup_fs (sc);if (error)return error;
@@ -652,11 +650,11 @@ xchk_checkpoint_log(*/ int xchk_get_inode ( -struct xfs_scrub *sc, -struct xfs_inode *ip_in) +struct xfs_scrub *sc) {struct xfs_imap imap;struct xfs_mount *mp = sc->mp; +struct xfs_inode *ip_in =XFS_I (file_inode (sc->file));struct xfs_inode *ip =NULL ;int error;
@@ -717,12 +715,11 @@ xchk_get_inode(int xchk_setup_inode_contents (struct xfs_scrub *sc, -struct xfs_inode *ip,unsigned int resblks) {int error; - error =xchk_get_inode (sc, ip); + error =xchk_get_inode (sc);if (error)return error;
fs/xfs/scrub/common.h +20 -33
79 lines not on this page · raw message
fs/xfs/scrub/dir.c +2 -3
@@ -22,10 +22,9 @@/* Set us up to scrub directories. */ int xchk_setup_directory ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Directories */
fs/xfs/scrub/fscounters.c +1 -2
@@ -116,8 +116,7 @@ xchk_fscount_warmup(int xchk_setup_fscounters ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {struct xchk_fscounters *fsc;int error;
fs/xfs/scrub/ialloc.c +2 -3
@@ -29,10 +29,9 @@*/ int xchk_setup_ag_iallocbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, sc->flags &XCHK_TRY_HARDER ); +return xchk_setup_ag_btree (sc, sc->flags &XCHK_TRY_HARDER ); }/* Inode btree scrubber. */
fs/xfs/scrub/inode.c +2 -3
@@ -28,8 +28,7 @@*/ int xchk_setup_inode ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error;
@@ -37,7 +36,7 @@ xchk_setup_inode(* Try to get the inode. If the verifiers fail, we try again * in raw mode. */ - error =xchk_get_inode (sc, ip); + error =xchk_get_inode (sc);switch (error) {case 0 :break ;
fs/xfs/scrub/parent.c +2 -3
@@ -20,10 +20,9 @@/* Set us up to scrub parents. */ int xchk_setup_parent ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Parent pointers */
fs/xfs/scrub/quota.c +2 -3
@@ -37,8 +37,7 @@ xchk_quota_to_dqtype(/* Set us up to scrub a quota. */ int xchk_setup_quota ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {xfs_dqtype_t dqtype;int error;
@@ -53,7 +52,7 @@ xchk_setup_quota(mutex_lock (&sc->mp->m_quotainfo->qi_quotaofflock);if (!xfs_this_quota_on (sc->mp, dqtype))return -ENOENT ; - error =xchk_setup_fs (sc, ip); + error =xchk_setup_fs (sc);if (error)return error; sc->ip =xfs_quota_inode (sc->mp, dqtype);
fs/xfs/scrub/refcount.c +2 -3
@@ -19,10 +19,9 @@*/ int xchk_setup_ag_refcountbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, false); +return xchk_setup_ag_btree (sc, false); }/* Reference count btree scrubber. */
fs/xfs/scrub/repair.c +2 -3
@@ -37,19 +37,18 @@*/ int xrep_attempt ( -struct xfs_inode *ip,struct xfs_scrub *sc) {int error =0 ; -trace_xrep_attempt (ip, sc->sm, error); +trace_xrep_attempt (XFS_I (file_inode (sc->file)), sc->sm, error);xchk_ag_btcur_free (&sc->sa);/* Repair whatever's broken. */ ASSERT (sc->ops->repair); error = sc->ops->repair (sc); -trace_xrep_done (ip, sc->sm, error); +trace_xrep_done (XFS_I (file_inode (sc->file)), sc->sm, error);switch (error) {case 0 :/*
fs/xfs/scrub/repair.h +3 -3
@@ -17,7 +17,7 @@ static inline int xrep_notsupported(struct xfs_scrub *sc)/* Repair helpers */ -int xrep_attempt (struct xfs_inode *ip,struct xfs_scrub *sc); +int xrep_attempt (struct xfs_scrub *sc);void xrep_failure (struct xfs_mount *mp);int xrep_roll_ag_trans (struct xfs_scrub *sc); bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
@@ -64,8 +64,8 @@ int xrep_agi(struct xfs_scrub *sc);#else -static inline int xrep_attempt ( -struct xfs_inode *ip, +static inline int +xrep_attempt (struct xfs_scrub *sc) {return -EOPNOTSUPP ;
fs/xfs/scrub/rmap.c +2 -3
@@ -21,10 +21,9 @@*/ int xchk_setup_ag_rmapbt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) { -return xchk_setup_ag_btree (sc, ip, false); +return xchk_setup_ag_btree (sc, false); }/* Reverse-mapping scrubber. */
fs/xfs/scrub/rtbitmap.c +2 -3
@@ -20,12 +20,11 @@/* Set us up with the realtime metadata locked. */ int xchk_setup_rt ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {int error; - error =xchk_setup_fs (sc, ip); + error =xchk_setup_fs (sc);if (error)return error;
fs/xfs/scrub/scrub.c +5 -6
@@ -468,8 +468,7 @@ xfs_scrub_metadata( .agno = NULLAGNUMBER, }, }; -struct xfs_inode *ip =XFS_I (file_inode (file)); -struct xfs_mount *mp = ip->i_mount; +struct xfs_mount *mp =XFS_I (file_inode (file))->i_mount;int error =0 ; sc.mp = mp;
@@ -477,7 +476,7 @@ xfs_scrub_metadata(BUILD_BUG_ON (sizeof (meta_scrub_ops) != (sizeof (struct xchk_meta_ops ) *XFS_SCRUB_TYPE_NR )); -trace_xchk_start (ip, sm, error); +trace_xchk_start (XFS_I (file_inode (file)), sm, error);/* Forbidden if we are shut down or mounted norecovery. */ error = -ESHUTDOWN ;
@@ -507,7 +506,7 @@ xfs_scrub_metadata( }/* Set up for the operation. */ - error = sc.ops->setup (&sc, ip); + error = sc.ops->setup (&sc);if (error) goto out_teardown;
@@ -553,7 +552,7 @@ xfs_scrub_metadata(* If it's broken, userspace wants us to fix it, and we haven't * already tried to fix it, then attempt a repair. */ - error =xrep_attempt (ip, &sc); + error =xrep_attempt (&sc);if (error == -EAGAIN ) {/* * Either the repair function succeeded or it couldn't
@@ -574,7 +573,7 @@ xfs_scrub_metadata( out_teardown: error =xchk_teardown (&sc, error); out: -trace_xchk_done (ip, sm, error); +trace_xchk_done (XFS_I (file_inode (file)), sm, error);if (error == -EFSCORRUPTED || error == -EFSBADCRC ) { sm->sm_flags |=XFS_SCRUB_OFLAG_CORRUPT ; error =0 ;
fs/xfs/scrub/scrub.h +1 -2
@@ -18,8 +18,7 @@ enum xchk_type {struct xchk_meta_ops {/* Acquire whatever resources are needed for the operation. */ -int (*setup)(struct xfs_scrub *, -struct xfs_inode *); +int (*setup)(struct xfs_scrub *sc);/* Examine metadata for errors. */ int (*scrub)(struct xfs_scrub *);
fs/xfs/scrub/symlink.c +2 -3
@@ -18,15 +18,14 @@/* Set us up to scrub a symbolic link. */ int xchk_setup_symlink ( -struct xfs_scrub *sc, -struct xfs_inode *ip) +struct xfs_scrub *sc) {/* Allocate the buffer without the inode lock held. */ sc->buf =kvzalloc (XFS_SYMLINK_MAXLEN +1 ,GFP_KERNEL );if (!sc->buf)return -ENOMEM ; -return xchk_setup_inode_contents (sc, ip,0 ); +return xchk_setup_inode_contents (sc,0 ); }/* Symbolic links. */
Quoted 9 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Now that the scrub context stores a pointer to the file that was used to invoke the scrub call, the struct
xfs_inodepointer that we passed to all the setup functions is no longer necessary. This is only ever used if the caller wants us to scrub the metadata of the open file.Signed-off-by Darrick J. Wong <[email protected]>Reviewed-by Chandan Babu R <[email protected]>
Looks good,