]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs: uninline inode_maybe_inc_iversion()
authorAndrew Morton <akpm@linux-foundation.org>
Fri, 9 Sep 2022 20:57:41 +0000 (13:57 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 3 Oct 2022 21:21:43 +0000 (14:21 -0700)
It has many callsites and is large.

   text    data     bss     dec     hex filename
  91796   15984     512  108292   1a704 mm/shmem.o-before
  91180   15984     512  107676   1a49c mm/shmem.o-after

Acked-by: Jeff Layton <jlayton@kernel.org>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/libfs.c
include/linux/iversion.h

index 31b0ddf01c31daca6a946c48c78b5d821034e0c0..682d56345a1cfeb3977e9d66b00017540f7fb492 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/mutex.h>
 #include <linux/namei.h>
 #include <linux/exportfs.h>
+#include <linux/iversion.h>
 #include <linux/writeback.h>
 #include <linux/buffer_head.h> /* sync_mapping_buffers */
 #include <linux/fs_context.h>
@@ -1520,3 +1521,48 @@ void generic_set_encrypted_ci_d_ops(struct dentry *dentry)
 #endif
 }
 EXPORT_SYMBOL(generic_set_encrypted_ci_d_ops);
+
+/**
+ * inode_maybe_inc_iversion - increments i_version
+ * @inode: inode with the i_version that should be updated
+ * @force: increment the counter even if it's not necessary?
+ *
+ * Every time the inode is modified, the i_version field must be seen to have
+ * changed by any observer.
+ *
+ * If "force" is set or the QUERIED flag is set, then ensure that we increment
+ * the value, and clear the queried flag.
+ *
+ * In the common case where neither is set, then we can return "false" without
+ * updating i_version.
+ *
+ * If this function returns false, and no other metadata has changed, then we
+ * can avoid logging the metadata.
+ */
+bool inode_maybe_inc_iversion(struct inode *inode, bool force)
+{
+       u64 cur, new;
+
+       /*
+        * The i_version field is not strictly ordered with any other inode
+        * information, but the legacy inode_inc_iversion code used a spinlock
+        * to serialize increments.
+        *
+        * Here, we add full memory barriers to ensure that any de-facto
+        * ordering with other info is preserved.
+        *
+        * This barrier pairs with the barrier in inode_query_iversion()
+        */
+       smp_mb();
+       cur = inode_peek_iversion_raw(inode);
+       do {
+               /* If flag is clear then we needn't do anything */
+               if (!force && !(cur & I_VERSION_QUERIED))
+                       return false;
+
+               /* Since lowest bit is flag, add 2 to avoid it */
+               new = (cur & ~I_VERSION_QUERIED) + I_VERSION_INCREMENT;
+       } while (!atomic64_try_cmpxchg(&inode->i_version, &cur, new));
+       return true;
+}
+EXPORT_SYMBOL(inode_maybe_inc_iversion);
index eb5a158101693d9b99be02b2d8d27e5d2e26f934..e27bd4f55d840e656a0aa81bd0240a721f147ad8 100644 (file)
@@ -172,51 +172,7 @@ inode_set_iversion_queried(struct inode *inode, u64 val)
                                I_VERSION_QUERIED);
 }
 
-/**
- * inode_maybe_inc_iversion - increments i_version
- * @inode: inode with the i_version that should be updated
- * @force: increment the counter even if it's not necessary?
- *
- * Every time the inode is modified, the i_version field must be seen to have
- * changed by any observer.
- *
- * If "force" is set or the QUERIED flag is set, then ensure that we increment
- * the value, and clear the queried flag.
- *
- * In the common case where neither is set, then we can return "false" without
- * updating i_version.
- *
- * If this function returns false, and no other metadata has changed, then we
- * can avoid logging the metadata.
- */
-static inline bool
-inode_maybe_inc_iversion(struct inode *inode, bool force)
-{
-       u64 cur, new;
-
-       /*
-        * The i_version field is not strictly ordered with any other inode
-        * information, but the legacy inode_inc_iversion code used a spinlock
-        * to serialize increments.
-        *
-        * Here, we add full memory barriers to ensure that any de-facto
-        * ordering with other info is preserved.
-        *
-        * This barrier pairs with the barrier in inode_query_iversion()
-        */
-       smp_mb();
-       cur = inode_peek_iversion_raw(inode);
-       do {
-               /* If flag is clear then we needn't do anything */
-               if (!force && !(cur & I_VERSION_QUERIED))
-                       return false;
-
-               /* Since lowest bit is flag, add 2 to avoid it */
-               new = (cur & ~I_VERSION_QUERIED) + I_VERSION_INCREMENT;
-       } while (!atomic64_try_cmpxchg(&inode->i_version, &cur, new));
-       return true;
-}
-
+bool inode_maybe_inc_iversion(struct inode *inode, bool force);
 
 /**
  * inode_inc_iversion - forcibly increment i_version