Skip to content

Commit df5660c

Browse files
Darrick J. Wongdchinner
authored andcommitted
xfs: implement per-mount warnings for scrub and shrink usage
Currently, we don't have a consistent story around logging when an EXPERIMENTAL feature gets turned on at runtime -- online fsck and shrink log a message once per day across all mounts, and the recently merged LARP mode only ever does it once per insmod cycle or reboot. Because EXPERIMENTAL tags are supposed to go away eventually, convert the existing daily warnings into state flags that travel with the mount, and warn once per mount. Making this an opstate flag means that we'll be able to capture the experimental usage in the ftrace output too. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent 3740379 commit df5660c

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

fs/xfs/scrub/scrub.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -340,20 +340,6 @@ static const struct xchk_meta_ops meta_scrub_ops[] = {
340340
},
341341
};
342342

343-
/* This isn't a stable feature, warn once per day. */
344-
static inline void
345-
xchk_experimental_warning(
346-
struct xfs_mount *mp)
347-
{
348-
static struct ratelimit_state scrub_warning = RATELIMIT_STATE_INIT(
349-
"xchk_warning", 86400 * HZ, 1);
350-
ratelimit_set_flags(&scrub_warning, RATELIMIT_MSG_ON_RELEASE);
351-
352-
if (__ratelimit(&scrub_warning))
353-
xfs_alert(mp,
354-
"EXPERIMENTAL online scrub feature in use. Use at your own risk!");
355-
}
356-
357343
static int
358344
xchk_validate_inputs(
359345
struct xfs_mount *mp,
@@ -478,7 +464,8 @@ xfs_scrub_metadata(
478464
if (error)
479465
goto out;
480466

481-
xchk_experimental_warning(mp);
467+
xfs_warn_mount(mp, XFS_OPSTATE_WARNED_SCRUB,
468+
"EXPERIMENTAL online scrub feature in use. Use at your own risk!");
482469

483470
sc = kmem_zalloc(sizeof(struct xfs_scrub), KM_NOFS | KM_MAYFAIL);
484471
if (!sc) {

fs/xfs/xfs_fsops.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,7 @@ xfs_growfs_data_private(
149149
error = xfs_resizefs_init_new_ags(tp, &id, oagcount, nagcount,
150150
delta, &lastag_extended);
151151
} else {
152-
static struct ratelimit_state shrink_warning = \
153-
RATELIMIT_STATE_INIT("shrink_warning", 86400 * HZ, 1);
154-
ratelimit_set_flags(&shrink_warning, RATELIMIT_MSG_ON_RELEASE);
155-
156-
if (__ratelimit(&shrink_warning))
157-
xfs_alert(mp,
152+
xfs_warn_mount(mp, XFS_OPSTATE_WARNED_SHRINK,
158153
"EXPERIMENTAL online shrink feature in use. Use at your own risk!");
159154

160155
error = xfs_ag_shrink_space(mp, &tp, nagcount - 1, -delta);

fs/xfs/xfs_message.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ do { \
7575
#define xfs_debug_ratelimited(dev, fmt, ...) \
7676
xfs_printk_ratelimited(xfs_debug, dev, fmt, ##__VA_ARGS__)
7777

78+
#define xfs_warn_mount(mp, warntag, fmt, ...) \
79+
do { \
80+
if (xfs_should_warn((mp), (warntag))) \
81+
xfs_warn((mp), (fmt), ##__VA_ARGS__); \
82+
} while (0)
83+
7884
#define xfs_warn_once(dev, fmt, ...) \
7985
xfs_printk_once(xfs_warn, dev, fmt, ##__VA_ARGS__)
8086
#define xfs_notice_once(dev, fmt, ...) \

fs/xfs/xfs_mount.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ __XFS_HAS_FEAT(nouuid, NOUUID)
391391
*/
392392
#define XFS_OPSTATE_BLOCKGC_ENABLED 6
393393

394+
/* Kernel has logged a warning about online fsck being used on this fs. */
395+
#define XFS_OPSTATE_WARNED_SCRUB 7
396+
/* Kernel has logged a warning about shrink being used on this fs. */
397+
#define XFS_OPSTATE_WARNED_SHRINK 8
398+
394399
#define __XFS_IS_OPSTATE(name, NAME) \
395400
static inline bool xfs_is_ ## name (struct xfs_mount *mp) \
396401
{ \
@@ -413,14 +418,22 @@ __XFS_IS_OPSTATE(readonly, READONLY)
413418
__XFS_IS_OPSTATE(inodegc_enabled, INODEGC_ENABLED)
414419
__XFS_IS_OPSTATE(blockgc_enabled, BLOCKGC_ENABLED)
415420

421+
static inline bool
422+
xfs_should_warn(struct xfs_mount *mp, long nr)
423+
{
424+
return !test_and_set_bit(nr, &mp->m_opstate);
425+
}
426+
416427
#define XFS_OPSTATE_STRINGS \
417428
{ (1UL << XFS_OPSTATE_UNMOUNTING), "unmounting" }, \
418429
{ (1UL << XFS_OPSTATE_CLEAN), "clean" }, \
419430
{ (1UL << XFS_OPSTATE_SHUTDOWN), "shutdown" }, \
420431
{ (1UL << XFS_OPSTATE_INODE32), "inode32" }, \
421432
{ (1UL << XFS_OPSTATE_READONLY), "read_only" }, \
422433
{ (1UL << XFS_OPSTATE_INODEGC_ENABLED), "inodegc" }, \
423-
{ (1UL << XFS_OPSTATE_BLOCKGC_ENABLED), "blockgc" }
434+
{ (1UL << XFS_OPSTATE_BLOCKGC_ENABLED), "blockgc" }, \
435+
{ (1UL << XFS_OPSTATE_WARNED_SCRUB), "wscrub" }, \
436+
{ (1UL << XFS_OPSTATE_WARNED_SHRINK), "wshrink" }
424437

425438
/*
426439
* Max and min values for mount-option defined I/O

0 commit comments

Comments
 (0)