diff options
author | Jan Kara <jack@suse.cz> | 2023-02-28 08:13:17 +0300 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2023-03-23 17:06:07 +0300 |
commit | eaf2ca10ca4ba450f8e514cb8bfc9149660b57f6 (patch) | |
tree | 59fef0e12b7499b759187d95ab90b183f1154df2 /fs/ext4/inode.c | |
parent | f1496362e9d7b37fe6b8983086c1548a601b5594 (diff) | |
download | linux-eaf2ca10ca4ba450f8e514cb8bfc9149660b57f6.tar.xz |
ext4: Move page unlocking out of mpage_submit_page()
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>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20230228051319.4085470-6-tytso@mit.edu
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index fcaa2a7a27a5..85951da08d60 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; } @@ -2666,14 +2672,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(&folio->page)) { + if (ext4_page_nomap_can_writeout(&folio->page)) err = mpage_submit_page(mpd, &folio->page); - if (err < 0) - goto out; - } else { - folio_unlock(folio); - mpd->first_page += folio_nr_pages(folio); - } + mpage_page_done(mpd, &folio->page); + if (err < 0) + goto out; } else { /* Add all dirty buffers to mpd */ lblk = ((ext4_lblk_t)folio->index) << |