xfs: move xfs_attr_use_log_assist out of xfs_log.c
authorDarrick J. Wong <djwong@kernel.org>
Fri, 27 May 2022 00:33:29 +0000 (10:33 +1000)
committerDave Chinner <david@fromorbit.com>
Fri, 27 May 2022 00:33:29 +0000 (10:33 +1000)
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>
fs/xfs/libxfs/xfs_attr.c
fs/xfs/xfs_log.c
fs/xfs/xfs_super.c
fs/xfs/xfs_super.h
fs/xfs/xfs_xattr.c
fs/xfs/xfs_xattr.h [new file with mode: 0644]

index 9f14aca29ec40921e30f1c93dad3edcd5e285201..24fa213715c11ae1861d6b7e18a2561473556e86 100644 (file)
@@ -25,7 +25,7 @@
 #include "xfs_trans_space.h"
 #include "xfs_trace.h"
 #include "xfs_attr_item.h"
-#include "xfs_log.h"
+#include "xfs_xattr.h"
 
 struct kmem_cache              *xfs_attr_intent_cache;
 
@@ -1028,7 +1028,7 @@ xfs_attr_set(
        }
 
        if (use_logging) {
-               error = xfs_attr_use_log_assist(mp);
+               error = xfs_attr_grab_log_assist(mp);
                if (error)
                        return error;
        }
@@ -1102,7 +1102,7 @@ out_unlock:
        xfs_iunlock(dp, XFS_ILOCK_EXCL);
 drop_incompat:
        if (use_logging)
-               xlog_drop_incompat_feat(mp->m_log);
+               xfs_attr_rele_log_assist(mp);
        return error;
 
 out_trans_cancel:
index a75f4ffc75f99be2ff09241311be66bb70b94f9a..1e972f884a812c831384ba05855ae99ef002b559 100644 (file)
@@ -3877,44 +3877,3 @@ xlog_drop_incompat_feat(
 {
        up_read(&log->l_incompat_users);
 }
-
-/*
- * Get permission to use log-assisted atomic exchange of file extents.
- *
- * Callers must not be running any transactions or hold any inode locks, and
- * they must release the permission by calling xlog_drop_incompat_feat
- * when they're done.
- */
-int
-xfs_attr_use_log_assist(
-       struct xfs_mount        *mp)
-{
-       int                     error = 0;
-
-       /*
-        * Protect ourselves from an idle log clearing the logged xattrs log
-        * incompat feature bit.
-        */
-       xlog_use_incompat_feat(mp->m_log);
-
-       /*
-        * If log-assisted xattrs are already enabled, the caller can use the
-        * log assisted swap functions with the log-incompat reference we got.
-        */
-       if (xfs_sb_version_haslogxattrs(&mp->m_sb))
-               return 0;
-
-       /* Enable log-assisted xattrs. */
-       error = xfs_add_incompat_log_feature(mp,
-                       XFS_SB_FEAT_INCOMPAT_LOG_XATTRS);
-       if (error)
-               goto drop_incompat;
-
-       xfs_warn_mount(mp, XFS_OPSTATE_WARNED_LARP,
- "EXPERIMENTAL logged extended attributes feature in use. Use at your own risk!");
-
-       return 0;
-drop_incompat:
-       xlog_drop_incompat_feat(mp->m_log);
-       return error;
-}
index 51ce127a0cc6308ff9c3b7e6e0f83923257ace31..a6e7b4176faf1f8cc701a6b8d59c20cab0fae968 100644 (file)
@@ -39,6 +39,7 @@
 #include "xfs_ag.h"
 #include "xfs_defer.h"
 #include "xfs_attr_item.h"
+#include "xfs_xattr.h"
 
 #include <linux/magic.h>
 #include <linux/fs_context.h>
index 167d23f92ffe5aff8c98e4a0012b09846140bc61..3cd5a51bace13f9ee93bc5b0537692e4f4fe008f 100644 (file)
@@ -91,7 +91,6 @@ extern xfs_agnumber_t xfs_set_inode_alloc(struct xfs_mount *,
                                           xfs_agnumber_t agcount);
 
 extern const struct export_operations xfs_export_operations;
-extern const struct xattr_handler *xfs_xattr_handlers[];
 extern const struct quotactl_ops xfs_quotactl_operations;
 
 extern void xfs_reinit_percpu_counters(struct xfs_mount *mp);
index 7a044afd4c468b9807d19c78302abf998f11fccf..fc6acf7021a78414757193a9861a178aec078926 100644 (file)
 #include "xfs_da_btree.h"
 #include "xfs_attr.h"
 #include "xfs_acl.h"
+#include "xfs_log.h"
+#include "xfs_xattr.h"
 
 #include <linux/posix_acl_xattr.h>
 
+/*
+ * Get permission to use log-assisted atomic exchange of file extents.
+ *
+ * Callers must not be running any transactions or hold any inode locks, and
+ * they must release the permission by calling xlog_drop_incompat_feat
+ * when they're done.
+ */
+int
+xfs_attr_grab_log_assist(
+       struct xfs_mount        *mp)
+{
+       int                     error = 0;
+
+       /*
+        * Protect ourselves from an idle log clearing the logged xattrs log
+        * incompat feature bit.
+        */
+       xlog_use_incompat_feat(mp->m_log);
+
+       /*
+        * If log-assisted xattrs are already enabled, the caller can use the
+        * log assisted swap functions with the log-incompat reference we got.
+        */
+       if (xfs_sb_version_haslogxattrs(&mp->m_sb))
+               return 0;
+
+       /* Enable log-assisted xattrs. */
+       error = xfs_add_incompat_log_feature(mp,
+                       XFS_SB_FEAT_INCOMPAT_LOG_XATTRS);
+       if (error)
+               goto drop_incompat;
+
+       xfs_warn_mount(mp, XFS_OPSTATE_WARNED_LARP,
+ "EXPERIMENTAL logged extended attributes feature in use. Use at your own risk!");
+
+       return 0;
+drop_incompat:
+       xlog_drop_incompat_feat(mp->m_log);
+       return error;
+}
+
+void
+xfs_attr_rele_log_assist(
+       struct xfs_mount        *mp)
+{
+       xlog_drop_incompat_feat(mp->m_log);
+}
 
 static int
 xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused,
diff --git a/fs/xfs/xfs_xattr.h b/fs/xfs/xfs_xattr.h
new file mode 100644 (file)
index 0000000..d34ef18
--- /dev/null
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ */
+#ifndef __XFS_XATTR_H__
+#define __XFS_XATTR_H__
+
+int xfs_attr_grab_log_assist(struct xfs_mount *mp);
+void xfs_attr_rele_log_assist(struct xfs_mount *mp);
+
+extern const struct xattr_handler *xfs_xattr_handlers[];
+
+#endif /* __XFS_XATTR_H__ */