Skip to content

Commit d9c61cc

Browse files
Darrick J. Wongdchinner
authored andcommitted
xfs: move xfs_attr_use_log_assist out of xfs_log.c
The LARP patchset added an awkward coupling point between libxfs and what would be libxlog, if the XFS log were actually its own library. Move the code that enables logged xattr updates out of "lib"xlog and into xfs_xattr.c so that it no longer has to know about xlog_* functions. While we're at it, give xfs_xattr.c its own header file. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
1 parent 202865c commit d9c61cc

File tree

6 files changed

+67
-45
lines changed

6 files changed

+67
-45
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 3 additions & 3 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

@@ -1028,7 +1028,7 @@ xfs_attr_set(
10281028
}
10291029

10301030
if (use_logging) {
1031-
error = xfs_attr_use_log_assist(mp);
1031+
error = xfs_attr_grab_log_assist(mp);
10321032
if (error)
10331033
return error;
10341034
}
@@ -1102,7 +1102,7 @@ xfs_attr_set(
11021102
xfs_iunlock(dp, XFS_ILOCK_EXCL);
11031103
drop_incompat:
11041104
if (use_logging)
1105-
xlog_drop_incompat_feat(mp->m_log);
1105+
xfs_attr_rele_log_assist(mp);
11061106
return error;
11071107

11081108
out_trans_cancel:

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_mount(mp, XFS_OPSTATE_WARNED_LARP,
3914-
"EXPERIMENTAL logged extended attributes feature in use. 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_super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "xfs_ag.h"
4040
#include "xfs_defer.h"
4141
#include "xfs_attr_item.h"
42+
#include "xfs_xattr.h"
4243

4344
#include <linux/magic.h>
4445
#include <linux/fs_context.h>

fs/xfs/xfs_super.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ extern xfs_agnumber_t xfs_set_inode_alloc(struct xfs_mount *,
9191
xfs_agnumber_t agcount);
9292

9393
extern const struct export_operations xfs_export_operations;
94-
extern const struct xattr_handler *xfs_xattr_handlers[];
9594
extern const struct quotactl_ops xfs_quotactl_operations;
9695

9796
extern void xfs_reinit_percpu_counters(struct xfs_mount *mp);

fs/xfs/xfs_xattr.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,58 @@
1515
#include "xfs_da_btree.h"
1616
#include "xfs_attr.h"
1717
#include "xfs_acl.h"
18+
#include "xfs_log.h"
19+
#include "xfs_xattr.h"
1820

1921
#include <linux/posix_acl_xattr.h>
2022

23+
/*
24+
* Get permission to use log-assisted atomic exchange of file extents.
25+
*
26+
* Callers must not be running any transactions or hold any inode locks, and
27+
* they must release the permission by calling xlog_drop_incompat_feat
28+
* when they're done.
29+
*/
30+
int
31+
xfs_attr_grab_log_assist(
32+
struct xfs_mount *mp)
33+
{
34+
int error = 0;
35+
36+
/*
37+
* Protect ourselves from an idle log clearing the logged xattrs log
38+
* incompat feature bit.
39+
*/
40+
xlog_use_incompat_feat(mp->m_log);
41+
42+
/*
43+
* If log-assisted xattrs are already enabled, the caller can use the
44+
* log assisted swap functions with the log-incompat reference we got.
45+
*/
46+
if (xfs_sb_version_haslogxattrs(&mp->m_sb))
47+
return 0;
48+
49+
/* Enable log-assisted xattrs. */
50+
error = xfs_add_incompat_log_feature(mp,
51+
XFS_SB_FEAT_INCOMPAT_LOG_XATTRS);
52+
if (error)
53+
goto drop_incompat;
54+
55+
xfs_warn_mount(mp, XFS_OPSTATE_WARNED_LARP,
56+
"EXPERIMENTAL logged extended attributes feature in use. Use at your own risk!");
57+
58+
return 0;
59+
drop_incompat:
60+
xlog_drop_incompat_feat(mp->m_log);
61+
return error;
62+
}
63+
64+
void
65+
xfs_attr_rele_log_assist(
66+
struct xfs_mount *mp)
67+
{
68+
xlog_drop_incompat_feat(mp->m_log);
69+
}
2170

2271
static int
2372
xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused,

fs/xfs/xfs_xattr.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2000-2005 Silicon Graphics, Inc.
4+
* All Rights Reserved.
5+
*/
6+
#ifndef __XFS_XATTR_H__
7+
#define __XFS_XATTR_H__
8+
9+
int xfs_attr_grab_log_assist(struct xfs_mount *mp);
10+
void xfs_attr_rele_log_assist(struct xfs_mount *mp);
11+
12+
extern const struct xattr_handler *xfs_xattr_handlers[];
13+
14+
#endif /* __XFS_XATTR_H__ */

0 commit comments

Comments
 (0)