Message ID | 20250114224819.GD2103004@frogsfrogsfrogs (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | xfs: fix online repair probing when CONFIG_XFS_ONLINE_REPAIR=n | expand |
On Tue, Jan 14, 2025 at 02:48:19PM -0800, Darrick J. Wong wrote: > index 950f5a58dcd967..09468f50781b24 100644 > --- a/fs/xfs/scrub/scrub.c > +++ b/fs/xfs/scrub/scrub.c > @@ -149,6 +149,15 @@ xchk_probe( > if (xchk_should_terminate(sc, &error)) > return error; > > + /* > + * If the caller is probing to see if repair works, set the CORRUPT > + * flag (without any of the usual tracing/logging) to force us into > + * the repair codepaths. If repair is compiled into the kernel, we'll > + * call xrep_probe and simulate a repair; otherwise, the repair > + * codepaths return EOPNOTSUPP. > + */ > + if (xchk_could_repair(sc)) > + sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; Stupid question: what is the point in not just directly returning -EOPNOTSUPP here when online repair is not supported?
On Wed, Jan 15, 2025 at 07:06:15AM +0100, Christoph Hellwig wrote: > On Tue, Jan 14, 2025 at 02:48:19PM -0800, Darrick J. Wong wrote: > > index 950f5a58dcd967..09468f50781b24 100644 > > --- a/fs/xfs/scrub/scrub.c > > +++ b/fs/xfs/scrub/scrub.c > > @@ -149,6 +149,15 @@ xchk_probe( > > if (xchk_should_terminate(sc, &error)) > > return error; > > > > + /* > > + * If the caller is probing to see if repair works, set the CORRUPT > > + * flag (without any of the usual tracing/logging) to force us into > > + * the repair codepaths. If repair is compiled into the kernel, we'll > > + * call xrep_probe and simulate a repair; otherwise, the repair > > + * codepaths return EOPNOTSUPP. > > + */ > > + if (xchk_could_repair(sc)) > > + sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; > > Stupid question: what is the point in not just directly returning > -EOPNOTSUPP here when online repair is not supported? Good point, we could cut it off right then and there. Though this seems a little gross: if (xchk_could_repair(sc)) #ifdef CONFIG_XFS_ONLINE_REPAIR sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; #else return -EOPNOTSUPP; #endif return 0; but I don't mind. Some day the stubs will go away, fingers crossed. --D
On Tue, Jan 14, 2025 at 10:20:37PM -0800, Darrick J. Wong wrote: > Good point, we could cut it off right then and there. Though this seems > a little gross: > > if (xchk_could_repair(sc)) > #ifdef CONFIG_XFS_ONLINE_REPAIR > sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; > #else > return -EOPNOTSUPP; > #endif > return 0; > > but I don't mind. Some day the stubs will go away, fingers crossed. We'll I'd write it as: if (xchk_could_repair(sc)) { if (!IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)) return -EOPNOTSUPP; sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; } but I'm fine with either version: Reviewed-by: Christoph Hellwig <hch@lst.de>
On Wed, Jan 15, 2025 at 07:27:43AM +0100, Christoph Hellwig wrote: > On Tue, Jan 14, 2025 at 10:20:37PM -0800, Darrick J. Wong wrote: > > Good point, we could cut it off right then and there. Though this seems > > a little gross: > > > > if (xchk_could_repair(sc)) > > #ifdef CONFIG_XFS_ONLINE_REPAIR > > sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; > > #else > > return -EOPNOTSUPP; > > #endif > > return 0; > > > > but I don't mind. Some day the stubs will go away, fingers crossed. > > We'll I'd write it as: > > if (xchk_could_repair(sc)) { > if (!IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)) > return -EOPNOTSUPP; > sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; > } > > but I'm fine with either version: I like your version /much/ better. > Reviewed-by: Christoph Hellwig <hch@lst.de> Thanks! --D
diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h index eecb6d54c0f953..53a6b34ce54271 100644 --- a/fs/xfs/scrub/common.h +++ b/fs/xfs/scrub/common.h @@ -212,7 +212,6 @@ static inline bool xchk_skip_xref(struct xfs_scrub_metadata *sm) bool xchk_dir_looks_zapped(struct xfs_inode *dp); bool xchk_pptr_looks_zapped(struct xfs_inode *ip); -#ifdef CONFIG_XFS_ONLINE_REPAIR /* Decide if a repair is required. */ static inline bool xchk_needs_repair(const struct xfs_scrub_metadata *sm) { @@ -232,10 +231,6 @@ static inline bool xchk_could_repair(const struct xfs_scrub *sc) return (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) && !(sc->flags & XREP_ALREADY_FIXED); } -#else -# define xchk_needs_repair(sc) (false) -# define xchk_could_repair(sc) (false) -#endif /* CONFIG_XFS_ONLINE_REPAIR */ int xchk_metadata_inode_forks(struct xfs_scrub *sc); diff --git a/fs/xfs/scrub/repair.h b/fs/xfs/scrub/repair.h index b649da1a93eb8c..b3b1fe62814e7b 100644 --- a/fs/xfs/scrub/repair.h +++ b/fs/xfs/scrub/repair.h @@ -173,7 +173,16 @@ bool xrep_buf_verify_struct(struct xfs_buf *bp, const struct xfs_buf_ops *ops); #else #define xrep_ino_dqattach(sc) (0) -#define xrep_will_attempt(sc) (false) + +/* + * When online repair is not built into the kernel, we still want to attempt + * the repair so that the stub xrep_attempt below will return EOPNOTSUPP. + */ +static inline bool xrep_will_attempt(const struct xfs_scrub *sc) +{ + return (sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) || + xchk_needs_repair(sc->sm); +} static inline int xrep_attempt( diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c index 950f5a58dcd967..09468f50781b24 100644 --- a/fs/xfs/scrub/scrub.c +++ b/fs/xfs/scrub/scrub.c @@ -149,6 +149,15 @@ xchk_probe( if (xchk_should_terminate(sc, &error)) return error; + /* + * If the caller is probing to see if repair works, set the CORRUPT + * flag (without any of the usual tracing/logging) to force us into + * the repair codepaths. If repair is compiled into the kernel, we'll + * call xrep_probe and simulate a repair; otherwise, the repair + * codepaths return EOPNOTSUPP. + */ + if (xchk_could_repair(sc)) + sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; return 0; }