summary refs log tree commit diff
path: root/fs/xfs/xfs_xattr.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-05-27 10:34:04 +1000
committerDave Chinner <david@fromorbit.com>2022-05-27 10:34:04 +1000
commitefc2efeba169ff37bbd425631985064365c614e0 (patch)
tree302a3de693f7a871fd4c883007c8ff491c9434bd /fs/xfs/xfs_xattr.c
parentd9c61ccb3b09d8f892cccbf662ce0c870f8e4ade (diff)
downloadlinux-efc2efeba169ff37bbd425631985064365c614e0.tar.gz
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>

Diffstat (limited to 'fs/xfs/xfs_xattr.c')
-rw-r--r--fs/xfs/xfs_xattr.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c
index fc6acf7021a7..35e13e125ec6 100644
--- a/fs/xfs/xfs_xattr.c
+++ b/fs/xfs/xfs_xattr.c
@@ -27,7 +27,7 @@
  * they must release the permission by calling xlog_drop_incompat_feat
  * when they're done.
  */
-int
+static inline int
 xfs_attr_grab_log_assist(
 	struct xfs_mount	*mp)
 {
@@ -61,13 +61,41 @@ drop_incompat:
 	return error;
 }
 
-void
+static inline void
 xfs_attr_rele_log_assist(
 	struct xfs_mount	*mp)
 {
 	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
 xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused,
 		struct inode *inode, const char *name, void *value, size_t size)
@@ -105,7 +133,7 @@ xfs_xattr_set(const struct xattr_handler *handler,
 	};
 	int			error;
 
-	error = xfs_attr_set(&args);
+	error = xfs_attr_change(&args);
 	if (!error && (handler->flags & XFS_ATTR_ROOT))
 		xfs_forget_acl(inode, name);
 	return error;