Skip to content

Commit 17bf23a

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
fs: convert block_write_full_page to block_write_full_folio
Convert the function to be compatible with writepage_t so that it can be passed to write_cache_pages() by blkdev. This removes a call to compound_head(). We can also remove the function export as both callers are built-in. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Jens Axboe <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent af34acc commit 17bf23a

File tree

9 files changed

+35
-22
lines changed

9 files changed

+35
-22
lines changed

block/fops.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,24 @@ static int blkdev_get_block(struct inode *inode, sector_t iblock,
410410
return 0;
411411
}
412412

413-
static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
413+
/*
414+
* We cannot call mpage_writepages() as it does not take the buffer lock.
415+
* We must use block_write_full_folio() directly which holds the buffer
416+
* lock. The buffer lock provides the synchronisation with writeback
417+
* that filesystems rely on when they use the blockdev's mapping.
418+
*/
419+
static int blkdev_writepages(struct address_space *mapping,
420+
struct writeback_control *wbc)
414421
{
415-
return block_write_full_page(page, blkdev_get_block, wbc);
422+
struct blk_plug plug;
423+
int err;
424+
425+
blk_start_plug(&plug);
426+
err = write_cache_pages(mapping, wbc, block_write_full_folio,
427+
blkdev_get_block);
428+
blk_finish_plug(&plug);
429+
430+
return err;
416431
}
417432

418433
static int blkdev_read_folio(struct file *file, struct folio *folio)
@@ -449,7 +464,7 @@ const struct address_space_operations def_blk_aops = {
449464
.invalidate_folio = block_invalidate_folio,
450465
.read_folio = blkdev_read_folio,
451466
.readahead = blkdev_readahead,
452-
.writepage = blkdev_writepage,
467+
.writepages = blkdev_writepages,
453468
.write_begin = blkdev_write_begin,
454469
.write_end = blkdev_write_end,
455470
.migrate_folio = buffer_migrate_folio_norefs,

fs/buffer.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static void end_buffer_async_read_io(struct buffer_head *bh, int uptodate)
372372
}
373373

