From: Lukas Czerner <lczerner@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: Lukas Czerner <lczerner@redhat.com>
Subject: [PATCH 2/2] ext4: Wait for existing dio workers in ext4_alloc_file_blocks()
Date: Tue, 9 Jun 2015 08:58:46 +0200 [thread overview]
Message-ID: <1433833126-28575-2-git-send-email-lczerner@redhat.com> (raw)
In-Reply-To: <1433833126-28575-1-git-send-email-lczerner@redhat.com>
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 <lczerner@redhat.com>
---
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
next prev parent reply other threads:[~2015-06-09 6:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 6:58 [PATCH 1/2] ext4: Recalculate journal credits as inode depth changes Lukas Czerner
2015-06-09 6:58 ` Lukas Czerner [this message]
2015-06-15 4:25 ` [PATCH 2/2] ext4: Wait for existing dio workers in ext4_alloc_file_blocks() Theodore Ts'o
2015-06-15 4:22 ` [PATCH 1/2] ext4: Recalculate journal credits as inode depth changes Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433833126-28575-2-git-send-email-lczerner@redhat.com \
--to=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).