From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 5/7] ext4: Move page unlocking out of mpage_submit_page()
Date: Wed, 11 Jan 2023 16:43:29 +0100 [thread overview]
Message-ID: <20230111154338.392-5-jack@suse.cz> (raw)
In-Reply-To: <20230111152736.9608-1-jack@suse.cz>
Move page unlocking during page writeback out of mpage_submit_page()
into the callers. This will allow writeback in data=journal mode to keep
the page locked for a bit longer. Since page unlocking it tightly
connected to increment of mpd->first_page (as that determines cleanup of
locked but unwritten pages), move page unlocking as well as
mpd->first_page handling into a helper function.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/inode.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 237880f0d406..28b59e078a1d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2083,6 +2083,12 @@ static int ext4_writepage(struct page *page,
return ret;
}
+static void mpage_page_done(struct mpage_da_data *mpd, struct page *page)
+{
+ mpd->first_page++;
+ unlock_page(page);
+}
+
static int mpage_submit_page(struct mpage_da_data *mpd, struct page *page)
{
int len;
@@ -2111,10 +2117,8 @@ static int mpage_submit_page(struct mpage_da_data *mpd, struct page *page)
else
len = PAGE_SIZE;
err = ext4_bio_write_page(&mpd->io_submit, page, len);
- unlock_page(page);
if (!err)
mpd->wbc->nr_to_write--;
- mpd->first_page++;
return err;
}
@@ -2226,6 +2230,7 @@ static int mpage_process_page_bufs(struct mpage_da_data *mpd,
/* So far everything mapped? Submit the page for IO. */
if (mpd->map.m_len == 0) {
err = mpage_submit_page(mpd, head->b_page);
+ mpage_page_done(mpd, head->b_page);
if (err < 0)
return err;
}
@@ -2357,6 +2362,7 @@ static int mpage_map_and_submit_buffers(struct mpage_da_data *mpd)
goto out;
/* Page fully mapped - let IO run! */
err = mpage_submit_page(mpd, page);
+ mpage_page_done(mpd, page);
if (err < 0)
goto out;
}
@@ -2667,14 +2673,11 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
* modify metadata is simple. Just submit the page.
*/
if (!mpd->can_map) {
- if (ext4_page_nomap_can_writeout(page)) {
+ if (ext4_page_nomap_can_writeout(page))
err = mpage_submit_page(mpd, page);
- if (err < 0)
- goto out;
- } else {
- unlock_page(page);
- mpd->first_page++;
- }
+ mpage_page_done(mpd, page);
+ if (err < 0)
+ goto out;
} else {
/* Add all dirty buffers to mpd */
lblk = ((ext4_lblk_t)page->index) <<
--
2.35.3
next prev parent reply other threads:[~2023-01-11 15:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 15:43 [PATCH 0/7] ext4: Cleanup data=journal writeback path Jan Kara
2023-01-11 15:43 ` [PATCH 1/7] ext4: Update stale comment about write constraints Jan Kara
2023-01-11 15:43 ` [PATCH 2/7] ext4: Use nr_to_write directly in mpage_prepare_extent_to_map() Jan Kara
2023-01-11 15:43 ` [PATCH 3/7] ext4: Mark page for delayed dirtying only if it is pinned Jan Kara
2023-01-11 22:34 ` kernel test robot
2023-01-12 1:36 ` kernel test robot
2023-01-12 2:07 ` kernel test robot
2023-01-12 9:29 ` Jan Kara
2023-01-11 15:43 ` [PATCH 4/7] ext4: Don't unlock page in ext4_bio_write_page() Jan Kara
2023-01-11 15:43 ` Jan Kara [this message]
2023-01-11 15:43 ` [PATCH 6/7] ext4: Move mpage_page_done() calls after error handling Jan Kara
2023-01-11 15:43 ` [PATCH 7/7] ext4: Convert data=journal writeback to use ext4_writepages() Jan Kara
2023-02-19 5:40 ` [PATCH 0/7] ext4: Cleanup data=journal writeback path Theodore Ts'o
-- strict thread matches above, loose matches on Subject: below --
2023-02-28 5:13 [PATCH REBASED " Theodore Ts'o
2023-02-28 5:13 ` [PATCH 5/7] ext4: Move page unlocking out of mpage_submit_page() 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=20230111154338.392-5-jack@suse.cz \
--to=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).