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

gfs2: convert gfs2_write_buf_to_page() to use a folio

Remove several folio->page->folio conversions.

Link: https://lkml.kernel.org/r/20231016201114.1928083-10-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
Cc: Pankaj Raghav <p.raghav@samsung.com>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent c646e573
...@@ -749,7 +749,7 @@ static int gfs2_write_buf_to_page(struct gfs2_sbd *sdp, unsigned long index, ...@@ -749,7 +749,7 @@ static int gfs2_write_buf_to_page(struct gfs2_sbd *sdp, unsigned long index,
struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode); struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode);
struct inode *inode = &ip->i_inode; struct inode *inode = &ip->i_inode;
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
struct page *page; struct folio *folio;
struct buffer_head *bh; struct buffer_head *bh;
u64 blk; u64 blk;
unsigned bsize = sdp->sd_sb.sb_bsize, bnum = 0, boff = 0; unsigned bsize = sdp->sd_sb.sb_bsize, bnum = 0, boff = 0;
...@@ -758,15 +758,15 @@ static int gfs2_write_buf_to_page(struct gfs2_sbd *sdp, unsigned long index, ...@@ -758,15 +758,15 @@ static int gfs2_write_buf_to_page(struct gfs2_sbd *sdp, unsigned long index,
blk = index << (PAGE_SHIFT - sdp->sd_sb.sb_bsize_shift); blk = index << (PAGE_SHIFT - sdp->sd_sb.sb_bsize_shift);
boff = off % bsize; boff = off % bsize;
page = grab_cache_page(mapping, index); folio = filemap_grab_folio(mapping, index);
if (!page) if (IS_ERR(folio))
return -ENOMEM; return PTR_ERR(folio);
if (!page_has_buffers(page)) bh = folio_buffers(folio);
create_empty_buffers(page, bsize, 0); if (!bh)
bh = folio_create_empty_buffers(folio, bsize, 0);
bh = page_buffers(page); for (;;) {
for(;;) { /* Find the beginning block within the folio */
/* Find the beginning block within the page */
if (pg_off >= ((bnum * bsize) + bsize)) { if (pg_off >= ((bnum * bsize) + bsize)) {
bh = bh->b_this_page; bh = bh->b_this_page;
bnum++; bnum++;
...@@ -779,9 +779,10 @@ static int gfs2_write_buf_to_page(struct gfs2_sbd *sdp, unsigned long index, ...@@ -779,9 +779,10 @@ static int gfs2_write_buf_to_page(struct gfs2_sbd *sdp, unsigned long index,
goto unlock_out; goto unlock_out;
/* If it's a newly allocated disk block, zero it */ /* If it's a newly allocated disk block, zero it */
if (buffer_new(bh)) if (buffer_new(bh))
zero_user(page, bnum * bsize, bh->b_size); folio_zero_range(folio, bnum * bsize,
bh->b_size);
} }
if (PageUptodate(page)) if (folio_test_uptodate(folio))
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
if (bh_read(bh, REQ_META | REQ_PRIO) < 0) if (bh_read(bh, REQ_META | REQ_PRIO) < 0)
goto unlock_out; goto unlock_out;
...@@ -797,17 +798,17 @@ static int gfs2_write_buf_to_page(struct gfs2_sbd *sdp, unsigned long index, ...@@ -797,17 +798,17 @@ static int gfs2_write_buf_to_page(struct gfs2_sbd *sdp, unsigned long index,
break; break;
} }
/* Write to the page, now that we have setup the buffer(s) */ /* Write to the folio, now that we have setup the buffer(s) */
memcpy_to_page(page, off, buf, bytes); memcpy_to_folio(folio, off, buf, bytes);
flush_dcache_page(page); flush_dcache_folio(folio);
unlock_page(page); folio_unlock(folio);
put_page(page); folio_put(folio);
return 0; return 0;
unlock_out: unlock_out:
unlock_page(page); folio_unlock(folio);
put_page(page); folio_put(folio);
return -EIO; return -EIO;
} }
......
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