From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: "Theodore Tso" <tytso@mit.edu>,
Andreas Dilger <adilger.kernel@dilger.ca>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 05/31] ext4: Convert ext4_writepage() to use a folio
Date: Thu, 26 Jan 2023 20:23:49 +0000 [thread overview]
Message-ID: <20230126202415.1682629-6-willy@infradead.org> (raw)
In-Reply-To: <20230126202415.1682629-1-willy@infradead.org>
Prepare for multi-page folios and save some instructions by converting
to the folio API.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ext4/inode.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index b8b3e2e0d9fd..8e3d2cca1e0c 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2027,26 +2027,25 @@ static int ext4_writepage(struct page *page,
trace_ext4_writepage(page);
size = i_size_read(inode);
- if (page->index == size >> PAGE_SHIFT &&
+ len = folio_size(folio);
+ if (folio_pos(folio) + len > size &&
!ext4_verity_in_progress(inode))
- len = size & ~PAGE_MASK;
- else
- len = PAGE_SIZE;
+ len = size - folio_pos(folio);
+ page_bufs = folio_buffers(folio);
/* Should never happen but for bugs in other kernel subsystems */
- if (!page_has_buffers(page)) {
+ if (!page_bufs) {
ext4_warning_inode(inode,
- "page %lu does not have buffers attached", page->index);
- ClearPageDirty(page);
- unlock_page(page);
+ "page %lu does not have buffers attached", folio->index);
+ folio_clear_dirty(folio);
+ folio_unlock(folio);
return 0;
}
- page_bufs = page_buffers(page);
/*
* We cannot do block allocation or other extent handling in this
* function. If there are buffers needing that, we have to redirty
- * the page. But we may reach here when we do a journal commit via
+ * the folio. But we may reach here when we do a journal commit via
* journal_submit_inode_data_buffers() and in that case we must write
* allocated buffers to achieve data=ordered mode guarantees.
*
@@ -2062,7 +2061,7 @@ static int ext4_writepage(struct page *page,
*/
if (ext4_walk_page_buffers(NULL, inode, page_bufs, 0, len, NULL,
ext4_bh_delay_or_unwritten)) {
- redirty_page_for_writepage(wbc, page);
+ folio_redirty_for_writepage(wbc, folio);
if ((current->flags & PF_MEMALLOC) ||
(inode->i_sb->s_blocksize == PAGE_SIZE)) {
/*
@@ -2072,12 +2071,12 @@ static int ext4_writepage(struct page *page,
*/
WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD))
== PF_MEMALLOC);
- unlock_page(page);
+ folio_unlock(folio);
return 0;
}
}
- if (PageChecked(page) && ext4_should_journal_data(inode))
+ if (folio_test_checked(folio) && ext4_should_journal_data(inode))
/*
* It's mmapped pagecache. Add buffers and journal it. There
* doesn't seem much point in redirtying the page here.
@@ -2087,8 +2086,8 @@ static int ext4_writepage(struct page *page,
ext4_io_submit_init(&io_submit, wbc);
io_submit.io_end = ext4_init_io_end(inode, GFP_NOFS);
if (!io_submit.io_end) {
- redirty_page_for_writepage(wbc, page);
- unlock_page(page);
+ folio_redirty_for_writepage(wbc, folio);
+ folio_unlock(folio);
return -ENOMEM;
}
ret = ext4_bio_write_page(&io_submit, page, len);
--
2.35.1
next prev parent reply other threads:[~2023-01-26 20:25 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 20:23 [PATCH 00/31] Convert most of ext4 to folios Matthew Wilcox (Oracle)
2023-01-26 20:23 ` [PATCH 01/31] fs: Add FGP_WRITEBEGIN Matthew Wilcox (Oracle)
2023-03-05 8:53 ` Ritesh Harjani
2023-03-14 22:00 ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 02/31] fscrypt: Add some folio helper functions Matthew Wilcox (Oracle)
2023-01-27 3:02 ` Eric Biggers
2023-01-27 16:13 ` Matthew Wilcox
2023-01-27 16:21 ` Eric Biggers
2023-01-27 16:37 ` Matthew Wilcox
2023-03-14 22:05 ` Theodore Ts'o
2023-03-14 23:12 ` Eric Biggers
2023-03-15 2:53 ` Theodore Ts'o
2023-03-05 9:06 ` Ritesh Harjani
2023-01-26 20:23 ` [PATCH 03/31] ext4: Convert ext4_bio_write_page() to use a folio Matthew Wilcox (Oracle)
2023-01-28 16:53 ` kernel test robot
2023-01-28 19:07 ` kernel test robot
2023-03-05 11:18 ` Ritesh Harjani
2023-03-14 22:07 ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 04/31] ext4: Convert ext4_finish_bio() to use folios Matthew Wilcox (Oracle)
2023-03-06 9:10 ` Ritesh Harjani
2023-03-23 3:26 ` Matthew Wilcox
2023-03-23 14:51 ` Darrick J. Wong
2023-03-23 15:30 ` Matthew Wilcox
2023-03-27 0:58 ` Christoph Hellwig
2023-03-27 0:57 ` Christoph Hellwig
2023-03-14 22:08 ` Theodore Ts'o
2023-01-26 20:23 ` Matthew Wilcox (Oracle) [this message]
2023-03-06 18:45 ` [PATCH 05/31] ext4: Convert ext4_writepage() to use a folio Ritesh Harjani
2023-03-14 22:26 ` Theodore Ts'o
2023-03-23 3:29 ` Matthew Wilcox
2023-01-26 20:23 ` [PATCH 06/31] ext4: Turn mpage_process_page() into mpage_process_folio() Matthew Wilcox (Oracle)
2023-03-14 22:27 ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 07/31] ext4: Convert mpage_submit_page() to mpage_submit_folio() Matthew Wilcox (Oracle)
2023-03-14 22:28 ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 08/31] ext4: Convert ext4_bio_write_page() to ext4_bio_write_folio() Matthew Wilcox (Oracle)
2023-03-14 22:31 ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 09/31] ext4: Convert ext4_readpage_inline() to take a folio Matthew Wilcox (Oracle)
2023-03-14 22:31 ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 10/31] ext4: Convert ext4_convert_inline_data_to_extent() to use " Matthew Wilcox (Oracle)
2023-03-14 22:36 ` Theodore Ts'o
2023-03-23 17:14 ` Matthew Wilcox
2023-01-26 20:23 ` [PATCH 11/31] ext4: Convert ext4_try_to_write_inline_data() " Matthew Wilcox (Oracle)
2023-03-14 22:37 ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 12/31] ext4: Convert ext4_da_convert_inline_data_to_extent() " Matthew Wilcox (Oracle)
2023-01-26 20:23 ` [PATCH 13/31] ext4: Convert ext4_da_write_inline_data_begin() " Matthew Wilcox (Oracle)
2023-01-26 20:23 ` [PATCH 14/31] ext4: Convert ext4_read_inline_page() to ext4_read_inline_folio() Matthew Wilcox (Oracle)
2023-03-14 22:38 ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 15/31] ext4: Convert ext4_write_inline_data_end() to use a folio Matthew Wilcox (Oracle)
2023-03-14 22:39 ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 16/31] ext4: Convert ext4_write_begin() " Matthew Wilcox (Oracle)
2023-03-14 22:40 ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 17/31] ext4: Convert ext4_write_end() " Matthew Wilcox (Oracle)
2023-03-14 22:41 ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 18/31] ext4: Use a folio in ext4_journalled_write_end() Matthew Wilcox (Oracle)
2023-03-14 22:41 ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 19/31] ext4: Convert ext4_journalled_zero_new_buffers() to use a folio Matthew Wilcox (Oracle)
2023-03-14 22:46 ` Theodore Ts'o
2023-03-24 4:15 ` Matthew Wilcox
2023-01-26 20:24 ` [PATCH 20/31] ext4: Convert __ext4_block_zero_page_range() " Matthew Wilcox (Oracle)
2023-03-05 12:26 ` Ritesh Harjani
2023-01-26 20:24 ` [PATCH 21/31] ext4: Convert __ext4_journalled_writepage() to take " Matthew Wilcox (Oracle)
2023-03-14 22:47 ` Theodore Ts'o
2023-03-24 4:55 ` Matthew Wilcox
2023-01-26 20:24 ` [PATCH 22/31] ext4: Convert ext4_page_nomap_can_writeout() " Matthew Wilcox (Oracle)
2023-03-14 22:50 ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 23/31] ext4: Use a folio in ext4_da_write_begin() Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 24/31] ext4: Convert ext4_mpage_readpages() to work on folios Matthew Wilcox (Oracle)
2023-01-27 4:15 ` Eric Biggers
2023-01-27 16:08 ` Matthew Wilcox
2023-03-05 11:26 ` Ritesh Harjani
2023-01-26 20:24 ` [PATCH 25/31] ext4: Convert ext4_block_write_begin() to take a folio Matthew Wilcox (Oracle)
2023-03-06 6:51 ` Ritesh Harjani
2023-03-06 8:27 ` Matthew Wilcox
2023-03-06 15:21 ` Ritesh Harjani
2023-03-15 4:40 ` Matthew Wilcox
2023-03-15 14:57 ` Ritesh Harjani
2023-01-26 20:24 ` [PATCH 26/31] ext4: Convert ext4_writepage() " Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 27/31] ext4: Use a folio in ext4_page_mkwrite() Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 28/31] ext4: Use a folio iterator in __read_end_io() Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 29/31] ext4: Convert mext_page_mkuptodate() to take a folio Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 30/31] ext4: Convert pagecache_read() to use " Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 31/31] ext4: Use a folio in ext4_read_merkle_tree_page Matthew Wilcox (Oracle)
2023-03-15 17:57 ` [PATCH 00/31] Convert most of ext4 to folios 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=20230126202415.1682629-6-willy@infradead.org \
--to=willy@infradead.org \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@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).