From 070424c965da48c56f35ed9504834fa3f9bb5c41 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 5 Sep 2016 23:29:21 -0400 Subject: [PATCH] add patch cleanup-ext4_sync_parent --- cleanup-ext4_sync_parent | 42 ++++++++++++++++++++++++++++++++++++++++++ series | 1 + timestamps | 7 ++++--- 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 cleanup-ext4_sync_parent diff --git a/cleanup-ext4_sync_parent b/cleanup-ext4_sync_parent new file mode 100644 index 00000000..db1134a8 --- /dev/null +++ b/cleanup-ext4_sync_parent @@ -0,0 +1,42 @@ +ext4: cleanup ext4_sync_parent() + +From: Jan Kara + +A condition !hlist_empty(&inode->i_dentry) is always true for open file. +Just remove it. Also ext4_sync_parent() could use some explanation why +races with rmdir() are not an issue - add a comment explaining that. + +Reported-by: Al Viro +Signed-off-by: Jan Kara +Signed-off-by: Theodore Ts'o +--- + fs/ext4/fsync.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c +index 5c43725..88effb1 100644 +--- a/fs/ext4/fsync.c ++++ b/fs/ext4/fsync.c +@@ -61,6 +61,13 @@ static int ext4_sync_parent(struct inode *inode) + break; + iput(inode); + inode = next; ++ /* ++ * The directory inode may have gone through rmdir by now. But ++ * the inode itself and its blocks are still allocated (we hold ++ * a reference to the inode so it didn't go through ++ * ext4_evict_inode()) and so we are safe to flush metadata ++ * blocks and the inode. ++ */ + ret = sync_mapping_buffers(inode->i_mapping); + if (ret) + break; +@@ -107,7 +114,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) + + if (!journal) { + ret = __generic_file_fsync(file, start, end, datasync); +- if (!ret && !hlist_empty(&inode->i_dentry)) ++ if (!ret) + ret = ext4_sync_parent(inode); + if (test_opt(inode->i_sb, BARRIER)) + goto issue_flush; diff --git a/series b/series index ff371998..558824bd 100644 --- a/series +++ b/series @@ -13,6 +13,7 @@ mbcache-fix-to-detect-failure-of-register_shrinker reinforce-check-of-i_dtime-when-clearing-high-uid-gid-fields enable-quota-enforcement-based-on-mount-options remove-old-feature-helpers +cleanup-ext4_sync_parent ########################################## # unstable patches diff --git a/timestamps b/timestamps index bec8f2a5..d5a8512d 100755 --- a/timestamps +++ b/timestamps @@ -52,6 +52,7 @@ touch -d @1472658276 mbcache-fix-to-detect-failure-of-register_shrinker touch -d @1473130570 reinforce-check-of-i_dtime-when-clearing-high-uid-gid-fields touch -d @1473131296 enable-quota-enforcement-based-on-mount-options touch -d @1473131518 remove-old-feature-helpers -touch -d @1473131544 series -touch -d @1473131549 status -touch -d @1473131854 timestamps +touch -d @1473131882 series +touch -d @1473132103 cleanup-ext4_sync_parent +touch -d @1473132103 status +touch -d @1473132553 timestamps -- 2.11.4.GIT