xfs: get rid of the ip parameter to xchk_setup_*
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. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
71bddbccab
commit
026f57ebe1
@ -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. */
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
/*
|
||||
|
@ -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 */
|
||||
|
@ -116,8 +116,7 @@ next_loop_perag:
|
||||
|
||||
int
|
||||
xchk_setup_fscounters(
|
||||
struct xfs_scrub *sc,
|
||||
struct xfs_inode *ip)
|
||||
struct xfs_scrub *sc)
|
||||
{
|
||||
struct xchk_fscounters *fsc;
|
||||
int error;
|
||||
|
@ -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. */
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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. */
|
||||
|
@ -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:
|
||||
/*
|
||||
|
@ -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;
|
||||
|
@ -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. */
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 @@ retry_op:
|
||||
}
|
||||
|
||||
/* 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 @@ retry_op:
|
||||
* 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 @@ out_nofix:
|
||||
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;
|
||||
|
@ -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 *);
|
||||
|
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user