]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ext4: add ext4_should_use_dax()
authorRoss Zwisler <ross.zwisler@linux.intel.com>
Thu, 12 Oct 2017 16:00:59 +0000 (12:00 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 12 Oct 2017 16:00:59 +0000 (12:00 -0400)
This helper, in the spirit of ext4_should_dioread_nolock() et al., replaces
the complex conditional in ext4_set_inode_flags().

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>
fs/ext4/inode.c

index 350e0910ed32f9c9cde22bbe70d87e02612a52c8..9f836e2ec18cd21d6ef7178402f828b70a2d39a5 100644 (file)
@@ -4610,6 +4610,21 @@ int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
                !ext4_test_inode_state(inode, EXT4_STATE_XATTR));
 }
 
+static bool ext4_should_use_dax(struct inode *inode)
+{
+       if (!test_opt(inode->i_sb, DAX))
+               return false;
+       if (!S_ISREG(inode->i_mode))
+               return false;
+       if (ext4_should_journal_data(inode))
+               return false;
+       if (ext4_has_inline_data(inode))
+               return false;
+       if (ext4_encrypted_inode(inode))
+               return false;
+       return true;
+}
+
 void ext4_set_inode_flags(struct inode *inode)
 {
        unsigned int flags = EXT4_I(inode)->i_flags;
@@ -4625,9 +4640,7 @@ void ext4_set_inode_flags(struct inode *inode)
                new_fl |= S_NOATIME;
        if (flags & EXT4_DIRSYNC_FL)
                new_fl |= S_DIRSYNC;
-       if (test_opt(inode->i_sb, DAX) && S_ISREG(inode->i_mode) &&
-           !ext4_should_journal_data(inode) && !ext4_has_inline_data(inode) &&
-           !ext4_encrypted_inode(inode))
+       if (ext4_should_use_dax(inode))
                new_fl |= S_DAX;
        inode_set_flags(inode, new_fl,
                        S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX);