[PATCH 12/13] nfs: add support in nfs to handle multiple writeback contexts

Kundan Kumar
2025-05-29T11:34:17Z

Fetch writeback context to which an inode is affined. Use it to perform
writeback related operations.

Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
fs/nfs/internal.h | 5 +++--
fs/nfs/write.c | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index fd513bf9e875..a7cacaf484c9 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -838,14 +838,15 @@ static inline void nfs_folio_mark_unstable(struct folio *folio,
{
if (folio && !cinfo->dreq) {
struct inode *inode = folio->mapping->host;
+ struct bdi_writeback_ctx *bdi_wb_ctx =
+ fetch_bdi_writeback_ctx(inode);
long nr = folio_nr_pages(folio);

/* This page is really still in write-back - just that the
* writeback is happening on the server now.
*/
node_stat_mod_folio(folio, NR_WRITEBACK, nr);
- wb_stat_mod(&inode_to_bdi(inode)->wb_ctx_arr[0]->wb,
- WB_WRITEBACK, nr);
+ wb_stat_mod(&bdi_wb_ctx->wb, WB_WRITEBACK, nr);
__mark_inode_dirty(inode, I_DIRTY_DATASYNC);
}
}
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index ec48ec8c2db8..ca0823debce7 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -932,11 +932,11 @@ static void nfs_folio_clear_commit(struct folio *folio)
{
if (folio) {
long nr = folio_nr_pages(folio);
- struct inode *inode = folio->mapping->host;
+ struct bdi_writeback_ctx *bdi_wb_ctx =
+ fetch_bdi_writeback_ctx(folio->mapping->host);

node_stat_mod_folio(folio, NR_WRITEBACK, -nr);
- wb_stat_mod(&inode_to_bdi(inode)->wb_ctx_arr[0]->wb,
- WB_WRITEBACK, -nr);
+ wb_stat_mod(&bdi_wb_ctx->wb, WB_WRITEBACK, -nr);
}
}

--
2.25.1