Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: uninline inode_maybe_inc_iversion()

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>

+47 -45
+46
fs/libfs.c
··· 15 15 #include <linux/mutex.h> 16 16 #include <linux/namei.h> 17 17 #include <linux/exportfs.h> 18 + #include <linux/iversion.h> 18 19 #include <linux/writeback.h> 19 20 #include <linux/buffer_head.h> /* sync_mapping_buffers */ 20 21 #include <linux/fs_context.h> ··· 1521 1520 #endif 1522 1521 } 1523 1522 EXPORT_SYMBOL(generic_set_encrypted_ci_d_ops); 1523 + 1524 + /** 1525 + * inode_maybe_inc_iversion - increments i_version 1526 + * @inode: inode with the i_version that should be updated 1527 + * @force: increment the counter even if it's not necessary? 1528 + * 1529 + * Every time the inode is modified, the i_version field must be seen to have 1530 + * changed by any observer. 1531 + * 1532 + * If "force" is set or the QUERIED flag is set, then ensure that we increment 1533 + * the value, and clear the queried flag. 1534 + * 1535 + * In the common case where neither is set, then we can return "false" without 1536 + * updating i_version. 1537 + * 1538 + * If this function returns false, and no other metadata has changed, then we 1539 + * can avoid logging the metadata. 1540 + */ 1541 + bool inode_maybe_inc_iversion(struct inode *inode, bool force) 1542 + { 1543 + u64 cur, new; 1544 + 1545 + /* 1546 + * The i_version field is not strictly ordered with any other inode 1547 + * information, but the legacy inode_inc_iversion code used a spinlock 1548 + * to serialize increments. 1549 + * 1550 + * Here, we add full memory barriers to ensure that any de-facto 1551 + * ordering with other info is preserved. 1552 + * 1553 + * This barrier pairs with the barrier in inode_query_iversion() 1554 + */ 1555 + smp_mb(); 1556 + cur = inode_peek_iversion_raw(inode); 1557 + do { 1558 + /* If flag is clear then we needn't do anything */ 1559 + if (!force && !(cur & I_VERSION_QUERIED)) 1560 + return false; 1561 + 1562 + /* Since lowest bit is flag, add 2 to avoid it */ 1563 + new = (cur & ~I_VERSION_QUERIED) + I_VERSION_INCREMENT; 1564 + } while (!atomic64_try_cmpxchg(&inode->i_version, &cur, new)); 1565 + return true; 1566 + } 1567 + EXPORT_SYMBOL(inode_maybe_inc_iversion);
+1 -45
include/linux/iversion.h
··· 172 172 I_VERSION_QUERIED); 173 173 } 174 174 175 - /** 176 - * inode_maybe_inc_iversion - increments i_version 177 - * @inode: inode with the i_version that should be updated 178 - * @force: increment the counter even if it's not necessary? 179 - * 180 - * Every time the inode is modified, the i_version field must be seen to have 181 - * changed by any observer. 182 - * 183 - * If "force" is set or the QUERIED flag is set, then ensure that we increment 184 - * the value, and clear the queried flag. 185 - * 186 - * In the common case where neither is set, then we can return "false" without 187 - * updating i_version. 188 - * 189 - * If this function returns false, and no other metadata has changed, then we 190 - * can avoid logging the metadata. 191 - */ 192 - static inline bool 193 - inode_maybe_inc_iversion(struct inode *inode, bool force) 194 - { 195 - u64 cur, new; 196 - 197 - /* 198 - * The i_version field is not strictly ordered with any other inode 199 - * information, but the legacy inode_inc_iversion code used a spinlock 200 - * to serialize increments. 201 - * 202 - * Here, we add full memory barriers to ensure that any de-facto 203 - * ordering with other info is preserved. 204 - * 205 - * This barrier pairs with the barrier in inode_query_iversion() 206 - */ 207 - smp_mb(); 208 - cur = inode_peek_iversion_raw(inode); 209 - do { 210 - /* If flag is clear then we needn't do anything */ 211 - if (!force && !(cur & I_VERSION_QUERIED)) 212 - return false; 213 - 214 - /* Since lowest bit is flag, add 2 to avoid it */ 215 - new = (cur & ~I_VERSION_QUERIED) + I_VERSION_INCREMENT; 216 - } while (!atomic64_try_cmpxchg(&inode->i_version, &cur, new)); 217 - return true; 218 - } 219 - 175 + bool inode_maybe_inc_iversion(struct inode *inode, bool force); 220 176 221 177 /** 222 178 * inode_inc_iversion - forcibly increment i_version