From: Jinke Han <[email protected]>
In ext4_writepages, sometimes we leave the bio to next-to-write page for
physic block merge. But if next page no longer continuous, we'd better
submit it immediately.
For extent inode, the chance of physic continuous while logic block not
continuous is very small. If next to write page not continuous and
unmapped, we may gather enough pages for extent and then do block
allocation and mapping for it's extent. Then we try to merge to prev
bio and get failed. For the prev bio, the waiting time is unnecessary.
In that case, we have to flush the prev bio with holding all page locks
of the extent. The submit_bio may be blocked by wbt or getting request
which may take a while. Users also may be waiting for these page locks.
In fast do_map=0 writing mode, we should also end this hopeless waiting
soonner and submit it without any page lock.
Signed-off-by: Jinke Han <[email protected]>
---
Changes in v2:
-fix some spelling errors
fs/ext4/inode.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 601214453c3a..ad7139a835a2 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2608,6 +2608,12 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
if (mpd->map.m_len > 0 && mpd->next_page != page->index)
goto out;
+ /* Submit bio when page no longer continus and
+ * do it before taking other page's lock.
+ */
+ if (mpd->next_page != page->index && mpd->io_submit.io_bio)
+ ext4_io_submit(&mpd->io_submit);
+
lock_page(page);
/*
* If the page is no longer dirty, or its mapping no
--
2.20.1