When doing truncate/fallocate for some filesytem like ocfs2, it will zero some pages that are out of inode size and then later update the inode size, so it needs this api to writeback eof pages. Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Junxiao Bi <junxiao.bi@xxxxxxxxxx> --- fs/buffer.c | 14 +++++++++++--- include/linux/buffer_head.h | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 0cb7ffd4977c..802f0bacdbde 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1709,9 +1709,9 @@ static struct buffer_head *create_page_buffers(struct page *page, struct inode * * WB_SYNC_ALL, the writes are posted using REQ_SYNC; this * causes the writes to be flagged as synchronous writes. */ -int __block_write_full_page(struct inode *inode, struct page *page, +int __block_write_full_page_eof(struct inode *inode, struct page *page, get_block_t *get_block, struct writeback_control *wbc, - bh_end_io_t *handler) + bh_end_io_t *handler, bool eof_write) { int err; sector_t block; @@ -1746,7 +1746,7 @@ int __block_write_full_page(struct inode *inode, struct page *page, * handle any aliases from the underlying blockdev's mapping. */ do { - if (block > last_block) { + if (block > last_block && !eof_write) { /* * mapped buffers outside i_size will occur, because * this page can be outside i_size when there is a @@ -1871,6 +1871,14 @@ int __block_write_full_page(struct inode *inode, struct page *page, unlock_page(page); goto done; } +EXPORT_SYMBOL(__block_write_full_page_eof); + +int __block_write_full_page(struct inode *inode, struct page *page, + get_block_t *get_block, struct writeback_control *wbc, + bh_end_io_t *handler) +{ + return __block_write_full_page_eof(inode, page, get_block, wbc, handler, false); +} EXPORT_SYMBOL(__block_write_full_page); /* diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 6b47f94378c5..5da15a1ba15c 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -221,6 +221,9 @@ int block_write_full_page(struct page *page, get_block_t *get_block, int __block_write_full_page(struct inode *inode, struct page *page, get_block_t *get_block, struct writeback_control *wbc, bh_end_io_t *handler); +int __block_write_full_page_eof(struct inode *inode, struct page *page, + get_block_t *get_block, struct writeback_control *wbc, + bh_end_io_t *handler, bool eof_write); int block_read_full_page(struct page*, get_block_t*); int block_is_partially_uptodate(struct page *page, unsigned long from, unsigned long count); -- 2.24.3 (Apple Git-128)