374374
/*
375-
* Completion handler for block_write_full_page() - pages which are unlocked
375+
* Completion handler for block_write_full_folio() - pages which are unlocked
376376
* during I/O, and which have PageWriteback cleared upon I/O completion.
377377
*/
378378
void end_buffer_async_write(struct buffer_head *bh, int uptodate)
@@ -1771,18 +1771,18 @@ static struct buffer_head *folio_create_buffers(struct folio *folio,
17711771
*/
17721772

17731773
/*
1774-
* While block_write_full_page is writing back the dirty buffers under
1774+
* While block_write_full_folio is writing back the dirty buffers under
17751775
* the page lock, whoever dirtied the buffers may decide to clean them
17761776
* again at any time. We handle that by only looking at the buffer
17771777
* state inside lock_buffer().
17781778
*
1779-
* If block_write_full_page() is called for regular writeback
1779+
* If block_write_full_folio() is called for regular writeback
17801780
* (wbc->sync_mode == WB_SYNC_NONE) then it will redirty a page which has a
17811781
* locked buffer. This only can happen if someone has written the buffer
17821782
* directly, with submit_bh(). At the address_space level PageWriteback
17831783
* prevents this contention from occurring.
17841784
*
1785-
* If block_write_full_page() is called with wbc->sync_mode ==
1785+
* If block_write_full_folio() is called with wbc->sync_mode ==
17861786
* WB_SYNC_ALL, the writes are posted using REQ_SYNC; this
17871787
* causes the writes to be flagged as synchronous writes.
17881788
*/
@@ -1829,7 +1829,7 @@ int __block_write_full_folio(struct inode *inode, struct folio *folio,
18291829
* truncate in progress.
18301830
*/
18311831
/*
1832-
* The buffer was zeroed by block_write_full_page()
1832+
* The buffer was zeroed by block_write_full_folio()
18331833
*/
18341834
clear_buffer_dirty(bh);
18351835
set_buffer_uptodate(bh);
@@ -2696,10 +2696,9 @@ EXPORT_SYMBOL(block_truncate_page);
26962696
/*
26972697
* The generic ->writepage function for buffer-backed address_spaces
26982698
*/
2699-
int block_write_full_page(struct page *page, get_block_t *get_block,
2700-
struct writeback_control *wbc)
2699+
int block_write_full_folio(struct folio *folio, struct writeback_control *wbc,
2700+
void *get_block)
27012701
{
2702-
struct folio *folio = page_folio(page);
27032702
struct inode * const inode = folio->mapping->host;
27042703
loff_t i_size = i_size_read(inode);
27052704

@@ -2726,7 +2725,6 @@ int block_write_full_page(struct page *page, get_block_t *get_block,
27262725
return __block_write_full_folio(inode, folio, get_block, wbc,
27272726
end_buffer_async_write);
27282727
}
2729-
EXPORT_SYMBOL(block_write_full_page);
27302728

27312729
sector_t generic_block_bmap(struct address_space *mapping, sector_t block,
27322730
get_block_t *get_block)

fs/ext4/page-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ int ext4_bio_write_folio(struct ext4_io_submit *io, struct folio *folio,
444444
folio_clear_error(folio);
445445

446446
/*
447-
* Comments copied from block_write_full_page:
447+
* Comments copied from block_write_full_folio:
448448
*
449449
* The folio straddles i_size. It must be zeroed out on each and every
450450
* writepage invocation because it may be mmapped. "A file is mapped

fs/gfs2/aops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ static int gfs2_get_block_noalloc(struct inode *inode, sector_t lblock,
8282
}
8383

8484
/**
85-
* gfs2_write_jdata_folio - gfs2 jdata-specific version of block_write_full_page
85+
* gfs2_write_jdata_folio - gfs2 jdata-specific version of block_write_full_folio
8686
* @folio: The folio to write
8787
* @wbc: The writeback control
8888
*
89-
* This is the same as calling block_write_full_page, but it also
89+
* This is the same as calling block_write_full_folio, but it also
9090
* writes pages outside of i_size
9191
*/
9292
static int gfs2_write_jdata_folio(struct folio *folio,

fs/mpage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc,
642642
/*
643643
* The caller has a ref on the inode, so *mapping is stable
644644
*/
645-
ret = block_write_full_page(&folio->page, mpd->get_block, wbc);
645+
ret = block_write_full_folio(folio, wbc, mpd->get_block);
646646
mapping_set_error(mapping, ret);
647647
out:
648648
mpd->bio = bio;

fs/ntfs/aops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ static int ntfs_write_mst_block(struct page *page,
13041304
* page cleaned. The VM has already locked the page and marked it clean.
13051305
*
13061306
* For non-resident attributes, ntfs_writepage() writes the @page by calling
1307-
* the ntfs version of the generic block_write_full_page() function,
1307+
* the ntfs version of the generic block_write_full_folio() function,
13081308
* ntfs_write_block(), which in turn if necessary creates and writes the
13091309
* buffers associated with the page asynchronously.
13101310
*
@@ -1314,7 +1314,7 @@ static int ntfs_write_mst_block(struct page *page,
13141314
* vfs inode dirty code path for the inode the mft record belongs to or via the
13151315
* vm page dirty code path for the page the mft record is in.
13161316
*
1317-
* Based on ntfs_read_folio() and fs/buffer.c::block_write_full_page().
1317+
* Based on ntfs_read_folio() and fs/buffer.c::block_write_full_folio().
13181318
*
13191319
* Return 0 on success and -errno on error.
13201320
*/

fs/ocfs2/alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6934,7 +6934,7 @@ static int ocfs2_grab_eof_pages(struct inode *inode, loff_t start, loff_t end,
69346934
* nonzero data on subsequent file extends.
69356935
*
69366936
* We need to call this before i_size is updated on the inode because
6937-
* otherwise block_write_full_page() will skip writeout of pages past
6937+
* otherwise block_write_full_folio() will skip writeout of pages past
69386938
* i_size.
69396939
*/
69406940
int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle,

fs/ocfs2/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from,
818818
/*
819819
* fs-writeback will release the dirty pages without page lock
820820
* whose offset are over inode size, the release happens at
821-
* block_write_full_page().
821+
* block_write_full_folio().
822822
*/
823823
i_size_write(inode, abs_to);
824824
inode->i_blocks = ocfs2_inode_sector_count(inode);

include/linux/buffer_head.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ void __bh_read_batch(int nr, struct buffer_head *bhs[],
252252
* address_spaces.
253253
*/
254254
void block_invalidate_folio(struct folio *folio, size_t offset, size_t length);
255-
int block_write_full_page(struct page *page, get_block_t *get_block,
256-
struct writeback_control *wbc);
255+
int block_write_full_folio(struct folio *folio, struct writeback_control *wbc,
256+
void *get_block);
257257
int __block_write_full_folio(struct inode *inode, struct folio *folio,
258258
get_block_t *get_block, struct writeback_control *wbc,
259259
bh_end_io_t *handler);

0 commit comments

Comments
 (0)