1 ext4: add ext4_should_use_dax()
3 From: Ross Zwisler <ross.zwisler@linux.intel.com>
5 This helper, in the spirit of ext4_should_dioread_nolock() et al., replaces
6 the complex conditional in ext4_set_inode_flags().
8 Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 Reviewed-by: Jan Kara <jack@suse.cz>
12 fs/ext4/inode.c | 19 ++++++++++++++++---
13 1 file changed, 16 insertions(+), 3 deletions(-)
15 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
16 index 3207333..525dd63 100644
19 @@ -4577,6 +4577,21 @@ int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
20 !ext4_test_inode_state(inode, EXT4_STATE_XATTR));
23 +static bool ext4_should_use_dax(struct inode *inode)
25 + if (!test_opt(inode->i_sb, DAX))
27 + if (!S_ISREG(inode->i_mode))
29 + if (ext4_should_journal_data(inode))
31 + if (ext4_has_inline_data(inode))
33 + if (ext4_encrypted_inode(inode))
38 void ext4_set_inode_flags(struct inode *inode)
40 unsigned int flags = EXT4_I(inode)->i_flags;
41 @@ -4592,9 +4607,7 @@ void ext4_set_inode_flags(struct inode *inode)
43 if (flags & EXT4_DIRSYNC_FL)
45 - if (test_opt(inode->i_sb, DAX) && S_ISREG(inode->i_mode) &&
46 - !ext4_should_journal_data(inode) && !ext4_has_inline_data(inode) &&
47 - !ext4_encrypted_inode(inode))
48 + if (ext4_should_use_dax(inode))
50 inode_set_flags(inode, new_fl,
51 S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX);