aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Zwisler <ross.zwisler@linux.intel.com>2017-10-12 12:00:59 -0400
committerTheodore Ts'o <tytso@mit.edu>2017-10-12 12:00:59 -0400
commit6642586b3e5f9e0b559d20352d8d42ad84224d1f (patch)
tree215de3257712900bb4dd31c14c2da31d044f0507
parent7d3e06a8dae893a0df2777543980dc62eff61b59 (diff)
ext4: add ext4_should_use_dax()
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>
-rw-r--r--fs/ext4/inode.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 350e0910ed32..9f836e2ec18c 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4610,6 +4610,21 @@ int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
4610 !ext4_test_inode_state(inode, EXT4_STATE_XATTR)); 4610 !ext4_test_inode_state(inode, EXT4_STATE_XATTR));
4611} 4611}
4612 4612
4613static bool ext4_should_use_dax(struct inode *inode)
4614{
4615 if (!test_opt(inode->i_sb, DAX))
4616 return false;
4617 if (!S_ISREG(inode->i_mode))
4618 return false;
4619 if (ext4_should_journal_data(inode))
4620 return false;
4621 if (ext4_has_inline_data(inode))
4622 return false;
4623 if (ext4_encrypted_inode(inode))
4624 return false;
4625 return true;
4626}
4627
4613void ext4_set_inode_flags(struct inode *inode) 4628void ext4_set_inode_flags(struct inode *inode)
4614{ 4629{
4615 unsigned int flags = EXT4_I(inode)->i_flags; 4630 unsigned int flags = EXT4_I(inode)->i_flags;
@@ -4625,9 +4640,7 @@ void ext4_set_inode_flags(struct inode *inode)
4625 new_fl |= S_NOATIME; 4640 new_fl |= S_NOATIME;
4626 if (flags & EXT4_DIRSYNC_FL) 4641 if (flags & EXT4_DIRSYNC_FL)
4627 new_fl |= S_DIRSYNC; 4642 new_fl |= S_DIRSYNC;
4628 if (test_opt(inode->i_sb, DAX) && S_ISREG(inode->i_mode) && 4643 if (ext4_should_use_dax(inode))
4629 !ext4_should_journal_data(inode) && !ext4_has_inline_data(inode) &&
4630 !ext4_encrypted_inode(inode))
4631 new_fl |= S_DAX; 4644 new_fl |= S_DAX;
4632 inode_set_flags(inode, new_fl, 4645 inode_set_flags(inode, new_fl,
4633 S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX); 4646 S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX);