mm: remove filemap_fdatawrite_wbc

Replace filemap_fdatawrite_wbc, which exposes a writeback_control to the
callers with a filemap_writeback helper that takes all the possible
arguments and declares the writeback_control itself.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20251024080431.324236-9-hch@lst.de
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christoph Hellwig 2025-10-24 10:04:19 +02:00 committed by Christian Brauner
parent 7359651448
commit 1bcb413d0c
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
3 changed files with 21 additions and 41 deletions

View File

@ -822,9 +822,9 @@ static void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
* @wbc: writeback_control of interest * @wbc: writeback_control of interest
* @inode: target inode * @inode: target inode
* *
* This function is to be used by __filemap_fdatawrite_range(), which is an * This function is to be used by filemap_writeback(), which is an alternative
* alternative entry point into writeback code, and first ensures @inode is * entry point into writeback code, and first ensures @inode is associated with
* associated with a bdi_writeback and attaches it to @wbc. * a bdi_writeback and attaches it to @wbc.
*/ */
void wbc_attach_fdatawrite_inode(struct writeback_control *wbc, void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
struct inode *inode) struct inode *inode)

View File

@ -60,8 +60,6 @@ int filemap_fdatawrite_range(struct address_space *mapping,
loff_t start, loff_t end); loff_t start, loff_t end);
int filemap_check_errors(struct address_space *mapping); int filemap_check_errors(struct address_space *mapping);
void __filemap_set_wb_err(struct address_space *mapping, int err); void __filemap_set_wb_err(struct address_space *mapping, int err);
int filemap_fdatawrite_wbc(struct address_space *mapping,
struct writeback_control *wbc);
int kiocb_write_and_wait(struct kiocb *iocb, size_t count); int kiocb_write_and_wait(struct kiocb *iocb, size_t count);
static inline int filemap_write_and_wait(struct address_space *mapping) static inline int filemap_write_and_wait(struct address_space *mapping)

View File

@ -366,31 +366,30 @@ static int filemap_check_and_keep_errors(struct address_space *mapping)
return 0; return 0;
} }
/** static int filemap_writeback(struct address_space *mapping, loff_t start,
* filemap_fdatawrite_wbc - start writeback on mapping dirty pages in range loff_t end, enum writeback_sync_modes sync_mode,
* @mapping: address space structure to write long *nr_to_write)
* @wbc: the writeback_control controlling the writeout
*
* Call writepages on the mapping using the provided wbc to control the
* writeout.
*
* Return: %0 on success, negative error code otherwise.
*/
int filemap_fdatawrite_wbc(struct address_space *mapping,
struct writeback_control *wbc)
{ {
struct writeback_control wbc = {
.sync_mode = sync_mode,
.nr_to_write = nr_to_write ? *nr_to_write : LONG_MAX,
.range_start = start,
.range_end = end,
};
int ret; int ret;
if (!mapping_can_writeback(mapping) || if (!mapping_can_writeback(mapping) ||
!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) !mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
return 0; return 0;
wbc_attach_fdatawrite_inode(wbc, mapping->host); wbc_attach_fdatawrite_inode(&wbc, mapping->host);
ret = do_writepages(mapping, wbc); ret = do_writepages(mapping, &wbc);
wbc_detach_inode(wbc); wbc_detach_inode(&wbc);
if (!ret && nr_to_write)
*nr_to_write = wbc.nr_to_write;
return ret; return ret;
} }
EXPORT_SYMBOL(filemap_fdatawrite_wbc);
/** /**
* __filemap_fdatawrite_range - start writeback on mapping dirty pages in range * __filemap_fdatawrite_range - start writeback on mapping dirty pages in range
@ -412,14 +411,7 @@ EXPORT_SYMBOL(filemap_fdatawrite_wbc);
int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start, int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
loff_t end, int sync_mode) loff_t end, int sync_mode)
{ {
struct writeback_control wbc = { return filemap_writeback(mapping, start, end, sync_mode, NULL);
.sync_mode = sync_mode,
.nr_to_write = LONG_MAX,
.range_start = start,
.range_end = end,
};
return filemap_fdatawrite_wbc(mapping, &wbc);
} }
int filemap_fdatawrite_range(struct address_space *mapping, loff_t start, int filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
@ -475,18 +467,8 @@ EXPORT_SYMBOL(filemap_flush);
*/ */
int filemap_flush_nr(struct address_space *mapping, long *nr_to_write) int filemap_flush_nr(struct address_space *mapping, long *nr_to_write)
{ {
struct writeback_control wbc = { return filemap_writeback(mapping, 0, LLONG_MAX, WB_SYNC_NONE,
.nr_to_write = *nr_to_write, nr_to_write);
.sync_mode = WB_SYNC_NONE,
.range_start = 0,
.range_end = LLONG_MAX,
};
int ret;
ret = filemap_fdatawrite_wbc(mapping, &wbc);
if (!ret)
*nr_to_write = wbc.nr_to_write;
return ret;
} }
EXPORT_SYMBOL_FOR_MODULES(filemap_flush_nr, "btrfs"); EXPORT_SYMBOL_FOR_MODULES(filemap_flush_nr, "btrfs");