Skip to content

Commit 7146bda

Browse files
committed
Merge branch 'guilt/xfs-5.19-larp-cleanups' into xfs-5.19-for-next
This series contains a two key cleanups for the new LARP code. Most of it is refactoring and tweaking the code that creates kernel log messages about enabling and disabling features -- we should be warning about LARP being turned on once per mount, instead of once per insmod cycle; we shouldn't be spamming the logs so aggressively about turning *off* log incompat features. The second part of the series refactors the LARP code responsible for getting (and releasing) permission to use xattr log items. The implementation code doesn't belong in xfs_log.c, and calls to logging functions don't belong in libxfs -- they really should be done by the VFS implementation functions before they start calling into libraries. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Dave Chinner <david@fromorbit.com>
2 parents 621dc80 + efc2efe commit 7146bda

File tree

14 files changed

+126
-81
lines changed

14 files changed

+126
-81
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "xfs_trans_space.h"
2626
#include "xfs_trace.h"
2727
#include "xfs_attr_item.h"
28-
#include "xfs_log.h"
28+
#include "xfs_xattr.h"
2929

3030
struct kmem_cache *xfs_attr_intent_cache;
3131

@@ -982,7 +982,6 @@ xfs_attr_set(
982982
int error, local;
983983
int rmt_blks = 0;
984984
unsigned int total;
985-
bool use_logging = xfs_has_larp(mp);
986985

987986
if (xfs_is_shutdown(dp->i_mount))
988987
return -EIO;
@@ -1027,20 +1026,14 @@ xfs_attr_set(
10271026
rmt_blks = xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX);
10281027
}
10291028

1030-
if (use_logging) {
1031-
error = xfs_attr_use_log_assist(mp);
1032-
if (error)
1033-
return error;
1034-
}
1035-
10361029
/*
10371030
* Root fork attributes can use reserved data blocks for this
10381031
* operation if necessary
10391032
*/
10401033
xfs_init_attr_trans(args, &tres, &total);
10411034
error = xfs_trans_alloc_inode(dp, &tres, total, 0, rsvd, &args->trans);
10421035
if (error)
1043-
goto drop_incompat;
1036+
return error;
10441037

