[PATCH 03/13] writeback: link bdi_writeback to its corresponding bdi_writeback_ctx

Kundan Kumar
2025-05-29T11:33:42Z

Introduce a bdi_writeback_ctx field in bdi_writeback. This helps in
fetching the writeback context from the bdi_writeback.

Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
mm/backing-dev.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index adf87b036827..5479e2d34160 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -513,15 +513,16 @@ static void wb_update_bandwidth_workfn(struct work_struct *work)
*/
#define INIT_BW (100 << (20 - PAGE_SHIFT))

-static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
- gfp_t gfp)
+static int wb_init(struct bdi_writeback *wb,
+ struct bdi_writeback_ctx *bdi_wb_ctx,
+ struct backing_dev_info *bdi, gfp_t gfp)
{
int err;

memset(wb, 0, sizeof(*wb));

wb->bdi = bdi;
- wb->bdi_wb_ctx = bdi->wb_ctx_arr[0];
+ wb->bdi_wb_ctx = bdi_wb_ctx;
wb->last_old_flush = jiffies;
INIT_LIST_HEAD(&wb->b_dirty);
INIT_LIST_HEAD(&wb->b_io);
@@ -698,7 +699,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
goto out_put;
}

- ret = wb_init(wb, bdi, gfp);
+ ret = wb_init(wb, bdi_wb_ctx, bdi, gfp);
if (ret)
goto err_free;

@@ -843,7 +844,7 @@ static int cgwb_bdi_init(struct backing_dev_info *bdi)
mutex_init(&bdi->cgwb_release_mutex);
init_rwsem(&bdi_wb_ctx->wb_switch_rwsem);

- ret = wb_init(&bdi_wb_ctx->wb, bdi, GFP_KERNEL);
+ ret = wb_init(&bdi_wb_ctx->wb, bdi_wb_ctx, bdi, GFP_KERNEL);
if (!ret) {
bdi_wb_ctx->wb.memcg_css = &root_mem_cgroup->css;
bdi_wb_ctx->wb.blkcg_css = blkcg_root_css;
@@ -1000,7 +1001,7 @@ static int cgwb_bdi_init(struct backing_dev_info *bdi)
for_each_bdi_wb_ctx(bdi, bdi_wb_ctx) {
int ret;

- ret = wb_init(&bdi_wb_ctx->wb, bdi, GFP_KERNEL);
+ ret = wb_init(&bdi_wb_ctx->wb, bdi_wb_ctx, bdi, GFP_KERNEL);
if (ret)
return ret;
}
--
2.25.1