Skip to content

Commit 7fa4964

Browse files
author
Andreas Gruenbacher
committed
gfs2: Convert stuffed_readpage to folios
Change stuffed_readpage() to take a folio instead of a page. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent d6d64da commit 7fa4964

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

fs/gfs2/aops.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -403,41 +403,39 @@ static int gfs2_jdata_writepages(struct address_space *mapping,
403403
}
404404

405405
/**
406-
* stuffed_readpage - Fill in a Linux page with stuffed file data
406+
* stuffed_readpage - Fill in a Linux folio with stuffed file data
407407
* @ip: the inode
408-
* @page: the page
408+
* @folio: the folio
409409
*
410410
* Returns: errno
411411
*/
412-
static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
412+
static int stuffed_readpage(struct gfs2_inode *ip, struct folio *folio)
413413
{
414414
struct buffer_head *dibh;
415-
u64 dsize = i_size_read(&ip->i_inode);
416-
void *kaddr;
415+
size_t i_size = i_size_read(&ip->i_inode);
416+
void *data;
417417
int error;
418418

419419
/*
420420
* Due to the order of unstuffing files and ->fault(), we can be
421-
* asked for a zero page in the case of a stuffed file being extended,
421+
* asked for a zero folio in the case of a stuffed file being extended,
422422
* so we need to supply one here. It doesn't happen often.
423423
*/
424-
if (unlikely(page->index)) {
425-
zero_user(page, 0, PAGE_SIZE);
426-
SetPageUptodate(page);
424+
if (unlikely(folio->index)) {
425+
folio_zero_range(folio, 0, folio_size(folio));
426+
folio_mark_uptodate(folio);
427427
return 0;
428428
}
429429

430430
error = gfs2_meta_inode_buffer(ip, &dibh);
431431
if (error)
432432
return error;
433433

434-
kaddr = kmap_local_page(page);
435-
memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize);
436-
memset(kaddr + dsize, 0, PAGE_SIZE - dsize);
437-
kunmap_local(kaddr);
438-
flush_dcache_page(page);
434+
data = dibh->b_data + sizeof(struct gfs2_dinode);
435+
memcpy_to_folio(folio, 0, data, i_size);
436+
folio_zero_range(folio, i_size, folio_size(folio) - i_size);
439437
brelse(dibh);
440-
SetPageUptodate(page);
438+
folio_mark_uptodate(folio);
441439

442440
return 0;
443441
}
@@ -458,7 +456,7 @@ static int gfs2_read_folio(struct file *file, struct folio *folio)
458456
(i_blocksize(inode) == PAGE_SIZE && !folio_buffers(folio))) {
459457
error = iomap_read_folio(folio, &gfs2_iomap_ops);
460458
} else if (gfs2_is_stuffed(ip)) {
461-
error = stuffed_readpage(ip, &folio->page);
459+
error = stuffed_readpage(ip, folio);
462460
folio_unlock(folio);
463461
} else {
464462
error = mpage_read_folio(folio, gfs2_block_map);

0 commit comments

Comments
 (0)