Skip to content

Commit 9fed2c0

Browse files
jtlaytonbrauner
authored andcommitted
fs: reduce pointer chasing in is_mgtime() test
The is_mgtime test checks whether the FS_MGTIME flag is set in the fstype. To get there from the inode though, we have to dereference 3 pointers. Add a new IOP_MGTIME flag, and have inode_init_always() set that flag when the fstype flag is set. Then, make is_mgtime test for IOP_MGTIME instead. Signed-off-by: Jeff Layton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent b40508c commit 9fed2c0

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

fs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
241241
inode->i_opflags = 0;
242242
if (sb->s_xattr)
243243
inode->i_opflags |= IOP_XATTR;
244+
if (sb->s_type->fs_flags & FS_MGTIME)
245+
inode->i_opflags |= IOP_MGTIME;
244246
i_uid_write(inode, 0);
245247
i_gid_write(inode, 0);
246248
atomic_set(&inode->i_writecount, 0);

include/linux/fs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ is_uncached_acl(struct posix_acl *acl)
623623
#define IOP_NOFOLLOW 0x0004
624624
#define IOP_XATTR 0x0008
625625
#define IOP_DEFAULT_READLINK 0x0010
626+
#define IOP_MGTIME 0x0020
626627

627628
/*
628629
* Keep mostly read-only and often accessed (especially for
@@ -2581,7 +2582,7 @@ struct file_system_type {
25812582
*/
25822583
static inline bool is_mgtime(const struct inode *inode)
25832584
{
2584-
return inode->i_sb->s_type->fs_flags & FS_MGTIME;
2585+
return inode->i_opflags & IOP_MGTIME;
25852586
}
25862587

25872588
extern struct dentry *mount_bdev(struct file_system_type *fs_type,

0 commit comments

Comments
 (0)