Skip to content

Commit

Permalink
fs: Convert mpage_readpage to mpage_read_folio
Browse files Browse the repository at this point in the history
mpage_readpage still works in terms of pages, and has not been audited
for correctness with large folios, so include an assertion that the
filesystem is not passing it large folios.  Convert all the filesystems
to call mpage_read_folio() instead of mpage_readpage().

Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) committed May 9, 2022
1 parent 2c69e20 commit f132ab7
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 47 deletions.
6 changes: 3 additions & 3 deletions fs/exfat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ static int exfat_get_block(struct inode *inode, sector_t iblock,
return err;
}

static int exfat_readpage(struct file *file, struct page *page)
static int exfat_read_folio(struct file *file, struct folio *folio)
{
return mpage_readpage(page, exfat_get_block);
return mpage_read_folio(folio, exfat_get_block);
}

static void exfat_readahead(struct readahead_control *rac)
Expand Down Expand Up @@ -492,7 +492,7 @@ int exfat_block_truncate_page(struct inode *inode, loff_t from)
static const struct address_space_operations exfat_aops = {
.dirty_folio = block_dirty_folio,
.invalidate_folio = block_invalidate_folio,
.readpage = exfat_readpage,
.read_folio = exfat_read_folio,
.readahead = exfat_readahead,
.writepage = exfat_writepage,
.writepages = exfat_writepages,
Expand Down
8 changes: 4 additions & 4 deletions fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,9 @@ static int ext2_writepage(struct page *page, struct writeback_control *wbc)
return block_write_full_page(page, ext2_get_block, wbc);
}

static int ext2_readpage(struct file *file, struct page *page)
static int ext2_read_folio(struct file *file, struct folio *folio)
{
return mpage_readpage(page, ext2_get_block);
return mpage_read_folio(folio, ext2_get_block);
}

static void ext2_readahead(struct readahead_control *rac)
Expand Down Expand Up @@ -966,7 +966,7 @@ ext2_dax_writepages(struct address_space *mapping, struct writeback_control *wbc
const struct address_space_operations ext2_aops = {
.dirty_folio = block_dirty_folio,
.invalidate_folio = block_invalidate_folio,
.readpage = ext2_readpage,
.read_folio = ext2_read_folio,
.readahead = ext2_readahead,
.writepage = ext2_writepage,
.write_begin = ext2_write_begin,
Expand All @@ -982,7 +982,7 @@ const struct address_space_operations ext2_aops = {
const struct address_space_operations ext2_nobh_aops = {
.dirty_folio = block_dirty_folio,
.invalidate_folio = block_invalidate_folio,
.readpage = ext2_readpage,
.read_folio = ext2_read_folio,
.readahead = ext2_readahead,
.writepage = ext2_nobh_writepage,
.write_begin = ext2_nobh_write_begin,
Expand Down
6 changes: 3 additions & 3 deletions fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ static int fat_writepages(struct address_space *mapping,
return mpage_writepages(mapping, wbc, fat_get_block);
}

static int fat_readpage(struct file *file, struct page *page)
static int fat_read_folio(struct file *file, struct folio *folio)
{
return mpage_readpage(page, fat_get_block);
return mpage_read_folio(folio, fat_get_block);
}

static void fat_readahead(struct readahead_control *rac)
Expand Down Expand Up @@ -344,7 +344,7 @@ int fat_block_truncate_page(struct inode *inode, loff_t from)
static const struct address_space_operations fat_aops = {
.dirty_folio = block_dirty_folio,
.invalidate_folio = block_invalidate_folio,
.readpage = fat_readpage,
.read_folio = fat_read_folio,
.readahead = fat_readahead,
.writepage = fat_writepage,
.writepages = fat_writepages,
Expand Down
15 changes: 7 additions & 8 deletions fs/gfs2/aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ static int __gfs2_readpage(void *file, struct page *page)
error = stuffed_readpage(ip, page);
unlock_page(page);
} else {
error = mpage_readpage(page, gfs2_block_map);
error = mpage_read_folio(folio, gfs2_block_map);
}

if (unlikely(gfs2_withdrawn(sdp)))
Expand All @@ -490,14 +490,13 @@ static int __gfs2_readpage(void *file, struct page *page)
}

/**
* gfs2_readpage - read a page of a file
* gfs2_read_folio - read a folio from a file
* @file: The file to read
* @page: The page of the file
* @folio: The folio in the file
*/

static int gfs2_readpage(struct file *file, struct page *page)
static int gfs2_read_folio(struct file *file, struct folio *folio)
{
return __gfs2_readpage(file, page);
return __gfs2_readpage(file, &folio->page);
}

/**
Expand Down Expand Up @@ -773,7 +772,7 @@ int gfs2_releasepage(struct page *page, gfp_t gfp_mask)
static const struct address_space_operations gfs2_aops = {
.writepage = gfs2_writepage,
.writepages = gfs2_writepages,
.readpage = gfs2_readpage,
.read_folio = gfs2_read_folio,
.readahead = gfs2_readahead,
.dirty_folio = filemap_dirty_folio,
.releasepage = iomap_releasepage,
Expand All @@ -788,7 +787,7 @@ static const struct address_space_operations gfs2_aops = {
static const struct address_space_operations gfs2_jdata_aops = {
.writepage = gfs2_jdata_writepage,
.writepages = gfs2_jdata_writepages,
.readpage = gfs2_readpage,
.read_folio = gfs2_read_folio,
.readahead = gfs2_readahead,
.dirty_folio = jdata_dirty_folio,
.bmap = gfs2_bmap,
Expand Down
6 changes: 3 additions & 3 deletions fs/hpfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ static const struct iomap_ops hpfs_iomap_ops = {
.iomap_begin = hpfs_iomap_begin,
};

static int hpfs_readpage(struct file *file, struct page *page)
static int hpfs_read_folio(struct file *file, struct folio *folio)
{
return mpage_readpage(page, hpfs_get_block);
return mpage_read_folio(folio, hpfs_get_block);
}

static int hpfs_writepage(struct page *page, struct writeback_control *wbc)
Expand Down Expand Up @@ -247,7 +247,7 @@ static int hpfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
const struct address_space_operations hpfs_aops = {
.dirty_folio = block_dirty_folio,
.invalidate_folio = block_invalidate_folio,
.readpage = hpfs_readpage,
.read_folio = hpfs_read_folio,
.writepage = hpfs_writepage,
.readahead = hpfs_readahead,
.writepages = hpfs_writepages,
Expand Down
2 changes: 1 addition & 1 deletion fs/iomap/buffered-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter,
/*
* If the bio_alloc fails, try it again for a single page to
* avoid having to deal with partial page reads. This emulates
* what do_mpage_readpage does.
* what do_mpage_read_folio does.
*/
if (!ctx->bio) {
ctx->bio = bio_alloc(iomap->bdev, 1, REQ_OP_READ,
Expand Down
6 changes: 3 additions & 3 deletions fs/isofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,9 +1174,9 @@ struct buffer_head *isofs_bread(struct inode *inode, sector_t block)
return sb_bread(inode->i_sb, blknr);
}

static int isofs_readpage(struct file *file, struct page *page)
static int isofs_read_folio(struct file *file, struct folio *folio)
{
return mpage_readpage(page, isofs_get_block);
return mpage_read_folio(folio, isofs_get_block);
}

static void isofs_readahead(struct readahead_control *rac)
Expand All @@ -1190,7 +1190,7 @@ static sector_t _isofs_bmap(struct address_space *mapping, sector_t block)
}

static const struct address_space_operations isofs_aops = {
.readpage = isofs_readpage,
.read_folio = isofs_read_folio,
.readahead = isofs_readahead,
.bmap = _isofs_bmap
};
Expand Down
6 changes: 3 additions & 3 deletions fs/jfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ static int jfs_writepages(struct address_space *mapping,
return mpage_writepages(mapping, wbc, jfs_get_block);
}

static int jfs_readpage(struct file *file, struct page *page)
static int jfs_read_folio(struct file *file, struct folio *folio)
{
return mpage_readpage(page, jfs_get_block);
return mpage_read_folio(folio, jfs_get_block);
}

static void jfs_readahead(struct readahead_control *rac)
Expand Down Expand Up @@ -359,7 +359,7 @@ static ssize_t jfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
const struct address_space_operations jfs_aops = {
.dirty_folio = block_dirty_folio,
.invalidate_folio = block_invalidate_folio,
.readpage = jfs_readpage,
.read_folio = jfs_read_folio,
.readahead = jfs_readahead,
.writepage = jfs_writepage,
.writepages = jfs_writepages,
Expand Down
8 changes: 5 additions & 3 deletions fs/mpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,20 +364,22 @@ EXPORT_SYMBOL(mpage_readahead);
/*
* This isn't called much at all
*/
int mpage_readpage(struct page *page, get_block_t get_block)
int mpage_read_folio(struct folio *folio, get_block_t get_block)
{
struct mpage_readpage_args args = {
.page = page,
.page = &folio->page,
.nr_pages = 1,
.get_block = get_block,
};

VM_BUG_ON_FOLIO(folio_test_large(folio), folio);

args.bio = do_mpage_readpage(&args);
if (args.bio)
mpage_bio_submit(args.bio);
return 0;
}
EXPORT_SYMBOL(mpage_readpage);
EXPORT_SYMBOL(mpage_read_folio);

/*
* Writing is not so simple.
Expand Down
10 changes: 5 additions & 5 deletions fs/nilfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ int nilfs_get_block(struct inode *inode, sector_t blkoff,
}

/**
* nilfs_readpage() - implement readpage() method of nilfs_aops {}
* nilfs_read_folio() - implement read_folio() method of nilfs_aops {}
* address_space_operations.
* @file - file struct of the file to be read
* @page - the page to be read
* @folio - the folio to be read
*/
static int nilfs_readpage(struct file *file, struct page *page)
static int nilfs_read_folio(struct file *file, struct folio *folio)
{
return mpage_readpage(page, nilfs_get_block);
return mpage_read_folio(folio, nilfs_get_block);
}

static void nilfs_readahead(struct readahead_control *rac)
Expand Down Expand Up @@ -298,7 +298,7 @@ nilfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)

const struct address_space_operations nilfs_aops = {
.writepage = nilfs_writepage,
.readpage = nilfs_readpage,
.read_folio = nilfs_read_folio,
.writepages = nilfs_writepages,
.dirty_folio = nilfs_dirty_folio,
.readahead = nilfs_readahead,
Expand Down
9 changes: 5 additions & 4 deletions fs/ntfs3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,9 @@ static sector_t ntfs_bmap(struct address_space *mapping, sector_t block)
return generic_block_bmap(mapping, block, ntfs_get_block_bmap);
}

static int ntfs_readpage(struct file *file, struct page *page)
static int ntfs_read_folio(struct file *file, struct folio *folio)
{
struct page *page = &folio->page;
int err;
struct address_space *mapping = page->mapping;
struct inode *inode = mapping->host;
Expand All @@ -701,7 +702,7 @@ static int ntfs_readpage(struct file *file, struct page *page)
}

/* Normal + sparse files. */
return mpage_readpage(page, ntfs_get_block);
return mpage_read_folio(folio, ntfs_get_block);
}

static void ntfs_readahead(struct readahead_control *rac)
Expand Down Expand Up @@ -1940,7 +1941,7 @@ const struct inode_operations ntfs_link_inode_operations = {
};

const struct address_space_operations ntfs_aops = {
.readpage = ntfs_readpage,
.read_folio = ntfs_read_folio,
.readahead = ntfs_readahead,
.writepage = ntfs_writepage,
.writepages = ntfs_writepages,
Expand All @@ -1952,7 +1953,7 @@ const struct address_space_operations ntfs_aops = {
};

const struct address_space_operations ntfs_aops_cmpr = {
.readpage = ntfs_readpage,
.read_folio = ntfs_read_folio,
.readahead = ntfs_readahead,
};
// clang-format on
6 changes: 3 additions & 3 deletions fs/qnx6/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ static int qnx6_check_blockptr(__fs32 ptr)
return 1;
}

static int qnx6_readpage(struct file *file, struct page *page)
static int qnx6_read_folio(struct file *file, struct folio *folio)
{
return mpage_readpage(page, qnx6_get_block);
return mpage_read_folio(folio, qnx6_get_block);
}

static void qnx6_readahead(struct readahead_control *rac)
Expand Down Expand Up @@ -496,7 +496,7 @@ static sector_t qnx6_bmap(struct address_space *mapping, sector_t block)
return generic_block_bmap(mapping, block, qnx6_get_block);
}
static const struct address_space_operations qnx6_aops = {
.readpage = qnx6_readpage,
.read_folio = qnx6_read_folio,
.readahead = qnx6_readahead,
.bmap = qnx6_bmap
};
Expand Down
6 changes: 3 additions & 3 deletions fs/udf/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ static int udf_writepages(struct address_space *mapping,
return mpage_writepages(mapping, wbc, udf_get_block);
}

static int udf_readpage(struct file *file, struct page *page)
static int udf_read_folio(struct file *file, struct folio *folio)
{
return mpage_readpage(page, udf_get_block);
return mpage_read_folio(folio, udf_get_block);
}

static void udf_readahead(struct readahead_control *rac)
Expand Down Expand Up @@ -237,7 +237,7 @@ static sector_t udf_bmap(struct address_space *mapping, sector_t block)
const struct address_space_operations udf_aops = {
.dirty_folio = block_dirty_folio,
.invalidate_folio = block_invalidate_folio,
.readpage = udf_readpage,
.read_folio = udf_read_folio,
.readahead = udf_readahead,
.writepage = udf_writepage,
.writepages = udf_writepages,
Expand Down
2 changes: 1 addition & 1 deletion include/linux/mpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct writeback_control;
struct readahead_control;

void mpage_readahead(struct readahead_control *, get_block_t get_block);
int mpage_readpage(struct page *page, get_block_t get_block);
int mpage_read_folio(struct folio *folio, get_block_t get_block);
int mpage_writepages(struct address_space *mapping,
struct writeback_control *wbc, get_block_t get_block);
int mpage_writepage(struct page *page, get_block_t *get_block,
Expand Down

0 comments on commit f132ab7

Please sign in to comment.