Skip to content

Commit efc2efe

Browse files
Darrick J. Wongdchinner
authored andcommitted
xfs: move xfs_attr_use_log_assist usage out of libxfs
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 sets up logged xattr updates out of libxfs and into xfs_xattr.c so that libxfs no longer has to know about xlog_* functions. 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 d9c61cc commit efc2efe

File tree

6 files changed

+39
-19
lines changed

6 files changed

+39
-19
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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_grab_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-
xfs_attr_rele_log_assist(mp);
11061096
return error;
11071097

11081098
out_trans_cancel:

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* they must release the permission by calling xlog_drop_incompat_feat
2828
* when they're done.
2929
*/
30-
int
30+
static inline int
3131
xfs_attr_grab_log_assist(
3232
struct xfs_mount *mp)
3333
{
@@ -61,13 +61,41 @@ xfs_attr_grab_log_assist(
6161
return error;
6262
}
6363

64-
void
64+
static inline void
6565
xfs_attr_rele_log_assist(
6666
struct xfs_mount *mp)
6767
{
6868
xlog_drop_incompat_feat(mp->m_log);
6969
}
7070

71+
/*
72+
* Set or remove an xattr, having grabbed the appropriate logging resources
73+
* prior to calling libxfs.
74+
*/
75+
int
76+
xfs_attr_change(
77+
struct xfs_da_args *args)
78+
{
79+
struct xfs_mount *mp = args->dp->i_mount;
80+
bool use_logging = false;
81+
int error;
82+
83+
if (xfs_has_larp(mp)) {
84+
error = xfs_attr_grab_log_assist(mp);
85+
if (error)
86+
return error;
87+
88+
use_logging = true;
89+
}
90+
91+
error = xfs_attr_set(args);
92+
93+
if (use_logging)
94+
xfs_attr_rele_log_assist(mp);
95+
return error;
96+
}
97+
98+
7199
static int
72100
xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused,
73101
struct inode *inode, const char *name, void *value, size_t size)
@@ -105,7 +133,7 @@ xfs_xattr_set(const struct xattr_handler *handler,
105133
};
106134
int error;
107135

108-
error = xfs_attr_set(&args);
136+
error = xfs_attr_change(&args);
109137
if (!error && (handler->flags & XFS_ATTR_ROOT))
110138
xfs_forget_acl(inode, name);
111139
return error;

fs/xfs/xfs_xattr.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
#ifndef __XFS_XATTR_H__
77
#define __XFS_XATTR_H__
88

9-
int xfs_attr_grab_log_assist(struct xfs_mount *mp);
10-
void xfs_attr_rele_log_assist(struct xfs_mount *mp);
9+
int xfs_attr_change(struct xfs_da_args *args);
1110

1211
extern const struct xattr_handler *xfs_xattr_handlers[];
1312

0 commit comments

Comments
 (0)