From: Zhihao Cheng <chengzhihao1@huawei.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Richard Weinberger <richard@nod.at>
Cc: <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH 09/15] ubifs: Convert ubifs_write_end() to use a folio
Date: Tue, 23 Jan 2024 12:39:26 +0800 [thread overview]
Message-ID: <cb68632e-e813-4c42-0cdc-b68f92a01604@huawei.com> (raw)
In-Reply-To: <20240120230824.2619716-10-willy@infradead.org>
在 2024/1/21 7:08, Matthew Wilcox (Oracle) 写道:
> Convert the incoming page pointer to a folio and use it throughout,
> saving several calls to compound_head(). Also remove some PAGE_SIZE
> assumptions.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> fs/ubifs/file.c | 41 +++++++++++++++++++++--------------------
> 1 file changed, 21 insertions(+), 20 deletions(-)
>
> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index ef262499f228..52027b4feebf 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -532,6 +532,7 @@ static int ubifs_write_end(struct file *file, struct address_space *mapping,
> loff_t pos, unsigned len, unsigned copied,
> struct page *page, void *fsdata)
> {
> + struct folio *folio = page_folio(page);
> struct inode *inode = mapping->host;
> struct ubifs_inode *ui = ubifs_inode(inode);
> struct ubifs_info *c = inode->i_sb->s_fs_info;
> @@ -539,47 +540,47 @@ static int ubifs_write_end(struct file *file, struct address_space *mapping,
> int appending = !!(end_pos > inode->i_size);
>
> dbg_gen("ino %lu, pos %llu, pg %lu, len %u, copied %d, i_size %lld",
> - inode->i_ino, pos, page->index, len, copied, inode->i_size);
> + inode->i_ino, pos, folio->index, len, copied, inode->i_size);
>
> - if (unlikely(copied < len && len == PAGE_SIZE)) {
> + if (unlikely(copied < len && !folio_test_uptodate(folio))) {
> /*
> - * VFS copied less data to the page that it intended and
> + * VFS copied less data to the folio than it intended and
> * declared in its '->write_begin()' call via the @len
> - * argument. If the page was not up-to-date, and @len was
> - * @PAGE_SIZE, the 'ubifs_write_begin()' function did
> + * argument. If the folio was not up-to-date,
> + * the 'ubifs_write_begin()' function did
> * not load it from the media (for optimization reasons). This
> - * means that part of the page contains garbage. So read the
> - * page now.
> + * means that part of the folio contains garbage. So read the
> + * folio now.
> */
> dbg_gen("copied %d instead of %d, read page and repeat",
> copied, len);
> - cancel_budget(c, page, ui, appending);
> - ClearPageChecked(page);
> + cancel_budget(c, &folio->page, ui, appending);
> + folio_clear_checked(folio);
>
> /*
> * Return 0 to force VFS to repeat the whole operation, or the
> * error code if 'do_readpage()' fails.
> */
> - copied = do_readpage(page);
> + copied = do_readpage(&folio->page);
> goto out;
> }
>
> - if (len == PAGE_SIZE)
> - SetPageUptodate(page);
> + if (len >= folio_size(folio))
> + folio_mark_uptodate(folio);
So I think 'len == folio_size(folio)' is right? Since len is passed from
'bytes' which is recalculated after write_begin:
if (bytes > folio_size(folio) - offset)
bytes = folio_size(folio) - offset;
The 'len' can't be greater than folio_size.
>
> - if (!PagePrivate(page)) {
> - attach_page_private(page, (void *)1);
> + if (!folio->private) {
> + folio_attach_private(folio, (void *)1);
> atomic_long_inc(&c->dirty_pg_cnt);
> - __set_page_dirty_nobuffers(page);
> + filemap_dirty_folio(mapping, folio);
> }
>
> if (appending) {
> i_size_write(inode, end_pos);
> ui->ui_size = end_pos;
> /*
> - * Note, we do not set @I_DIRTY_PAGES (which means that the
> - * inode has dirty pages), this has been done in
> - * '__set_page_dirty_nobuffers()'.
> + * We do not set @I_DIRTY_PAGES (which means that
> + * the inode has dirty pages), this was done in
> + * filemap_dirty_folio().
> */
> __mark_inode_dirty(inode, I_DIRTY_DATASYNC);
> ubifs_assert(c, mutex_is_locked(&ui->ui_mutex));
> @@ -587,8 +588,8 @@ static int ubifs_write_end(struct file *file, struct address_space *mapping,
> }
>
> out:
> - unlock_page(page);
> - put_page(page);
> + folio_unlock(folio);
> + folio_put(folio);
> return copied;
> }
>
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2024-01-23 4:39 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-20 23:08 [PATCH 00/15] ubifs folio conversion Matthew Wilcox (Oracle)
2024-01-20 23:08 ` [PATCH 01/15] ubifs: Set page uptodate in the correct place Matthew Wilcox (Oracle)
2024-01-22 7:22 ` Zhihao Cheng
2024-01-22 14:40 ` Matthew Wilcox
2024-01-23 2:36 ` Zhihao Cheng
2024-01-24 5:01 ` Matthew Wilcox
2024-01-20 23:08 ` [PATCH 02/15] ubifs: Convert from writepage to writepages Matthew Wilcox (Oracle)
2024-01-22 11:31 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 03/15] ubifs: Convert ubifs_writepage to use a folio Matthew Wilcox (Oracle)
2024-01-22 9:27 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 04/15] ubifs: Use a folio in do_truncation() Matthew Wilcox (Oracle)
2024-01-22 9:31 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 05/15] ubifs: Convert do_writepage() to take a folio Matthew Wilcox (Oracle)
2024-01-22 11:31 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 06/15] ubifs: Convert ubifs_vm_page_mkwrite() to use " Matthew Wilcox (Oracle)
2024-01-22 11:38 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 07/15] ubifs: Convert write_begin_slow() " Matthew Wilcox (Oracle)
2024-01-20 23:08 ` [PATCH 08/15] ubifs: Convert ubifs_write_begin() " Matthew Wilcox (Oracle)
2024-01-22 11:51 ` Zhihao Cheng
2024-01-22 14:43 ` Matthew Wilcox
2024-01-23 2:15 ` Zhihao Cheng
2024-01-23 3:07 ` Matthew Wilcox
2024-01-23 4:27 ` Zhihao Cheng
2024-01-23 4:27 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 09/15] ubifs: Convert ubifs_write_end() " Matthew Wilcox (Oracle)
2024-01-23 4:39 ` Zhihao Cheng [this message]
2024-01-20 23:08 ` [PATCH 10/15] ubifs: Convert do_readpage() to take " Matthew Wilcox (Oracle)
2024-01-22 12:09 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 11/15] ubifs: Convert allocate_budget() to work on " Matthew Wilcox (Oracle)
2024-01-22 11:52 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 12/15] ubifs: Convert cancel_budget() to take " Matthew Wilcox (Oracle)
2024-01-22 12:14 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 13/15] ubifs: Pass a folio into ubifs_bulk_read() and ubifs_do_bulk_read() Matthew Wilcox (Oracle)
2024-01-22 12:15 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 14/15] ubifs: Use a folio in ubifs_do_bulk_read() Matthew Wilcox (Oracle)
2024-01-22 12:17 ` Zhihao Cheng
2024-01-20 23:08 ` [PATCH 15/15] ubifs: Convert populate_page() to take a folio Matthew Wilcox (Oracle)
2024-01-22 12:22 ` Zhihao Cheng
2024-01-23 7:33 ` [PATCH 00/15] ubifs folio conversion Richard Weinberger
2024-01-24 5:01 ` Matthew Wilcox
2024-01-25 2:05 ` Zhihao Cheng
2024-02-15 20:46 ` Matthew Wilcox
2024-02-15 20:54 ` Richard Weinberger
2024-02-25 22:13 ` Richard Weinberger
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=cb68632e-e813-4c42-0cdc-b68f92a01604@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=willy@infradead.org \
/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