* remove write_cache_pages()
@ 2025-08-18 6:10 Christoph Hellwig
2025-08-18 6:10 ` [PATCH 1/3] ntfs3: stop using write_cache_pages Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Christoph Hellwig @ 2025-08-18 6:10 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton
Cc: Kent Overstreet, Konstantin Komarov, linux-bcachefs, ntfs3,
linux-fsdevel, linux-mm
Kill of write_cache_pages after converting the last two users to the
iterator.
Diffstat:
fs/bcachefs/fs-io-buffered.c | 13 ++++++++++++-
fs/ntfs3/inode.c | 15 ++++++++++-----
include/linux/writeback.h | 6 ------
mm/page-writeback.c | 30 ------------------------------
4 files changed, 22 insertions(+), 42 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] ntfs3: stop using write_cache_pages
2025-08-18 6:10 remove write_cache_pages() Christoph Hellwig
@ 2025-08-18 6:10 ` Christoph Hellwig
2025-08-18 6:10 ` [PATCH 2/3] bcachefs: " Christoph Hellwig
2025-08-18 6:10 ` [PATCH 3/3] mm: remove write_cache_pages Christoph Hellwig
2 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2025-08-18 6:10 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton
Cc: Kent Overstreet, Konstantin Komarov, linux-bcachefs, ntfs3,
linux-fsdevel, linux-mm
Stop using the obsolete write_cache_pages and use writeback_iter directly.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/ntfs3/inode.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 37cbbee7fa58..48b4f73a93ee 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -871,9 +871,9 @@ int ntfs_set_size(struct inode *inode, u64 new_size)
}
static int ntfs_resident_writepage(struct folio *folio,
- struct writeback_control *wbc, void *data)
+ struct writeback_control *wbc)
{
- struct address_space *mapping = data;
+ struct address_space *mapping = folio->mapping;
struct inode *inode = mapping->host;
struct ntfs_inode *ni = ntfs_i(inode);
int ret;
@@ -907,9 +907,14 @@ static int ntfs_writepages(struct address_space *mapping,
if (unlikely(ntfs3_forced_shutdown(inode->i_sb)))
return -EIO;
- if (is_resident(ntfs_i(inode)))
- return write_cache_pages(mapping, wbc, ntfs_resident_writepage,
- mapping);
+ if (is_resident(ntfs_i(inode))) {
+ struct folio *folio = NULL;
+ int error;
+
+ while ((folio = writeback_iter(mapping, wbc, folio, &error)))
+ error = ntfs_resident_writepage(folio, wbc);
+ return error;
+ }
return mpage_writepages(mapping, wbc, ntfs_get_block);
}
--
2.47.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] bcachefs: stop using write_cache_pages
2025-08-18 6:10 remove write_cache_pages() Christoph Hellwig
2025-08-18 6:10 ` [PATCH 1/3] ntfs3: stop using write_cache_pages Christoph Hellwig
@ 2025-08-18 6:10 ` Christoph Hellwig
2025-08-18 11:17 ` Kent Overstreet
2025-08-18 6:10 ` [PATCH 3/3] mm: remove write_cache_pages Christoph Hellwig
2 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2025-08-18 6:10 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton
Cc: Kent Overstreet, Konstantin Komarov, linux-bcachefs, ntfs3,
linux-fsdevel, linux-mm
Stop using the obsolete write_cache_pages and use writeback_iter
directly. This basically just open codes write_cache_pages
without the indirect call, but there's probably ways to structure
the code even nicer as a follow on.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/bcachefs/fs-io-buffered.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/fs/bcachefs/fs-io-buffered.c b/fs/bcachefs/fs-io-buffered.c
index 1c54b9b5bd69..fdeaa25189f2 100644
--- a/fs/bcachefs/fs-io-buffered.c
+++ b/fs/bcachefs/fs-io-buffered.c
@@ -655,6 +655,17 @@ static int __bch2_writepage(struct folio *folio,
return 0;
}
+static int bch2_write_cache_pages(struct address_space *mapping,
+ struct writeback_control *wbc, void *data)
+{
+ struct folio *folio = NULL;
+ int error;
+
+ while ((folio = writeback_iter(mapping, wbc, folio, &error)))
+ error = __bch2_writepage(folio, wbc, data);
+ return error;
+}
+
int bch2_writepages(struct address_space *mapping, struct writeback_control *wbc)
{
struct bch_fs *c = mapping->host->i_sb->s_fs_info;
@@ -663,7 +674,7 @@ int bch2_writepages(struct address_space *mapping, struct writeback_control *wbc
bch2_inode_opts_get(&w->opts, c, &to_bch_ei(mapping->host)->ei_inode);
blk_start_plug(&w->plug);
- int ret = write_cache_pages(mapping, wbc, __bch2_writepage, w);
+ int ret = bch2_write_cache_pages(mapping, wbc, w);
if (w->io)
bch2_writepage_do_io(w);
blk_finish_plug(&w->plug);
--
2.47.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] mm: remove write_cache_pages
2025-08-18 6:10 remove write_cache_pages() Christoph Hellwig
2025-08-18 6:10 ` [PATCH 1/3] ntfs3: stop using write_cache_pages Christoph Hellwig
2025-08-18 6:10 ` [PATCH 2/3] bcachefs: " Christoph Hellwig
@ 2025-08-18 6:10 ` Christoph Hellwig
2025-08-18 13:18 ` David Hildenbrand
2 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2025-08-18 6:10 UTC (permalink / raw)
To: Matthew Wilcox (Oracle), Andrew Morton
Cc: Kent Overstreet, Konstantin Komarov, linux-bcachefs, ntfs3,
linux-fsdevel, linux-mm
No users left.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/writeback.h | 6 ------
mm/page-writeback.c | 30 ------------------------------
2 files changed, 36 deletions(-)
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index a2848d731a46..2a7e134d03ee 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -360,12 +360,6 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb);
struct folio *writeback_iter(struct address_space *mapping,
struct writeback_control *wbc, struct folio *folio, int *error);
-typedef int (*writepage_t)(struct folio *folio, struct writeback_control *wbc,
- void *data);
-
-int write_cache_pages(struct address_space *mapping,
- struct writeback_control *wbc, writepage_t writepage,
- void *data);
int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
void writeback_set_ratelimit(void);
void tag_pages_for_writeback(struct address_space *mapping,
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 3e248d1c3969..7e1e798e7213 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2590,36 +2590,6 @@ struct folio *writeback_iter(struct address_space *mapping,
}
EXPORT_SYMBOL_GPL(writeback_iter);
-/**
- * write_cache_pages - walk the list of dirty pages of the given address space and write all of them.
- * @mapping: address space structure to write
- * @wbc: subtract the number of written pages from *@wbc->nr_to_write
- * @writepage: function called for each page
- * @data: data passed to writepage function
- *
- * Return: %0 on success, negative error code otherwise
- *
- * Note: please use writeback_iter() instead.
- */
-int write_cache_pages(struct address_space *mapping,
- struct writeback_control *wbc, writepage_t writepage,
- void *data)
-{
- struct folio *folio = NULL;
- int error;
-
- while ((folio = writeback_iter(mapping, wbc, folio, &error))) {
- error = writepage(folio, wbc, data);
- if (error == AOP_WRITEPAGE_ACTIVATE) {
- folio_unlock(folio);
- error = 0;
- }
- }
-
- return error;
-}
-EXPORT_SYMBOL(write_cache_pages);
-
int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
{
int ret;
--
2.47.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] bcachefs: stop using write_cache_pages
2025-08-18 6:10 ` [PATCH 2/3] bcachefs: " Christoph Hellwig
@ 2025-08-18 11:17 ` Kent Overstreet
2025-08-19 8:57 ` Christoph Hellwig
0 siblings, 1 reply; 7+ messages in thread
From: Kent Overstreet @ 2025-08-18 11:17 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Matthew Wilcox (Oracle), Andrew Morton, Konstantin Komarov,
linux-bcachefs, ntfs3, linux-fsdevel, linux-mm
On Mon, Aug 18, 2025 at 08:10:09AM +0200, Christoph Hellwig wrote:
> Stop using the obsolete write_cache_pages and use writeback_iter
> directly. This basically just open codes write_cache_pages
> without the indirect call, but there's probably ways to structure
> the code even nicer as a follow on.
Wouldn't inlining write_cache_pages() achieve the same thing?
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/bcachefs/fs-io-buffered.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/fs/bcachefs/fs-io-buffered.c b/fs/bcachefs/fs-io-buffered.c
> index 1c54b9b5bd69..fdeaa25189f2 100644
> --- a/fs/bcachefs/fs-io-buffered.c
> +++ b/fs/bcachefs/fs-io-buffered.c
> @@ -655,6 +655,17 @@ static int __bch2_writepage(struct folio *folio,
> return 0;
> }
>
> +static int bch2_write_cache_pages(struct address_space *mapping,
> + struct writeback_control *wbc, void *data)
> +{
> + struct folio *folio = NULL;
> + int error;
> +
> + while ((folio = writeback_iter(mapping, wbc, folio, &error)))
> + error = __bch2_writepage(folio, wbc, data);
> + return error;
> +}
> +
> int bch2_writepages(struct address_space *mapping, struct writeback_control *wbc)
> {
> struct bch_fs *c = mapping->host->i_sb->s_fs_info;
> @@ -663,7 +674,7 @@ int bch2_writepages(struct address_space *mapping, struct writeback_control *wbc
> bch2_inode_opts_get(&w->opts, c, &to_bch_ei(mapping->host)->ei_inode);
>
> blk_start_plug(&w->plug);
> - int ret = write_cache_pages(mapping, wbc, __bch2_writepage, w);
> + int ret = bch2_write_cache_pages(mapping, wbc, w);
> if (w->io)
> bch2_writepage_do_io(w);
> blk_finish_plug(&w->plug);
> --
> 2.47.2
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] mm: remove write_cache_pages
2025-08-18 6:10 ` [PATCH 3/3] mm: remove write_cache_pages Christoph Hellwig
@ 2025-08-18 13:18 ` David Hildenbrand
0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2025-08-18 13:18 UTC (permalink / raw)
To: Christoph Hellwig, Matthew Wilcox (Oracle), Andrew Morton
Cc: Kent Overstreet, Konstantin Komarov, linux-bcachefs, ntfs3,
linux-fsdevel, linux-mm
On 18.08.25 08:10, Christoph Hellwig wrote:
> No users left.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] bcachefs: stop using write_cache_pages
2025-08-18 11:17 ` Kent Overstreet
@ 2025-08-19 8:57 ` Christoph Hellwig
0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2025-08-19 8:57 UTC (permalink / raw)
To: Kent Overstreet
Cc: Christoph Hellwig, Matthew Wilcox (Oracle), Andrew Morton,
Konstantin Komarov, linux-bcachefs, ntfs3, linux-fsdevel,
linux-mm
On Mon, Aug 18, 2025 at 07:17:15AM -0400, Kent Overstreet wrote:
> On Mon, Aug 18, 2025 at 08:10:09AM +0200, Christoph Hellwig wrote:
> > Stop using the obsolete write_cache_pages and use writeback_iter
> > directly. This basically just open codes write_cache_pages
> > without the indirect call, but there's probably ways to structure
> > the code even nicer as a follow on.
>
> Wouldn't inlining write_cache_pages() achieve the same thing?
It might eliminate the indirect calls with the right compiler or
options, but not archieve any of the other goals, and leave us
with a helper implementing a pointless callback pattern for 1 user.
> > +
> > + while ((folio = writeback_iter(mapping, wbc, folio, &error)))
> > + error = __bch2_writepage(folio, wbc, data);
> > + return error;
> > +}
> > +
> > int bch2_writepages(struct address_space *mapping, struct writeback_control *wbc)
> > {
> > struct bch_fs *c = mapping->host->i_sb->s_fs_info;
> > @@ -663,7 +674,7 @@ int bch2_writepages(struct address_space *mapping, struct writeback_control *wbc
> > bch2_inode_opts_get(&w->opts, c, &to_bch_ei(mapping->host)->ei_inode);
> >
> > blk_start_plug(&w->plug);
> > - int ret = write_cache_pages(mapping, wbc, __bch2_writepage, w);
> > + int ret = bch2_write_cache_pages(mapping, wbc, w);
> > if (w->io)
> > bch2_writepage_do_io(w);
> > blk_finish_plug(&w->plug);
> > --
> > 2.47.2
> >
---end quoted text---
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-08-19 8:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 6:10 remove write_cache_pages() Christoph Hellwig
2025-08-18 6:10 ` [PATCH 1/3] ntfs3: stop using write_cache_pages Christoph Hellwig
2025-08-18 6:10 ` [PATCH 2/3] bcachefs: " Christoph Hellwig
2025-08-18 11:17 ` Kent Overstreet
2025-08-19 8:57 ` Christoph Hellwig
2025-08-18 6:10 ` [PATCH 3/3] mm: remove write_cache_pages Christoph Hellwig
2025-08-18 13:18 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).