All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: unlock unused_pages timely when doing writeback
@ 2019-01-29  2:05 Xiaoguang Wang
  2019-02-11  4:54 ` Theodore Y. Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaoguang Wang @ 2019-01-29  2:05 UTC (permalink / raw)
  To: linux-ext4; +Cc: Xiaoguang Wang

In mpage_add_bh_to_extent(), when accumulated extents length is greater
than MAX_WRITEPAGES_EXTENT_LEN or buffer head's b_stat is not equal, we
will not continue to search unmapped area for this page, but note this
page is locked, and will only be unlocked in mpage_release_unused_pages()
after ext4_io_submit, if io also is throttled by blk-throttle or similar
io qos, we will hold this page locked for a while, it's unnecessary.

I think the best fix is to refactor mpage_add_bh_to_extent() to let it
return some hints whether to unlock this page, but given that we will
improve dioread_nolock later, we can let it done later, so currently
the simple fix would just call mpage_release_unused_pages() before
ext4_io_submit().

Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
---
 fs/ext4/inode.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 34d7e0703cc6..83a0d7c76736 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2836,12 +2836,12 @@ static int ext4_writepages(struct address_space *mapping,
 		goto unplug;
 	}
 	ret = mpage_prepare_extent_to_map(&mpd);
+	/* Unlock pages we didn't use */
+	mpage_release_unused_pages(&mpd, false);
 	/* Submit prepared bio */
 	ext4_io_submit(&mpd.io_submit);
 	ext4_put_io_end_defer(mpd.io_submit.io_end);
 	mpd.io_submit.io_end = NULL;
-	/* Unlock pages we didn't use */
-	mpage_release_unused_pages(&mpd, false);
 	if (ret < 0)
 		goto unplug;
 
@@ -2909,10 +2909,11 @@ static int ext4_writepages(struct address_space *mapping,
 			handle = NULL;
 			mpd.do_map = 0;
 		}
-		/* Submit prepared bio */
-		ext4_io_submit(&mpd.io_submit);
 		/* Unlock pages we didn't use */
 		mpage_release_unused_pages(&mpd, give_up_on_write);
+		/* Submit prepared bio */
+		ext4_io_submit(&mpd.io_submit);
+
 		/*
 		 * Drop our io_end reference we got from init. We have
 		 * to be careful and use deferred io_end finishing if
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext4: unlock unused_pages timely when doing writeback
  2019-01-29  2:05 [PATCH] ext4: unlock unused_pages timely when doing writeback Xiaoguang Wang
@ 2019-02-11  4:54 ` Theodore Y. Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Y. Ts'o @ 2019-02-11  4:54 UTC (permalink / raw)
  To: Xiaoguang Wang; +Cc: linux-ext4

On Tue, Jan 29, 2019 at 10:05:31AM +0800, Xiaoguang Wang wrote:
> In mpage_add_bh_to_extent(), when accumulated extents length is greater
> than MAX_WRITEPAGES_EXTENT_LEN or buffer head's b_stat is not equal, we
> will not continue to search unmapped area for this page, but note this
> page is locked, and will only be unlocked in mpage_release_unused_pages()
> after ext4_io_submit, if io also is throttled by blk-throttle or similar
> io qos, we will hold this page locked for a while, it's unnecessary.
> 
> I think the best fix is to refactor mpage_add_bh_to_extent() to let it
> return some hints whether to unlock this page, but given that we will
> improve dioread_nolock later, we can let it done later, so currently
> the simple fix would just call mpage_release_unused_pages() before
> ext4_io_submit().
> 
> Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>

Thanks, applied.

					- Ted

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-11  4:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29  2:05 [PATCH] ext4: unlock unused_pages timely when doing writeback Xiaoguang Wang
2019-02-11  4:54 ` Theodore Y. Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.