diff options
| author | Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com> | 2019-02-10 23:53:21 -0500 |
|---|---|---|
| committer | Theodore Ts'o <tytso@mit.edu> | 2019-02-10 23:53:21 -0500 |
| commit | a297b2fcee461e40df763e179cbbfba5a9e572d2 (patch) | |
| tree | b15dfad165f70a7b360b2d94676e2842f9d9cf0b | |
| parent | 16e08b14a4550bb167c48e918b26ef0d4980e9d1 (diff) | |
ext4: unlock unused_pages timely when doing writeback
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>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
| -rw-r--r-- | fs/ext4/inode.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index dd4641f3cdb9..9c3402ec85bc 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
| @@ -2829,12 +2829,12 @@ retry: | |||
| 2829 | goto unplug; | 2829 | goto unplug; |
| 2830 | } | 2830 | } |
| 2831 | ret = mpage_prepare_extent_to_map(&mpd); | 2831 | ret = mpage_prepare_extent_to_map(&mpd); |
| 2832 | /* Unlock pages we didn't use */ | ||
| 2833 | mpage_release_unused_pages(&mpd, false); | ||
| 2832 | /* Submit prepared bio */ | 2834 | /* Submit prepared bio */ |
| 2833 | ext4_io_submit(&mpd.io_submit); | 2835 | ext4_io_submit(&mpd.io_submit); |
| 2834 | ext4_put_io_end_defer(mpd.io_submit.io_end); | 2836 | ext4_put_io_end_defer(mpd.io_submit.io_end); |
| 2835 | mpd.io_submit.io_end = NULL; | 2837 | mpd.io_submit.io_end = NULL; |
| 2836 | /* Unlock pages we didn't use */ | ||
| 2837 | mpage_release_unused_pages(&mpd, false); | ||
| 2838 | if (ret < 0) | 2838 | if (ret < 0) |
| 2839 | goto unplug; | 2839 | goto unplug; |
| 2840 | 2840 | ||
| @@ -2902,10 +2902,11 @@ retry: | |||
| 2902 | handle = NULL; | 2902 | handle = NULL; |
| 2903 | mpd.do_map = 0; | 2903 | mpd.do_map = 0; |
| 2904 | } | 2904 | } |
| 2905 | /* Submit prepared bio */ | ||
| 2906 | ext4_io_submit(&mpd.io_submit); | ||
| 2907 | /* Unlock pages we didn't use */ | 2905 | /* Unlock pages we didn't use */ |
| 2908 | mpage_release_unused_pages(&mpd, give_up_on_write); | 2906 | mpage_release_unused_pages(&mpd, give_up_on_write); |
| 2907 | /* Submit prepared bio */ | ||
| 2908 | ext4_io_submit(&mpd.io_submit); | ||
| 2909 | |||
| 2909 | /* | 2910 | /* |
| 2910 | * Drop our io_end reference we got from init. We have | 2911 | * Drop our io_end reference we got from init. We have |
| 2911 | * to be careful and use deferred io_end finishing if | 2912 | * to be careful and use deferred io_end finishing if |
