From: Pankaj Raghav <p.raghav@samsung.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: David Sterba <dsterba@suse.com>, <linux-fsdevel@vger.kernel.org>,
Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
<ntfs3@lists.linux.dev>, Theodore Tso <tytso@mit.edu>,
Jan Kara <jack@suse.com>, <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 3/7] affs: Convert data read and write to use folios
Date: Thu, 13 Jul 2023 12:36:02 +0200 [thread overview]
Message-ID: <98e30ed3-e9b1-2869-b31e-32b099ef3865@samsung.com> (raw)
In-Reply-To: <20230713035512.4139457-4-willy@infradead.org>
On 2023-07-13 05:55, Matthew Wilcox (Oracle) wrote:
> We still need to convert to/from folios in write_begin & write_end
> to fit the API, but this removes a lot of calls to old page-based
> functions, removing many hidden calls to compound_head().
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good to me except one minor nit!
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
> @@ -624,25 +623,23 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
> return PTR_ERR(bh);
> }
>
> -static int
> -affs_read_folio_ofs(struct file *file, struct folio *folio)
> +static int affs_read_folio_ofs(struct file *file, struct folio *folio)
> {
> - struct page *page = &folio->page;
> - struct inode *inode = page->mapping->host;
> - u32 to;
> + struct inode *inode = folio->mapping->host;
> + size_t to;
> int err;
>
> - pr_debug("%s(%lu, %ld)\n", __func__, inode->i_ino, page->index);
> - to = PAGE_SIZE;
> - if (((page->index + 1) << PAGE_SHIFT) > inode->i_size) {
> - to = inode->i_size & ~PAGE_MASK;
> - memset(page_address(page) + to, 0, PAGE_SIZE - to);
> + pr_debug("%s(%lu, %ld)\n", __func__, inode->i_ino, folio->index);
> + to = folio_size(folio);
> + if (folio_pos(folio) + to > inode->i_size) {
> + to = inode->i_size - folio_pos(folio);
> + folio_zero_segment(folio, to, folio_size(folio));
This change makes the code more readable!
> }
>
> - err = affs_do_readpage_ofs(page, to, 0);
> + err = affs_do_read_folio_ofs(folio, to, 0);
> if (!err)
> @@ -688,6 +686,7 @@ static int affs_write_end_ofs(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 super_block *sb = inode->i_sb;
> struct buffer_head *bh, *prev_bh;
> @@ -701,18 +700,18 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
> to = from + len;
> /*
> * XXX: not sure if this can handle short copies (len < copied), but
> - * we don't have to, because the page should always be uptodate here,
> + * we don't have to, because the folio should always be uptodate here,
> * due to write_begin.
> */
>
> pr_debug("%s(%lu, %llu, %llu)\n", __func__, inode->i_ino, pos,
> pos + len);
> bsize = AFFS_SB(sb)->s_data_blksize;
> - data = page_address(page);
> + data = folio_address(folio);
>
> bh = NULL;
> written = 0;
> - tmp = (page->index << PAGE_SHIFT) + from;
> + tmp = (folio->index << PAGE_SHIFT) + from;
Can this be made to:
tmp = folio_pos(folio) + from;
Similar to what is being done in affs_do_read_folio_ofs()
> bidx = tmp / bsize;
> boff = tmp % bsize;
> if (boff) {
> @@ -804,11 +803,11 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
> from += tmp;
> bidx++;
> }
> - SetPageUptodate(page);
> + folio_mark_uptodate(folio);
>
> done:
> affs_brelse(bh);
> - tmp = (page->index << PAGE_SHIFT) + from;
> + tmp = (folio->index << PAGE_SHIFT) + from;
Same as the previous comment.
> if (tmp > inode->i_size)
> inode->i_size = AFFS_I(inode)->mmu_private = tmp;
>
> @@ -819,8 +818,8 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
> }
>
> err_first_bh:
> - unlock_page(page);
> - put_page(page);
> + folio_unlock(folio);
> + folio_put(folio);
>
> return written;
>
next prev parent reply other threads:[~2023-07-13 10:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 3:55 [PATCH 0/7] More filesystem folio conversions for 6.6 Matthew Wilcox (Oracle)
2023-07-13 3:55 ` [PATCH 1/7] highmem: Add memcpy_to_folio() and memcpy_from_folio() Matthew Wilcox (Oracle)
2023-07-22 0:06 ` Andreas Grünbacher
2023-07-13 3:55 ` [PATCH 2/7] affs: Convert affs_symlink_read_folio() to use the folio Matthew Wilcox (Oracle)
2023-07-21 16:50 ` David Sterba
2023-07-13 3:55 ` [PATCH 3/7] affs: Convert data read and write to use folios Matthew Wilcox (Oracle)
2023-07-13 10:36 ` Pankaj Raghav [this message]
2023-07-21 16:51 ` David Sterba
2023-07-13 3:55 ` [PATCH 4/7] migrate: Use folio_set_bh() instead of set_bh_page() Matthew Wilcox (Oracle)
2023-07-31 14:44 ` Jan Kara
2023-07-13 3:55 ` [PATCH 5/7] ntfs3: Convert ntfs_get_block_vbo() to use a folio Matthew Wilcox (Oracle)
2023-07-13 3:55 ` [PATCH 6/7] jbd2: Use a folio in jbd2_journal_write_metadata_buffer() Matthew Wilcox (Oracle)
2023-07-31 14:43 ` Jan Kara
2023-07-13 3:55 ` [PATCH 7/7] buffer: Remove set_bh_page() Matthew Wilcox (Oracle)
2023-07-31 14:46 ` Jan Kara
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=98e30ed3-e9b1-2869-b31e-32b099ef3865@samsung.com \
--to=p.raghav@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=dsterba@suse.com \
--cc=jack@suse.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
--cc=tytso@mit.edu \
--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;
as well as URLs for NNTP newsgroup(s).