Commit efc2efeb authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Dave Chinner

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: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent d9c61ccb
...@@ -982,7 +982,6 @@ xfs_attr_set( ...@@ -982,7 +982,6 @@ xfs_attr_set(
int error, local; int error, local;
int rmt_blks = 0; int rmt_blks = 0;
unsigned int total; unsigned int total;
bool use_logging = xfs_has_larp(mp);
if (xfs_is_shutdown(dp->i_mount)) if (xfs_is_shutdown(dp->i_mount))
return -EIO; return -EIO;
...@@ -1027,12 +1026,6 @@ xfs_attr_set( ...@@ -1027,12 +1026,6 @@ xfs_attr_set(
rmt_blks = xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX); rmt_blks = xfs_attr3_rmt_blocks(mp, XFS_XATTR_SIZE_MAX);
} }
if (use_logging) {
error = xfs_attr_grab_log_assist(mp);
if (error)
return error;
}
/* /*
* Root fork attributes can use reserved data blocks for this * Root fork attributes can use reserved data blocks for this
* operation if necessary * operation if necessary
...@@ -1040,7 +1033,7 @@ xfs_attr_set( ...@@ -1040,7 +1033,7 @@ xfs_attr_set(
xfs_init_attr_trans(args, &tres, &total); xfs_init_attr_trans(args, &tres, &total);
error = xfs_trans_alloc_inode(dp, &tres, total, 0, rsvd, &args->trans); error = xfs_trans_alloc_inode(dp, &tres, total, 0, rsvd, &args->trans);
if (error) if (error)
goto drop_incompat; return error;
if (args->value || xfs_inode_hasattr(dp)) { if (args->value || xfs_inode_hasattr(dp)) {
error = xfs_iext_count_may_overflow(dp, XFS_ATTR_FORK, error = xfs_iext_count_may_overflow(dp, XFS_ATTR_FORK,
...@@ -1100,9 +1093,6 @@ xfs_attr_set( ...@@ -1100,9 +1093,6 @@ xfs_attr_set(
error = xfs_trans_commit(args->trans); error = xfs_trans_commit(args->trans);
out_unlock: out_unlock:
xfs_iunlock(dp, XFS_ILOCK_EXCL); xfs_iunlock(dp, XFS_ILOCK_EXCL);
drop_incompat:
if (use_logging)
xfs_attr_rele_log_assist(mp);
return error; return error;
out_trans_cancel: out_trans_cancel:
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_acl.h" #include "xfs_acl.h"
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_xattr.h"
#include <linux/posix_acl_xattr.h> #include <linux/posix_acl_xattr.h>
...@@ -202,7 +203,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) ...@@ -202,7 +203,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
xfs_acl_to_disk(args.value, acl); xfs_acl_to_disk(args.value, acl);
} }
error = xfs_attr_set(&args); error = xfs_attr_change(&args);
kmem_free(args.value); kmem_free(args.value);
/* /*
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "xfs_health.h" #include "xfs_health.h"
#include "xfs_reflink.h" #include "xfs_reflink.h"
#include "xfs_ioctl.h" #include "xfs_ioctl.h"
#include "xfs_xattr.h"
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/namei.h> #include <linux/namei.h>
...@@ -524,7 +525,7 @@ xfs_attrmulti_attr_set( ...@@ -524,7 +525,7 @@ xfs_attrmulti_attr_set(
args.valuelen = len; args.valuelen = len;
} }
error = xfs_attr_set(&args); error = xfs_attr_change(&args);
if (!error && (flags & XFS_IOC_ATTR_ROOT)) if (!error && (flags & XFS_IOC_ATTR_ROOT))
xfs_forget_acl(inode, name); xfs_forget_acl(inode, name);
kfree(args.value); kfree(args.value);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "xfs_iomap.h" #include "xfs_iomap.h"
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_ioctl.h" #include "xfs_ioctl.h"
#include "xfs_xattr.h"
#include <linux/posix_acl.h> #include <linux/posix_acl.h>
#include <linux/security.h> #include <linux/security.h>
...@@ -61,7 +62,7 @@ xfs_initxattrs( ...@@ -61,7 +62,7 @@ xfs_initxattrs(
.value = xattr->value, .value = xattr->value,
.valuelen = xattr->value_len, .valuelen = xattr->value_len,
}; };
error = xfs_attr_set(&args); error = xfs_attr_change(&args);
if (error < 0) if (error < 0)
break; break;
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* they must release the permission by calling xlog_drop_incompat_feat * they must release the permission by calling xlog_drop_incompat_feat
* when they're done. * when they're done.
*/ */
int static inline int
xfs_attr_grab_log_assist( xfs_attr_grab_log_assist(
struct xfs_mount *mp) struct xfs_mount *mp)
{ {
...@@ -61,13 +61,41 @@ xfs_attr_grab_log_assist( ...@@ -61,13 +61,41 @@ xfs_attr_grab_log_assist(
return error; return error;
} }
void static inline void
xfs_attr_rele_log_assist( xfs_attr_rele_log_assist(
struct xfs_mount *mp) struct xfs_mount *mp)
{ {
xlog_drop_incompat_feat(mp->m_log); xlog_drop_incompat_feat(mp->m_log);
} }
/*
* Set or remove an xattr, having grabbed the appropriate logging resources
* prior to calling libxfs.
*/
int
xfs_attr_change(
struct xfs_da_args *args)
{
struct xfs_mount *mp = args->dp->i_mount;
bool use_logging = false;
int error;
if (xfs_has_larp(mp)) {
error = xfs_attr_grab_log_assist(mp);
if (error)
return error;
use_logging = true;
}
error = xfs_attr_set(args);
if (use_logging)
xfs_attr_rele_log_assist(mp);
return error;
}
static int static int
xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused,
struct inode *inode, const char *name, void *value, size_t size) struct inode *inode, const char *name, void *value, size_t size)
...@@ -105,7 +133,7 @@ xfs_xattr_set(const struct xattr_handler *handler, ...@@ -105,7 +133,7 @@ xfs_xattr_set(const struct xattr_handler *handler,
}; };
int error; int error;
error = xfs_attr_set(&args); error = xfs_attr_change(&args);
if (!error && (handler->flags & XFS_ATTR_ROOT)) if (!error && (handler->flags & XFS_ATTR_ROOT))
xfs_forget_acl(inode, name); xfs_forget_acl(inode, name);
return error; return error;
......
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
#ifndef __XFS_XATTR_H__ #ifndef __XFS_XATTR_H__
#define __XFS_XATTR_H__ #define __XFS_XATTR_H__
int xfs_attr_grab_log_assist(struct xfs_mount *mp); int xfs_attr_change(struct xfs_da_args *args);
void xfs_attr_rele_log_assist(struct xfs_mount *mp);
extern const struct xattr_handler *xfs_xattr_handlers[]; extern const struct xattr_handler *xfs_xattr_handlers[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment