Message ID | 20240420025029.2166544-3-willy@infradead.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/30] btrfs: Use a folio in wait_dev_supers() | expand |
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
On Sat, Apr 20, 2024 at 03:49:57AM +0100, Matthew Wilcox (Oracle) wrote: > @@ -3812,8 +3814,7 @@ static int write_dev_supers(struct btrfs_device *device, > bio->bi_iter.bi_sector = bytenr >> SECTOR_SHIFT; > bio->bi_private = device; > bio->bi_end_io = btrfs_end_super_write; > - __bio_add_page(bio, page, BTRFS_SUPER_INFO_SIZE, > - offset_in_page(bytenr)); > + bio_add_folio_nofail(bio, folio, BTRFS_SUPER_INFO_SIZE, offset); Compilation fails when btrfs is built as a module, bio_add_folio_nofail() is not exported. I can keep __bio_add_page() and the conversion can be done later.
On Thu, Apr 25, 2024 at 04:44:03PM +0200, David Sterba wrote: > On Sat, Apr 20, 2024 at 03:49:57AM +0100, Matthew Wilcox (Oracle) wrote: > > @@ -3812,8 +3814,7 @@ static int write_dev_supers(struct btrfs_device *device, > > bio->bi_iter.bi_sector = bytenr >> SECTOR_SHIFT; > > bio->bi_private = device; > > bio->bi_end_io = btrfs_end_super_write; > > - __bio_add_page(bio, page, BTRFS_SUPER_INFO_SIZE, > > - offset_in_page(bytenr)); > > + bio_add_folio_nofail(bio, folio, BTRFS_SUPER_INFO_SIZE, offset); > > Compilation fails when btrfs is built as a module, bio_add_folio_nofail() > is not exported. I can keep __bio_add_page() and the conversion can be > done later. I'd rather you added the obvious patch I just sent ... (please don't get me stuck in the infinite loop of "you can't export a symbol without any users" "you can't add a user until this is exported")
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 32cf64ccd761..8fa7c526093c 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3760,9 +3760,10 @@ static int write_dev_supers(struct btrfs_device *device, shash->tfm = fs_info->csum_shash; for (i = 0; i < max_mirrors; i++) { - struct page *page; + struct folio *folio; struct bio *bio; struct btrfs_super_block *disk_super; + size_t offset; bytenr_orig = btrfs_sb_offset(i); ret = btrfs_sb_log_location(device, i, WRITE, &bytenr); @@ -3785,9 +3786,9 @@ static int write_dev_supers(struct btrfs_device *device, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE, sb->csum); - page = find_or_create_page(mapping, bytenr >> PAGE_SHIFT, - GFP_NOFS); - if (!page) { + folio = __filemap_get_folio(mapping, bytenr >> PAGE_SHIFT, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, GFP_NOFS); + if (IS_ERR(folio)) { btrfs_err(device->fs_info, "couldn't get super block page for bytenr %llu", bytenr); @@ -3796,9 +3797,10 @@ static int write_dev_supers(struct btrfs_device *device, } /* Bump the refcount for wait_dev_supers() */ - get_page(page); + folio_get(folio); - disk_super = page_address(page); + offset = offset_in_folio(folio, bytenr); + disk_super = folio_address(folio) + offset; memcpy(disk_super, sb, BTRFS_SUPER_INFO_SIZE); /* @@ -3812,8 +3814,7 @@ static int write_dev_supers(struct btrfs_device *device, bio->bi_iter.bi_sector = bytenr >> SECTOR_SHIFT; bio->bi_private = device; bio->bi_end_io = btrfs_end_super_write; - __bio_add_page(bio, page, BTRFS_SUPER_INFO_SIZE, - offset_in_page(bytenr)); + bio_add_folio_nofail(bio, folio, BTRFS_SUPER_INFO_SIZE, offset); /* * We FUA only the first super block. The others we allow to
Remove some calls to obsolete APIs and some hidden calls to compound_head(). Cc: Chris Mason <clm@fb.com> Cc: Josef Bacik <josef@toxicpanda.com> Cc: David Sterba <dsterba@suse.com> Cc: linux-btrfs@vger.kernel.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- fs/btrfs/disk-io.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)