Commit c5521c76 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Andrew Morton

nilfs2: convert nilfs_grab_buffer() to use a folio

Remove a number of folio->page->folio conversions.

Link: https://lkml.kernel.org/r/20231016201114.1928083-12-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Pankaj Raghav <p.raghav@samsung.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 6c346be9
...@@ -25,19 +25,19 @@ ...@@ -25,19 +25,19 @@
(BIT(BH_Uptodate) | BIT(BH_Mapped) | BIT(BH_NILFS_Node) | \ (BIT(BH_Uptodate) | BIT(BH_Mapped) | BIT(BH_NILFS_Node) | \
BIT(BH_NILFS_Volatile) | BIT(BH_NILFS_Checked)) BIT(BH_NILFS_Volatile) | BIT(BH_NILFS_Checked))
static struct buffer_head * static struct buffer_head *__nilfs_get_folio_block(struct folio *folio,
__nilfs_get_page_block(struct page *page, unsigned long block, pgoff_t index, unsigned long block, pgoff_t index, int blkbits,
int blkbits, unsigned long b_state) unsigned long b_state)
{ {
unsigned long first_block; unsigned long first_block;
struct buffer_head *bh; struct buffer_head *bh = folio_buffers(folio);
if (!page_has_buffers(page)) if (!bh)
create_empty_buffers(page, 1 << blkbits, b_state); bh = folio_create_empty_buffers(folio, 1 << blkbits, b_state);
first_block = (unsigned long)index << (PAGE_SHIFT - blkbits); first_block = (unsigned long)index << (PAGE_SHIFT - blkbits);
bh = nilfs_page_get_nth_block(page, block - first_block); bh = get_nth_bh(bh, block - first_block);
touch_buffer(bh); touch_buffer(bh);
wait_on_buffer(bh); wait_on_buffer(bh);
...@@ -51,17 +51,17 @@ struct buffer_head *nilfs_grab_buffer(struct inode *inode, ...@@ -51,17 +51,17 @@ struct buffer_head *nilfs_grab_buffer(struct inode *inode,
{ {
int blkbits = inode->i_blkbits; int blkbits = inode->i_blkbits;
pgoff_t index = blkoff >> (PAGE_SHIFT - blkbits); pgoff_t index = blkoff >> (PAGE_SHIFT - blkbits);
struct page *page; struct folio *folio;
struct buffer_head *bh; struct buffer_head *bh;
page = grab_cache_page(mapping, index); folio = filemap_grab_folio(mapping, index);
if (unlikely(!page)) if (IS_ERR(folio))
return NULL; return NULL;
bh = __nilfs_get_page_block(page, blkoff, index, blkbits, b_state); bh = __nilfs_get_folio_block(folio, blkoff, index, blkbits, b_state);
if (unlikely(!bh)) { if (unlikely(!bh)) {
unlock_page(page); folio_unlock(folio);
put_page(page); folio_put(folio);
return NULL; return NULL;
} }
return bh; return bh;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment