bcache: Use a folio
Subsystems (2)
PATCH 1/1 bcache: Use a folio
From: Matthew Wilcox (Oracle) <[email protected]>
Retrieve a folio from the page cache instead of a page. Removes a hidden call to compound_head(). Then be sure to call folio_put() instead of put_page() to release it. That doesn't save any calls to compound_head(), just moves them around.
--- drivers/md/bcache/super.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/md/bcache/super.c +11 -11
@@ -168,14 +168,14 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev, {const char *err;struct cache_sb_disk *s; -struct page *page; +struct folio *folio;unsigned int i; - page =read_cache_page_gfp (bdev->bd_mapping, -SB_OFFSET >>PAGE_SHIFT ,GFP_KERNEL ); -if (IS_ERR (page)) + folio =mapping_read_folio_gfp (bdev->bd_mapping, +SB_OFFSET >>PAGE_SHIFT ,GFP_KERNEL ); +if (IS_ERR (folio))return "IO error" ; - s =page_address (page) +offset_in_page (SB_OFFSET ); + s =folio_address (folio) +offset_in_folio (folio,SB_OFFSET ); sb->offset =le64_to_cpu (s->offset); sb->version =le64_to_cpu (s->version);
@@ -272,7 +272,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev, *res = s;return NULL ; err: -put_page (page); +folio_put (folio);return err; }
@@ -1366,7 +1366,7 @@ static CLOSURE_CALLBACK(cached_dev_free)mutex_unlock (&bch_register_lock);if (dc->sb_disk) -put_page (virt_to_page (dc->sb_disk)); +folio_put (virt_to_folio (dc->sb_disk));if (dc->bdev_file)fput (dc->bdev_file);
@@ -2216,7 +2216,7 @@ void bch_cache_release(struct kobject *kobj)free_fifo (&ca->free[i]);if (ca->sb_disk) -put_page (virt_to_page (ca->sb_disk)); +folio_put (virt_to_folio (ca->sb_disk));if (ca->bdev_file)fput (ca->bdev_file);
@@ -2593,7 +2593,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,if (!holder) { ret = -ENOMEM ; err ="cannot allocate memory" ; - goto out_put_sb_page; + goto out_put_sb_folio; }/* Now reopen in exclusive mode with proper holder */
@@ -2667,8 +2667,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, out_free_holder:kfree (holder); -out_put_sb_page: -put_page (virt_to_page (sb_disk)); +out_put_sb_folio: +folio_put (virt_to_folio (sb_disk)); out_blkdev_put:if (bdev_file)fput (bdev_file);
Signature · 1 line
2.39.5
Jens Axboe
maintainerQuoted 6 lines · On 7/1/25 8:48 PM, [email protected] wrote:
From: Matthew Wilcox (Oracle) <[email protected]>
Retrieve a folio from the page cache instead of a page. Removes a hidden call to
compound_head(). Then be sure to callfolio_put()instead ofput_page()to release it. That doesn't save any calls tocompound_head(), just moves them around.
Really needs a better subject line... I can do that while applying, however. How about:
bcache: switch from pages to folios in read_super()
or something like that.
Signature · 1 line
Jens Axboe
Quoted 12 lines
2025年7月2日 21:49,Jens Axboe <[email protected]> 写道:
Quoted 6 lines · On 7/1/25 8:48 PM, [email protected] wrote:
From: Matthew Wilcox (Oracle) <[email protected]>
Retrieve a folio from the page cache instead of a page. Removes a hidden call to
compound_head(). Then be sure to callfolio_put()instead ofput_page()to release it. That doesn't save any calls tocompound_head(), just moves them around.
Quoted 4 lines
Really needs a better subject line... I can do that while applying, however. How about:
bcache: switch from pages to folios in
read_super()
Yeah, this subject is good IMHO.
Thanks.
Coly Li
Quoted 6 lines · On Wed, 02 Jul 2025 10:48:48 +0800, [email protected] wrote:
Retrieve a folio from the page cache instead of a page. Removes a hidden call to
compound_head(). Then be sure to callfolio_put()instead ofput_page()to release it. That doesn't save any calls tocompound_head(), just moves them around.
Applied, thanks!
[1/1] bcache: Use a folio
commit: 88b4b873551f0901dd0314d37ca2a420ec6c2686
Best regards,
Signature · 1 line
Jens Axboe