Skip to content

Commit 1bcb413

Browse files
Christoph Hellwigbrauner
authored andcommitted
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>
1 parent 7359651 commit 1bcb413

3 files changed

Lines changed: 21 additions & 41 deletions

File tree

fs/fs-writeback.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,9 @@ static void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
822822
* @wbc: writeback_control of interest
823823
* @inode: target inode
824824
*
825-
* This function is to be used by __filemap_fdatawrite_range(), which is an
826-
* alternative entry point into writeback code, and first ensures @inode is
827-
* associated with a bdi_writeback and attaches it to @wbc.
825+
* This function is to be used by filemap_writeback(), which is an alternative
826+
* entry point into writeback code, and first ensures @inode is associated with
827+
* a bdi_writeback and attaches it to @wbc.
828828
*/
829829
void wbc_attach_fdatawrite_inode(struct writeback_control *wbc,
830830
struct inode *inode)

include/linux/pagemap.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ int filemap_fdatawrite_range(struct address_space *mapping,
6060
loff_t start, loff_t end);
6161
int filemap_check_errors(struct address_space *mapping);
6262
void __filemap_set_wb_err(struct address_space *mapping, int err);
63-
int filemap_fdatawrite_wbc(struct address_space *mapping,
64-
struct writeback_control *wbc);
6563
int kiocb_write_and_wait(struct kiocb *iocb, size_t count);
6664

6765
static inline int filemap_write_and_wait(struct address_space *mapping)

mm/filemap.c

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -366,31 +366,30 @@ static int filemap_check_and_keep_errors(struct address_space *mapping)
366366
return 0;
367367
}
368368

369-
/**
370-
* filemap_fdatawrite_wbc - start writeback on mapping dirty pages in range
371-
* @mapping: address space structure to write
372-
* @wbc: the writeback_control controlling the writeout
373-
*
374-
* Call writepages on the mapping using the provided wbc to control the
375-
* writeout.
376-
*
377-
* Return: %0 on success, negative error code otherwise.
378-
*/
379-
int filemap_fdatawrite_wbc(struct address_space *mapping,
380-
struct writeback_control *wbc)
369+
static int filemap_writeback(struct address_space *mapping, loff_t start,
370+
loff_t end, enum writeback_sync_modes sync_mode,
371+
long *nr_to_write)
381372
{
373+
struct writeback_control wbc = {
374+
.sync_mode = sync_mode,
375+
.nr_to_write = nr_to_write ? *nr_to_write : LONG_MAX,
376+
.range_start = start,
377+
.range_end = end,
378+
};
382379
int ret;
383380

384381
if (!mapping_can_writeback(mapping) ||
385382
!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
386383
return 0;
387384

388-
wbc_attach_fdatawrite_inode(wbc, mapping->host);
389-
ret = do_writepages(mapping, wbc);
390-
wbc_detach_inode(wbc);
385+
wbc_attach_fdatawrite_inode(&wbc, mapping->host);
386+
ret = do_writepages(mapping, &wbc);
387+
wbc_detach_inode(&wbc);
388+
389+
if (!ret && nr_to_write)
390+
*nr_to_write = wbc.nr_to_write;
391391
return ret;
392392
}
393-
EXPORT_SYMBOL(filemap_fdatawrite_wbc);
394393

395394
/**
396395
* __filemap_fdatawrite_range - start writeback on mapping dirty pages in range
@@ -412,14 +411,7 @@ EXPORT_SYMBOL(filemap_fdatawrite_wbc);
412411
int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
413412
loff_t end, int sync_mode)
414413
{
415-
struct writeback_control wbc = {
416-
.sync_mode = sync_mode,
417-
.nr_to_write = LONG_MAX,
418-
.range_start = start,
419-
.range_end = end,
420-
};
421-
422-
return filemap_fdatawrite_wbc(mapping, &wbc);
414+
return filemap_writeback(mapping, start, end, sync_mode, NULL);
423415
}
424416

425417
int filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
@@ -475,18 +467,8 @@ EXPORT_SYMBOL(filemap_flush);
475467
*/
476468
int filemap_flush_nr(struct address_space *mapping, long *nr_to_write)
477469
{
478-
struct writeback_control wbc = {
479-
.nr_to_write = *nr_to_write,
480-
.sync_mode = WB_SYNC_NONE,
481-
.range_start = 0,
482-
.range_end = LLONG_MAX,
483-
};
484-
int ret;
485-
486-
ret = filemap_fdatawrite_wbc(mapping, &wbc);
487-
if (!ret)
488-
*nr_to_write = wbc.nr_to_write;
489-
return ret;
470+
return filemap_writeback(mapping, 0, LLONG_MAX, WB_SYNC_NONE,
471+
nr_to_write);
490472
}
491473
EXPORT_SYMBOL_FOR_MODULES(filemap_flush_nr, "btrfs");
492474

0 commit comments

Comments
 (0)