From 09f7929f8770a49bae8e8995555319ebf3817554 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 12 Oct 2017 12:11:58 -0400 Subject: [PATCH] add patch add-ext4_should_use_dax --- add-ext4_should_use_dax | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ series | 1 + timestamps | 8 ++++--- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 add-ext4_should_use_dax diff --git a/add-ext4_should_use_dax b/add-ext4_should_use_dax new file mode 100644 index 00000000..c5c07c54 --- /dev/null +++ b/add-ext4_should_use_dax @@ -0,0 +1,55 @@ +ext4: add ext4_should_use_dax() + +From: Ross Zwisler + +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 +Signed-off-by: Theodore Ts'o +Reviewed-by: Jan Kara +--- + fs/ext4/inode.c | 19 ++++++++++++++++--- + 1 file changed, 16 insertions(+), 3 deletions(-) + +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c +index 3207333..525dd63 100644 +--- a/fs/ext4/inode.c ++++ b/fs/ext4/inode.c +@@ -4577,6 +4577,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; +@@ -4592,9 +4607,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); +-- +2.9.5 + + diff --git a/series b/series index b0094574..69926616 100644 --- a/series +++ b/series @@ -10,6 +10,7 @@ fix-fallocate-and-delalloc-i_size-interaction prevent-data-corruption-with-inline-data-and-dax prevent-data-corruption-with-journaling-and-dax add-sanity-check-for-encryption-and-dax +add-ext4_should_use_dax #################################################### # unstable patches diff --git a/timestamps b/timestamps index b215e23a..eea98f0c 100755 --- a/timestamps +++ b/timestamps @@ -42,6 +42,8 @@ touch -d @1507345855 stable-boundary touch -d @1507823554 prevent-data-corruption-with-inline-data-and-dax touch -d @1507823648 prevent-data-corruption-with-journaling-and-dax touch -d @1507823885 add-sanity-check-for-encryption-and-dax -touch -d @1507823904 series -touch -d @1507823907 status -touch -d @1507823913 timestamps +touch -d @1507824041 series +touch -d @1507824059 add-ext4_should_use_dax +touch -d @1507824064 status +touch -d @1507824588 remove-duplicate-extended-attributes-defs +touch -d @1507824661 timestamps -- 2.11.4.GIT