Skip to content

Commit 39107cc

Browse files
Matthew Wilcox (Oracle)axboe
authored andcommitted
bcache: switch from pages to folios in read_super()
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. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Coly Li <[email protected]> Acked-back: Coly Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] [axboe: commit message massaging] Signed-off-by: Jens Axboe <[email protected]>
1 parent 0a50ed0 commit 39107cc

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

drivers/md/bcache/super.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
168168
{
169169
const char *err;
170170
struct cache_sb_disk *s;
171-
struct page *page;
171+
struct folio *folio;
172172
unsigned int i;
173173

174-
page = read_cache_page_gfp(bdev->bd_mapping,
175-
SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
176-
if (IS_ERR(page))
174+
folio = mapping_read_folio_gfp(bdev->bd_mapping,
175+
SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL);
176+
if (IS_ERR(folio))
177177
return "IO error";
178-
s = page_address(page) + offset_in_page(SB_OFFSET);
178+
s = folio_address(folio) + offset_in_folio(folio, SB_OFFSET);
179179

180180
sb->offset = le64_to_cpu(s->offset);
181181
sb->version = le64_to_cpu(s->version);
@@ -272,7 +272,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
272272
*res = s;
273273
return NULL;
274274
err:
275-
put_page(page);
275+
folio_put(folio);
276276
return err;
277277
}
278278

@@ -1366,7 +1366,7 @@ static CLOSURE_CALLBACK(cached_dev_free)
13661366
mutex_unlock(&bch_register_lock);
13671367

13681368
if (dc->sb_disk)
1369-
put_page(virt_to_page(dc->sb_disk));
1369+
folio_put(virt_to_folio(dc->sb_disk));
13701370

13711371
if (dc->bdev_file)
13721372
fput(dc->bdev_file);
@@ -2216,7 +2216,7 @@ void bch_cache_release(struct kobject *kobj)
22162216
free_fifo(&ca->free[i]);
22172217

22182218
if (ca->sb_disk)
2219-
put_page(virt_to_page(ca->sb_disk));
2219+
folio_put(virt_to_folio(ca->sb_disk));
22202220

22212221
if (ca->bdev_file)
22222222
fput(ca->bdev_file);
@@ -2593,7 +2593,7 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
25932593
if (!holder) {
25942594
ret = -ENOMEM;
25952595
err = "cannot allocate memory";
2596-
goto out_put_sb_page;
2596+
goto out_put_sb_folio;
25972597
}
25982598

25992599
/* Now reopen in exclusive mode with proper holder */
@@ -2667,8 +2667,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
26672667

26682668
out_free_holder:
26692669
kfree(holder);
2670-
out_put_sb_page:
2671-
put_page(virt_to_page(sb_disk));
2670+
out_put_sb_folio:
2671+
folio_put(virt_to_folio(sb_disk));
26722672
out_blkdev_put:
26732673
if (bdev_file)
26742674
fput(bdev_file);

0 commit comments

Comments
 (0)