10451038
if (args->value || xfs_inode_hasattr(dp)) {
10461039
error = xfs_iext_count_may_overflow(dp, XFS_ATTR_FORK,
@@ -1100,9 +1093,6 @@ xfs_attr_set(
11001093
error = xfs_trans_commit(args->trans);
11011094
out_unlock:
11021095
xfs_iunlock(dp, XFS_ILOCK_EXCL);
1103-
drop_incompat:
1104-
if (use_logging)
1105-
xlog_drop_incompat_feat(mp->m_log);
11061096
return error;
11071097

11081098
out_trans_cancel:

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_acl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "xfs_error.h"
1818
#include "xfs_acl.h"
1919
#include "xfs_trans.h"
20+
#include "xfs_xattr.h"
2021

2122
#include <linux/posix_acl_xattr.h>
2223

@@ -202,7 +203,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
202203
xfs_acl_to_disk(args.value, acl);
203204
}
204205

205-
error = xfs_attr_set(&args);
206+
error = xfs_attr_change(&args);
206207
kmem_free(args.value);
207208

208209
/*

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_ioctl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "xfs_health.h"
3838
#include "xfs_reflink.h"
3939
#include "xfs_ioctl.h"
40+
#include "xfs_xattr.h"
4041

4142
#include <linux/mount.h>
4243
#include <linux/namei.h>
@@ -524,7 +525,7 @@ xfs_attrmulti_attr_set(
524525
args.valuelen = len;
525526
}
526527

527-
error = xfs_attr_set(&args);
528+
error = xfs_attr_change(&args);
528529
if (!error && (flags & XFS_IOC_ATTR_ROOT))
529530
xfs_forget_acl(inode, name);
530531
kfree(args.value);

fs/xfs/xfs_iops.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "xfs_iomap.h"
2525
#include "xfs_error.h"
2626
#include "xfs_ioctl.h"
27+
#include "xfs_xattr.h"
2728

2829
#include <linux/posix_acl.h>
2930
#include <linux/security.h>
@@ -61,7 +62,7 @@ xfs_initxattrs(
6162
.value = xattr->value,
6263
.valuelen = xattr->value_len,
6364
};
64-
error = xfs_attr_set(&args);
65+
error = xfs_attr_change(&args);
6566
if (error < 0)
6667
break;
6768
}

fs/xfs/xfs_log.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,44 +3877,3 @@ xlog_drop_incompat_feat(
38773877
{
38783878
up_read(&log->l_incompat_users);
38793879
}
3880-
3881-
/*
3882-
* Get permission to use log-assisted atomic exchange of file extents.
3883-
*
3884-
* Callers must not be running any transactions or hold any inode locks, and
3885-
* they must release the permission by calling xlog_drop_incompat_feat
3886-
* when they're done.
3887-
*/
3888-
int
3889-
xfs_attr_use_log_assist(
3890-
struct xfs_mount *mp)
3891-
{
3892-
int error = 0;
3893-
3894-
/*
3895-
* Protect ourselves from an idle log clearing the logged xattrs log
3896-
* incompat feature bit.
3897-
*/
3898-
xlog_use_incompat_feat(mp->m_log);
3899-
3900-
/*
3901-
* If log-assisted xattrs are already enabled, the caller can use the
3902-
* log assisted swap functions with the log-incompat reference we got.
3903-
*/
3904-
if (xfs_sb_version_haslogxattrs(&mp->m_sb))
3905-
return 0;
3906-
3907-
/* Enable log-assisted xattrs. */
3908-
error = xfs_add_incompat_log_feature(mp,
3909-
XFS_SB_FEAT_INCOMPAT_LOG_XATTRS);
3910-
if (error)
3911-
goto drop_incompat;
3912-
3913-
xfs_warn_once(mp,
3914-
"EXPERIMENTAL logged extended attributes feature added. Use at your own risk!");
3915-
3916-
return 0;
3917-
drop_incompat:
3918-
xlog_drop_incompat_feat(mp->m_log);
3919-
return error;
3920-
}

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.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,6 @@ xfs_clear_incompat_log_features(
13561356

13571357
if (xfs_sb_has_incompat_log_feature(&mp->m_sb,
13581358
XFS_SB_FEAT_INCOMPAT_LOG_ALL)) {
1359-
xfs_info(mp, "Clearing log incompat feature flags.");
13601359
xfs_sb_remove_incompat_log_features(&mp->m_sb);
13611360
ret = true;
13621361
}

fs/xfs/xfs_mount.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,13 @@ __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+
/* Kernel has logged a warning about logged xattr updates being used. */
399+
#define XFS_OPSTATE_WARNED_LARP 9
400+
394401
#define __XFS_IS_OPSTATE(name, NAME) \
395402
static inline bool xfs_is_ ## name (struct xfs_mount *mp) \
396403
{ \
@@ -413,14 +420,23 @@ __XFS_IS_OPSTATE(readonly, READONLY)
413420
__XFS_IS_OPSTATE(inodegc_enabled, INODEGC_ENABLED)
414421
__XFS_IS_OPSTATE(blockgc_enabled, BLOCKGC_ENABLED)
415422

423+
static inline bool
424+
xfs_should_warn(struct xfs_mount *mp, long nr)
425+
{
426+
return !test_and_set_bit(nr, &mp->m_opstate);
427+
}
428+
416429
#define XFS_OPSTATE_STRINGS \
417430
{ (1UL << XFS_OPSTATE_UNMOUNTING), "unmounting" }, \
418431
{ (1UL << XFS_OPSTATE_CLEAN), "clean" }, \
419432
{ (1UL << XFS_OPSTATE_SHUTDOWN), "shutdown" }, \
420433
{ (1UL << XFS_OPSTATE_INODE32), "inode32" }, \
421434
{ (1UL << XFS_OPSTATE_READONLY), "read_only" }, \
422435
{ (1UL << XFS_OPSTATE_INODEGC_ENABLED), "inodegc" }, \
423-
{ (1UL << XFS_OPSTATE_BLOCKGC_ENABLED), "blockgc" }
436+
{ (1UL << XFS_OPSTATE_BLOCKGC_ENABLED), "blockgc" }, \
437+
{ (1UL << XFS_OPSTATE_WARNED_SCRUB), "wscrub" }, \
438+
{ (1UL << XFS_OPSTATE_WARNED_SHRINK), "wshrink" }, \
439+
{ (1UL << XFS_OPSTATE_WARNED_LARP), "wlarp" }
424440

425441
/*
426442
* Max and min values for mount-option defined I/O

0 commit comments

Comments
 (0)