diff options
Diffstat (limited to 'fs/xfs/scrub/scrub.c')
-rw-r--r-- | fs/xfs/scrub/scrub.c | 210 |
1 files changed, 108 insertions, 102 deletions
diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c index 58ae76b3a421..4bfae1e61d30 100644 --- a/fs/xfs/scrub/scrub.c +++ b/fs/xfs/scrub/scrub.c @@ -131,6 +131,12 @@ * optimize the structure so that the rebuild knows what to do. The * second check evaluates the completeness of the repair; that is what * is reported to userspace. + * + * A quick note on symbol prefixes: + * - "xfs_" are general XFS symbols. + * - "xchk_" are symbols related to metadata checking. + * - "xrep_" are symbols related to metadata repair. + * - "xfs_scrub_" are symbols that tie online fsck to the rest of XFS. */ /* @@ -144,12 +150,12 @@ * supported by the running kernel. */ static int -xfs_scrub_probe( - struct xfs_scrub_context *sc) +xchk_probe( + struct xfs_scrub *sc) { - int error = 0; + int error = 0; - if (xfs_scrub_should_terminate(sc, &error)) + if (xchk_should_terminate(sc, &error)) return error; return 0; @@ -159,12 +165,12 @@ xfs_scrub_probe( /* Free all the resources and finish the transactions. */ STATIC int -xfs_scrub_teardown( - struct xfs_scrub_context *sc, - struct xfs_inode *ip_in, - int error) +xchk_teardown( + struct xfs_scrub *sc, + struct xfs_inode *ip_in, + int error) { - xfs_scrub_ag_free(sc, &sc->sa); + xchk_ag_free(sc, &sc->sa); if (sc->tp) { if (error == 0 && (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)) error = xfs_trans_commit(sc->tp); @@ -177,7 +183,7 @@ xfs_scrub_teardown( xfs_iunlock(sc->ip, sc->ilock_flags); if (sc->ip != ip_in && !xfs_internal_inum(sc->mp, sc->ip->i_ino)) - iput(VFS_I(sc->ip)); + xfs_irele(sc->ip); sc->ip = NULL; } if (sc->has_quotaofflock) @@ -191,165 +197,165 @@ xfs_scrub_teardown( /* Scrubbing dispatch. */ -static const struct xfs_scrub_meta_ops meta_scrub_ops[] = { +static const struct xchk_meta_ops meta_scrub_ops[] = { [XFS_SCRUB_TYPE_PROBE] = { /* ioctl presence test */ .type = ST_NONE, - .setup = xfs_scrub_setup_fs, - .scrub = xfs_scrub_probe, - .repair = xfs_repair_probe, + .setup = xchk_setup_fs, + .scrub = xchk_probe, + .repair = xrep_probe, }, [XFS_SCRUB_TYPE_SB] = { /* superblock */ .type = ST_PERAG, - .setup = xfs_scrub_setup_fs, - .scrub = xfs_scrub_superblock, - .repair = xfs_repair_superblock, + .setup = xchk_setup_fs, + .scrub = xchk_superblock, + .repair = xrep_superblock, }, [XFS_SCRUB_TYPE_AGF] = { /* agf */ .type = ST_PERAG, - .setup = xfs_scrub_setup_fs, - .scrub = xfs_scrub_agf, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_fs, + .scrub = xchk_agf, + .repair = xrep_agf, }, [XFS_SCRUB_TYPE_AGFL]= { /* agfl */ .type = ST_PERAG, - .setup = xfs_scrub_setup_fs, - .scrub = xfs_scrub_agfl, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_fs, + .scrub = xchk_agfl, + .repair = xrep_agfl, }, [XFS_SCRUB_TYPE_AGI] = { /* agi */ .type = ST_PERAG, - .setup = xfs_scrub_setup_fs, - .scrub = xfs_scrub_agi, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_fs, + .scrub = xchk_agi, + .repair = xrep_agi, }, [XFS_SCRUB_TYPE_BNOBT] = { /* bnobt */ .type = ST_PERAG, - .setup = xfs_scrub_setup_ag_allocbt, - .scrub = xfs_scrub_bnobt, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_ag_allocbt, + .scrub = xchk_bnobt, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_CNTBT] = { /* cntbt */ .type = ST_PERAG, - .setup = xfs_scrub_setup_ag_allocbt, - .scrub = xfs_scrub_cntbt, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_ag_allocbt, + .scrub = xchk_cntbt, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_INOBT] = { /* inobt */ .type = ST_PERAG, - .setup = xfs_scrub_setup_ag_iallocbt, - .scrub = xfs_scrub_inobt, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_ag_iallocbt, + .scrub = xchk_inobt, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_FINOBT] = { /* finobt */ .type = ST_PERAG, - .setup = xfs_scrub_setup_ag_iallocbt, - .scrub = xfs_scrub_finobt, + .setup = xchk_setup_ag_iallocbt, + .scrub = xchk_finobt, .has = xfs_sb_version_hasfinobt, - .repair = xfs_repair_notsupported, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_RMAPBT] = { /* rmapbt */ .type = ST_PERAG, - .setup = xfs_scrub_setup_ag_rmapbt, - .scrub = xfs_scrub_rmapbt, + .setup = xchk_setup_ag_rmapbt, + .scrub = xchk_rmapbt, .has = xfs_sb_version_hasrmapbt, - .repair = xfs_repair_notsupported, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_REFCNTBT] = { /* refcountbt */ .type = ST_PERAG, - .setup = xfs_scrub_setup_ag_refcountbt, - .scrub = xfs_scrub_refcountbt, + .setup = xchk_setup_ag_refcountbt, + .scrub = xchk_refcountbt, .has = xfs_sb_version_hasreflink, - .repair = xfs_repair_notsupported, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_INODE] = { /* inode record */ .type = ST_INODE, - .setup = xfs_scrub_setup_inode, - .scrub = xfs_scrub_inode, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_inode, + .scrub = xchk_inode, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_BMBTD] = { /* inode data fork */ .type = ST_INODE, - .setup = xfs_scrub_setup_inode_bmap, - .scrub = xfs_scrub_bmap_data, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_inode_bmap, + .scrub = xchk_bmap_data, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_BMBTA] = { /* inode attr fork */ .type = ST_INODE, - .setup = xfs_scrub_setup_inode_bmap, - .scrub = xfs_scrub_bmap_attr, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_inode_bmap, + .scrub = xchk_bmap_attr, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_BMBTC] = { /* inode CoW fork */ .type = ST_INODE, - .setup = xfs_scrub_setup_inode_bmap, - .scrub = xfs_scrub_bmap_cow, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_inode_bmap, + .scrub = xchk_bmap_cow, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_DIR] = { /* directory */ .type = ST_INODE, - .setup = xfs_scrub_setup_directory, - .scrub = xfs_scrub_directory, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_directory, + .scrub = xchk_directory, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_XATTR] = { /* extended attributes */ .type = ST_INODE, - .setup = xfs_scrub_setup_xattr, - .scrub = xfs_scrub_xattr, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_xattr, + .scrub = xchk_xattr, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_SYMLINK] = { /* symbolic link */ .type = ST_INODE, - .setup = xfs_scrub_setup_symlink, - .scrub = xfs_scrub_symlink, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_symlink, + .scrub = xchk_symlink, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_PARENT] = { /* parent pointers */ .type = ST_INODE, - .setup = xfs_scrub_setup_parent, - .scrub = xfs_scrub_parent, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_parent, + .scrub = xchk_parent, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_RTBITMAP] = { /* realtime bitmap */ .type = ST_FS, - .setup = xfs_scrub_setup_rt, - .scrub = xfs_scrub_rtbitmap, + .setup = xchk_setup_rt, + .scrub = xchk_rtbitmap, .has = xfs_sb_version_hasrealtime, - .repair = xfs_repair_notsupported, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_RTSUM] = { /* realtime summary */ .type = ST_FS, - .setup = xfs_scrub_setup_rt, - .scrub = xfs_scrub_rtsummary, + .setup = xchk_setup_rt, + .scrub = xchk_rtsummary, .has = xfs_sb_version_hasrealtime, - .repair = xfs_repair_notsupported, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_UQUOTA] = { /* user quota */ .type = ST_FS, - .setup = xfs_scrub_setup_quota, - .scrub = xfs_scrub_quota, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_quota, + .scrub = xchk_quota, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_GQUOTA] = { /* group quota */ .type = ST_FS, - .setup = xfs_scrub_setup_quota, - .scrub = xfs_scrub_quota, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_quota, + .scrub = xchk_quota, + .repair = xrep_notsupported, }, [XFS_SCRUB_TYPE_PQUOTA] = { /* project quota */ .type = ST_FS, - .setup = xfs_scrub_setup_quota, - .scrub = xfs_scrub_quota, - .repair = xfs_repair_notsupported, + .setup = xchk_setup_quota, + .scrub = xchk_quota, + .repair = xrep_notsupported, }, }; /* This isn't a stable feature, warn once per day. */ static inline void -xfs_scrub_experimental_warning( +xchk_experimental_warning( struct xfs_mount *mp) { static struct ratelimit_state scrub_warning = RATELIMIT_STATE_INIT( - "xfs_scrub_warning", 86400 * HZ, 1); + "xchk_warning", 86400 * HZ, 1); ratelimit_set_flags(&scrub_warning, RATELIMIT_MSG_ON_RELEASE); if (__ratelimit(&scrub_warning)) @@ -358,12 +364,12 @@ xfs_scrub_experimental_warning( } static int -xfs_scrub_validate_inputs( +xchk_validate_inputs( struct xfs_mount *mp, struct xfs_scrub_metadata *sm) { int error; - const struct xfs_scrub_meta_ops *ops; + const struct xchk_meta_ops *ops; error = -EINVAL; /* Check our inputs. */ @@ -441,7 +447,7 @@ out: } #ifdef CONFIG_XFS_ONLINE_REPAIR -static inline void xfs_scrub_postmortem(struct xfs_scrub_context *sc) +static inline void xchk_postmortem(struct xfs_scrub *sc) { /* * Userspace asked us to repair something, we repaired it, rescanned @@ -451,10 +457,10 @@ static inline void xfs_scrub_postmortem(struct xfs_scrub_context *sc) if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) && (sc->sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT | XFS_SCRUB_OFLAG_XCORRUPT))) - xfs_repair_failure(sc->mp); + xrep_failure(sc->mp); } #else -static inline void xfs_scrub_postmortem(struct xfs_scrub_context *sc) +static inline void xchk_postmortem(struct xfs_scrub *sc) { /* * Userspace asked us to scrub something, it's broken, and we have no @@ -473,16 +479,16 @@ xfs_scrub_metadata( struct xfs_inode *ip, struct xfs_scrub_metadata *sm) { - struct xfs_scrub_context sc; + struct xfs_scrub sc; struct xfs_mount *mp = ip->i_mount; bool try_harder = false; bool already_fixed = false; int error = 0; BUILD_BUG_ON(sizeof(meta_scrub_ops) != - (sizeof(struct xfs_scrub_meta_ops) * XFS_SCRUB_TYPE_NR)); + (sizeof(struct xchk_meta_ops) * XFS_SCRUB_TYPE_NR)); - trace_xfs_scrub_start(ip, sm, error); + trace_xchk_start(ip, sm, error); /* Forbidden if we are shut down or mounted norecovery. */ error = -ESHUTDOWN; @@ -492,11 +498,11 @@ xfs_scrub_metadata( if (mp->m_flags & XFS_MOUNT_NORECOVERY) goto out; - error = xfs_scrub_validate_inputs(mp, sm); + error = xchk_validate_inputs(mp, sm); if (error) goto out; - xfs_scrub_experimental_warning(mp); + xchk_experimental_warning(mp); retry_op: /* Set up for the operation. */ @@ -518,7 +524,7 @@ retry_op: * Tear down everything we hold, then set up again with * preparation for worst-case scenarios. */ - error = xfs_scrub_teardown(&sc, ip, 0); + error = xchk_teardown(&sc, ip, 0); if (error) goto out; try_harder = true; @@ -549,13 +555,13 @@ 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 = xfs_repair_attempt(ip, &sc, &already_fixed); + error = xrep_attempt(ip, &sc, &already_fixed); if (error == -EAGAIN) { if (sc.try_harder) try_harder = true; - error = xfs_scrub_teardown(&sc, ip, 0); + error = xchk_teardown(&sc, ip, 0); if (error) { - xfs_repair_failure(mp); + xrep_failure(mp); goto out; } goto retry_op; @@ -563,11 +569,11 @@ retry_op: } out_nofix: - xfs_scrub_postmortem(&sc); + xchk_postmortem(&sc); out_teardown: - error = xfs_scrub_teardown(&sc, ip, error); + error = xchk_teardown(&sc, ip, error); out: - trace_xfs_scrub_done(ip, sm, error); + trace_xchk_done(ip, sm, error); if (error == -EFSCORRUPTED || error == -EFSBADCRC) { sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; error = 0; |