* [PATCH v2 1/4] writeback: prep helpers for dirty-limit and writeback accounting
2026-02-13 5:46 ` [PATCH v2 0/4] Avoid filesystem references to writeback internals Kundan Kumar
@ 2026-02-13 5:46 ` Kundan Kumar
2026-02-13 5:46 ` [PATCH v2 2/4] f2fs: stop using writeback internals for dirty_exceeded checks Kundan Kumar
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Kundan Kumar @ 2026-02-13 5:46 UTC (permalink / raw)
To: jaegeuk, chao, agruenba, trondmy, anna, hch, brauner, jack, viro,
djwong, jlayton
Cc: linux-f2fs-devel, linux-kernel, gfs2, linux-nfs, gost.dev,
anuj20.g, vishak.g, joshi.k, Kundan Kumar
Add helper APIs needed by filesystems to avoid poking into writeback
internals.
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com>
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
include/linux/backing-dev.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 0c8342747cab..5b7d12b40d5e 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -136,6 +136,19 @@ static inline bool mapping_can_writeback(struct address_space *mapping)
return inode_to_bdi(mapping->host)->capabilities & BDI_CAP_WRITEBACK;
}
+/* Must not be used by file systems that support cgroup writeback */
+static inline int bdi_wb_dirty_exceeded(struct backing_dev_info *bdi)
+{
+ return bdi->wb.dirty_exceeded;
+}
+
+/* Must not be used by file systems that support cgroup writeback */
+static inline void bdi_wb_stat_mod(struct inode *inode, enum wb_stat_item item,
+ s64 amount)
+{
+ wb_stat_mod(&inode_to_bdi(inode)->wb, item, amount);
+}
+
#ifdef CONFIG_CGROUP_WRITEBACK
struct bdi_writeback *wb_get_lookup(struct backing_dev_info *bdi,
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 2/4] f2fs: stop using writeback internals for dirty_exceeded checks
2026-02-13 5:46 ` [PATCH v2 0/4] Avoid filesystem references to writeback internals Kundan Kumar
2026-02-13 5:46 ` [PATCH v2 1/4] writeback: prep helpers for dirty-limit and writeback accounting Kundan Kumar
@ 2026-02-13 5:46 ` Kundan Kumar
2026-02-13 5:46 ` [PATCH v2 3/4] gfs2: stop using writeback internals for dirty_exceeded check Kundan Kumar
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Kundan Kumar @ 2026-02-13 5:46 UTC (permalink / raw)
To: jaegeuk, chao, agruenba, trondmy, anna, hch, brauner, jack, viro,
djwong, jlayton
Cc: linux-f2fs-devel, linux-kernel, gfs2, linux-nfs, gost.dev,
anuj20.g, vishak.g, joshi.k, Kundan Kumar
Replace direct dereferences of dirty_exceeded with the core helper
bdi_wb_dirty_exceeded(), removing f2fs dependencies on writeback
internals.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com>
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
fs/f2fs/node.c | 4 ++--
fs/f2fs/segment.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 482a362f2625..d450b282cc55 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -78,7 +78,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
if (excess_cached_nats(sbi))
res = false;
} else if (type == DIRTY_DENTS) {
- if (sbi->sb->s_bdi->wb.dirty_exceeded)
+ if (bdi_wb_dirty_exceeded(sbi->sb->s_bdi))
return false;
mem_size = get_pages(sbi, F2FS_DIRTY_DENTS);
res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1);
@@ -119,7 +119,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
res = false;
#endif
} else {
- if (!sbi->sb->s_bdi->wb.dirty_exceeded)
+ if (!bdi_wb_dirty_exceeded(sbi->sb->s_bdi))
return true;
}
return res;
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 07dcbcbeb7c6..d7166f1f000a 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -1000,7 +1000,7 @@ static inline bool sec_usage_check(struct f2fs_sb_info *sbi, unsigned int secno)
*/
static inline int nr_pages_to_skip(struct f2fs_sb_info *sbi, int type)
{
- if (sbi->sb->s_bdi->wb.dirty_exceeded)
+ if (bdi_wb_dirty_exceeded(sbi->sb->s_bdi))
return 0;
if (type == DATA)
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 3/4] gfs2: stop using writeback internals for dirty_exceeded check
2026-02-13 5:46 ` [PATCH v2 0/4] Avoid filesystem references to writeback internals Kundan Kumar
2026-02-13 5:46 ` [PATCH v2 1/4] writeback: prep helpers for dirty-limit and writeback accounting Kundan Kumar
2026-02-13 5:46 ` [PATCH v2 2/4] f2fs: stop using writeback internals for dirty_exceeded checks Kundan Kumar
@ 2026-02-13 5:46 ` Kundan Kumar
2026-02-13 5:46 ` [PATCH v2 4/4] nfs: stop using writeback internals for WB_WRITEBACK accounting Kundan Kumar
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Kundan Kumar @ 2026-02-13 5:46 UTC (permalink / raw)
To: jaegeuk, chao, agruenba, trondmy, anna, hch, brauner, jack, viro,
djwong, jlayton
Cc: linux-f2fs-devel, linux-kernel, gfs2, linux-nfs, gost.dev,
anuj20.g, vishak.g, joshi.k, Kundan Kumar
Convert gfs2 dirty_exceeded handling to use the writeback core helper
instead of accessing writeback directly.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com>
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
fs/gfs2/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index f6cd907b3ec6..7ddeee19dec4 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -447,7 +447,7 @@ static int gfs2_write_inode(struct inode *inode, struct writeback_control *wbc)
gfs2_log_flush(GFS2_SB(inode), ip->i_gl,
GFS2_LOG_HEAD_FLUSH_NORMAL |
GFS2_LFC_WRITE_INODE);
- if (bdi->wb.dirty_exceeded)
+ if (bdi_wb_dirty_exceeded(bdi))
gfs2_ail1_flush(sdp, wbc);
else
filemap_fdatawrite(metamapping);
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v2 4/4] nfs: stop using writeback internals for WB_WRITEBACK accounting
2026-02-13 5:46 ` [PATCH v2 0/4] Avoid filesystem references to writeback internals Kundan Kumar
` (2 preceding siblings ...)
2026-02-13 5:46 ` [PATCH v2 3/4] gfs2: stop using writeback internals for dirty_exceeded check Kundan Kumar
@ 2026-02-13 5:46 ` Kundan Kumar
2026-02-13 6:24 ` [PATCH v2 0/4] Avoid filesystem references to writeback internals Christoph Hellwig
2026-02-17 12:26 ` Christian Brauner
5 siblings, 0 replies; 7+ messages in thread
From: Kundan Kumar @ 2026-02-13 5:46 UTC (permalink / raw)
To: jaegeuk, chao, agruenba, trondmy, anna, hch, brauner, jack, viro,
djwong, jlayton
Cc: linux-f2fs-devel, linux-kernel, gfs2, linux-nfs, gost.dev,
anuj20.g, vishak.g, joshi.k, Kundan Kumar
Convert NFS WB_WRITEBACK accounting to writeback helper, eliminating
direct access to writeback.
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
fs/nfs/internal.h | 2 +-
fs/nfs/write.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 2e596244799f..96249d6d9132 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -866,7 +866,7 @@ static inline void nfs_folio_mark_unstable(struct folio *folio,
* writeback is happening on the server now.
*/
node_stat_mod_folio(folio, NR_WRITEBACK, nr);
- wb_stat_mod(&inode_to_bdi(inode)->wb, WB_WRITEBACK, nr);
+ bdi_wb_stat_mod(inode, WB_WRITEBACK, nr);
__mark_inode_dirty(inode, I_DIRTY_DATASYNC);
}
}
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index bf412455e8ed..9053e0c4a836 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -872,8 +872,7 @@ static void nfs_folio_clear_commit(struct folio *folio)
long nr = folio_nr_pages(folio);
node_stat_mod_folio(folio, NR_WRITEBACK, -nr);
- wb_stat_mod(&inode_to_bdi(folio->mapping->host)->wb,
- WB_WRITEBACK, -nr);
+ bdi_wb_stat_mod(folio->mapping->host, WB_WRITEBACK, -nr);
}
}
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v2 0/4] Avoid filesystem references to writeback internals
2026-02-13 5:46 ` [PATCH v2 0/4] Avoid filesystem references to writeback internals Kundan Kumar
` (3 preceding siblings ...)
2026-02-13 5:46 ` [PATCH v2 4/4] nfs: stop using writeback internals for WB_WRITEBACK accounting Kundan Kumar
@ 2026-02-13 6:24 ` Christoph Hellwig
2026-02-17 12:26 ` Christian Brauner
5 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2026-02-13 6:24 UTC (permalink / raw)
To: Kundan Kumar
Cc: jaegeuk, chao, agruenba, trondmy, anna, hch, brauner, jack, viro,
djwong, jlayton, linux-f2fs-devel, linux-kernel, gfs2, linux-nfs,
gost.dev, anuj20.g, vishak.g, joshi.k
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v2 0/4] Avoid filesystem references to writeback internals
2026-02-13 5:46 ` [PATCH v2 0/4] Avoid filesystem references to writeback internals Kundan Kumar
` (4 preceding siblings ...)
2026-02-13 6:24 ` [PATCH v2 0/4] Avoid filesystem references to writeback internals Christoph Hellwig
@ 2026-02-17 12:26 ` Christian Brauner
5 siblings, 0 replies; 7+ messages in thread
From: Christian Brauner @ 2026-02-17 12:26 UTC (permalink / raw)
To: Kundan Kumar
Cc: Christian Brauner, linux-f2fs-devel, linux-kernel, gfs2,
linux-nfs, gost.dev, anuj20.g, vishak.g, joshi.k, jaegeuk, chao,
agruenba, trondmy, anna, hch, jack, viro, djwong, jlayton
On Fri, 13 Feb 2026 11:16:30 +0530, Kundan Kumar wrote:
> The series introduces writeback helper APIs and converts f2fs, gfs2
> and nfs to stop accessing writeback internals directly.
>
> As suggested by Christoph [1], filesystem code that directly accesses
> writeback internals is split out:
> [1] https://lore.kernel.org/all/20251015072912.GA11294@lst.de/
>
> [...]
Applied to the master branch of the vfs/vfs.git tree.
Patches in the master branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: master
[1/4] writeback: prep helpers for dirty-limit and writeback accounting
https://git.kernel.org/vfs/vfs/c/a235d3bcd28b
[2/4] f2fs: stop using writeback internals for dirty_exceeded checks
https://git.kernel.org/vfs/vfs/c/07043a6ebeb2
[3/4] gfs2: stop using writeback internals for dirty_exceeded check
https://git.kernel.org/vfs/vfs/c/8cab8dc0e141
[4/4] nfs: stop using writeback internals for WB_WRITEBACK accounting
https://git.kernel.org/vfs/vfs/c/fd15b9c6ec8a
^ permalink raw reply [flat|nested] 7+ messages in thread