From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Tal Zussman <tz2294@columbia.edu>,
David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 07/10] btrfs: use folios for reading super blocks from the block device
Date: Mon, 7 Sep 2026 16:21:08 +0930 [thread overview]
Message-ID: <4e2f0f90-0dd1-490d-bbb4-2bcde430b2e0@gmx.com> (raw)
In-Reply-To: <20260906-btrfs-folio-conversions-v1-7-834b9d7b06f5@columbia.edu>
在 2026/9/7 07:59, Tal Zussman 写道:
> btrfs_read_disk_super() and the zoned super block log comparison go
> through read_cache_page_gfp() and page_address(), and
> btrfs_release_disk_super() recovers the page with virt_to_page(). Use
> mapping_read_folio_gfp(), folio_address(), and virt_to_folio() instead.
> This removes the last callers of read_cache_page_gfp() and put_page()
> in btrfs.
>
> Compute the super block address with offset_in_folio() as
> write_dev_supers() does, rather than assuming it is at the start of
> the page.
>
> Assisted-by: Claude:claude-fable-5-1
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/volumes.c | 16 +++++++---------
> fs/btrfs/zoned.c | 12 ++++++------
> 2 files changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 949e40baff33..4ddabadc9188 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1327,16 +1327,14 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
>
> void btrfs_release_disk_super(struct btrfs_super_block *super)
> {
> - struct page *page = virt_to_page(super);
> -
> - put_page(page);
> + folio_put(virt_to_folio(super));
> }
>
> struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,
> int copy_num, bool drop_cache)
> {
> struct btrfs_super_block *super;
> - struct page *page;
> + struct folio *folio;
> u64 bytenr, bytenr_orig;
> struct address_space *mapping = bdev->bd_mapping;
> int ret;
> @@ -1357,7 +1355,7 @@ struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,
> ASSERT(copy_num == 0);
>
> /*
> - * Drop the page of the primary superblock, so later read will
> + * Drop the folio of the primary superblock, so later read will
> * always read from the device.
> */
> invalidate_inode_pages2_range(mapping, bytenr >> PAGE_SHIFT,
> @@ -1365,12 +1363,12 @@ struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,
> }
>
> filemap_invalidate_lock_shared(mapping);
> - page = read_cache_page_gfp(mapping, bytenr >> PAGE_SHIFT, GFP_NOFS);
> + folio = mapping_read_folio_gfp(mapping, bytenr >> PAGE_SHIFT, GFP_NOFS);
> filemap_invalidate_unlock_shared(mapping);
> - if (IS_ERR(page))
> - return ERR_CAST(page);
> + if (IS_ERR(folio))
> + return ERR_CAST(folio);
>
> - super = page_address(page);
> + super = folio_address(folio) + offset_in_folio(folio, bytenr);
> if (btrfs_super_magic(super) != BTRFS_MAGIC ||
> btrfs_super_bytenr(super) != bytenr_orig) {
> btrfs_release_disk_super(super);
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index 08a15465a087..a1ef8caaacda 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -123,24 +123,24 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
> } else if (full[0] && full[1]) {
> /* Compare two super blocks */
> struct address_space *mapping = bdev->bd_mapping;
> - struct page *page[BTRFS_NR_SB_LOG_ZONES];
> struct btrfs_super_block *super[BTRFS_NR_SB_LOG_ZONES];
>
> for (int i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++) {
> u64 zone_end = (zones[i].start + zones[i].capacity) << SECTOR_SHIFT;
> u64 bytenr = ALIGN_DOWN(zone_end, BTRFS_SUPER_INFO_SIZE) -
> BTRFS_SUPER_INFO_SIZE;
> + struct folio *folio;
>
> filemap_invalidate_lock_shared(mapping);
> - page[i] = read_cache_page_gfp(mapping,
> - bytenr >> PAGE_SHIFT, GFP_NOFS);
> + folio = mapping_read_folio_gfp(mapping, bytenr >> PAGE_SHIFT,
> + GFP_NOFS);
> filemap_invalidate_unlock_shared(mapping);
> - if (IS_ERR(page[i])) {
> + if (IS_ERR(folio)) {
> if (i == 1)
> btrfs_release_disk_super(super[0]);
> - return PTR_ERR(page[i]);
> + return PTR_ERR(folio);
> }
> - super[i] = page_address(page[i]);
> + super[i] = folio_address(folio) + offset_in_folio(folio, bytenr);
> }
>
> if (btrfs_super_generation(super[0]) >
>
next prev parent reply other threads:[~2026-09-07 6:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 22:29 [PATCH 00/10] btrfs: convert some struct page users to folios Tal Zussman
2026-09-06 22:29 ` [PATCH 01/10] btrfs: tests: rename process_page_range() to process_folio_range() Tal Zussman
2026-09-07 6:30 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 02/10] btrfs: tests: convert test_find_delalloc() to use folios Tal Zussman
2026-09-07 6:29 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 03/10] btrfs: tests: use eb folio helpers in extent buffer memory checks Tal Zussman
2026-09-07 6:33 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 04/10] btrfs: convert btrfs_compr_pool_scan() to use folios Tal Zussman
2026-09-07 6:36 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 05/10] btrfs: convert heuristic_collect_sample() " Tal Zussman
2026-09-07 6:44 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 06/10] btrfs: fix stale function references in compression comments Tal Zussman
2026-09-07 6:44 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 07/10] btrfs: use folios for reading super blocks from the block device Tal Zussman
2026-09-07 6:51 ` Qu Wenruo [this message]
2026-09-06 22:29 ` [PATCH 08/10] btrfs: keep the free space cache inode mapping at order 0 Tal Zussman
2026-09-06 23:10 ` Qu Wenruo
2026-09-06 22:29 ` [PATCH 09/10] btrfs: convert struct btrfs_io_ctl to use folios Tal Zussman
2026-09-06 22:29 ` [PATCH 10/10] btrfs: rename io_ctl page helpers to folio helpers Tal Zussman
2026-09-06 23:12 ` Qu Wenruo
2026-09-06 23:20 ` Tal Zussman
2026-09-07 0:23 ` Qu Wenruo
2026-09-07 0:58 ` Tal Zussman
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=4e2f0f90-0dd1-490d-bbb4-2bcde430b2e0@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@kernel.org \
--cc=tz2294@columbia.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
all inboxes | Powered by JetHome®