From 4e6a2e14db7271005f2feb043dbc1277283e9c81 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 15 Jun 2015 00:25:15 -0400 Subject: [PATCH] add patch wait-for-existing-dio-workers-in-ext4_alloc_file_blocks --- series | 1 + timestamps | 7 +-- ...-existing-dio-workers-in-ext4_alloc_file_blocks | 52 ++++++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 wait-for-existing-dio-workers-in-ext4_alloc_file_blocks diff --git a/series b/series index 3a925b5f..3f9dd042 100644 --- a/series +++ b/series @@ -49,6 +49,7 @@ use-swap-in-memswap use-swap-in-mext_page_double_lock use_GFP_NOFS_in_jbd2_cleanup_journal_tail recalculate-journal-credits-as-inode-depth-changes +wait-for-existing-dio-workers-in-ext4_alloc_file_blocks ########################################## # unstable patches diff --git a/timestamps b/timestamps index 2e5f927b..49188ab3 100755 --- a/timestamps +++ b/timestamps @@ -65,6 +65,7 @@ touch -d @1434335672 use-swap-in-memswap touch -d @1434341049 use-swap-in-mext_page_double_lock touch -d @1434341882 use_GFP_NOFS_in_jbd2_cleanup_journal_tail touch -d @1434342046 recalculate-journal-credits-as-inode-depth-changes -touch -d @1434342154 series -touch -d @1434342158 status -touch -d @1434342251 timestamps +touch -d @1434342233 wait-for-existing-dio-workers-in-ext4_alloc_file_blocks +touch -d @1434342268 series +touch -d @1434342272 status +touch -d @1434342305 timestamps diff --git a/wait-for-existing-dio-workers-in-ext4_alloc_file_blocks b/wait-for-existing-dio-workers-in-ext4_alloc_file_blocks new file mode 100644 index 00000000..b65e808d --- /dev/null +++ b/wait-for-existing-dio-workers-in-ext4_alloc_file_blocks @@ -0,0 +1,52 @@ +ext4: wait for existing dio workers in ext4_alloc_file_blocks() + +From: Lukas Czerner + +Currently existing dio workers can jump in and potentially increase +extent tree depth while we're allocating blocks in +ext4_alloc_file_blocks(). This may cause us to underestimate the +number of credits needed for the transaction because the extent tree +depth can change after our estimation. + +Fix this by waiting for all the existing dio workers in the same way +as we do it in ext4_punch_hole. We've seen errors caused by this in +xfstest generic/299, however it's really hard to reproduce. + +Signed-off-by: Lukas Czerner +Signed-off-by: Theodore Ts'o +--- + fs/ext4/extents.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c +index 13c5ebf..a5f7322 100644 +--- a/fs/ext4/extents.c ++++ b/fs/ext4/extents.c +@@ -4678,6 +4678,10 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, + if (len <= EXT_UNWRITTEN_MAX_LEN) + flags |= EXT4_GET_BLOCKS_NO_NORMALIZE; + ++ /* Wait all existing dio workers, newcomers will block on i_mutex */ ++ ext4_inode_block_unlocked_dio(inode); ++ inode_dio_wait(inode); ++ + /* + * credits to insert 1 extent into extent tree + */ +@@ -4741,6 +4745,8 @@ retry: + goto retry; + } + ++ ext4_inode_resume_unlocked_dio(inode); ++ + return ret > 0 ? ret2 : ret; + } + +-- +1.8.3.1 + +-- +To unsubscribe from this list: send the line "unsubscribe linux-ext4" in +the body of a message to majordomo@vger.kernel.org +More majordomo info at http://vger.kernel.org/majordomo-info.html + -- 2.11.4.GIT