[PATCH 11/13] gfs2: add support in gfs2 to handle multiple writeback contexts

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

Add support to handle multiple writeback contexts and check for
dirty_exceeded across all the writeback contexts

Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
fs/gfs2/super.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index dfc83bd3def3..d4fdab4a4201 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -450,6 +450,7 @@ static int gfs2_write_inode(struct inode *inode, struct writeback_control *wbc)
struct gfs2_sbd *sdp = GFS2_SB(inode);
struct address_space *metamapping = gfs2_glock2aspace(ip->i_gl);
struct backing_dev_info *bdi = inode_to_bdi(metamapping->host);
+ struct bdi_writeback_ctx *bdi_wb_ctx;
int ret = 0;
bool flush_all = (wbc->sync_mode == WB_SYNC_ALL || gfs2_is_jdata(ip));

@@ -457,10 +458,12 @@ 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_ctx_arr[0]->wb.dirty_exceeded)
- gfs2_ail1_flush(sdp, wbc);
- else
- filemap_fdatawrite(metamapping);
+
+ for_each_bdi_wb_ctx(bdi, bdi_wb_ctx)
+ if (bdi_wb_ctx->wb.dirty_exceeded)
+ gfs2_ail1_flush(sdp, wbc);
+ else
+ filemap_fdatawrite(metamapping);
if (flush_all)
ret = filemap_fdatawait(metamapping);
if (ret)
--
2.25.1