[PATCH v2 05/16] writeback: modify bdi_writeback search logic to search across all wb ctxs

Kundan Kumar
2025-10-14T12:10:42Z

Since we have multiple cgwb per bdi, embedded in writeback_ctx now, we
iterate over all of them to find the associated writeback.

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

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 56c048e22f72..93f8ea340247 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -1090,7 +1090,8 @@ int cgroup_writeback_by_id(u64 bdi_id, int memcg_id,
{
struct backing_dev_info *bdi;
struct cgroup_subsys_state *memcg_css;
- struct bdi_writeback *wb;
+ struct bdi_writeback *wb = NULL;
+ struct bdi_writeback_ctx *bdi_wb_ctx;
struct wb_writeback_work *work;
unsigned long dirty;
int ret;
@@ -1114,7 +1115,11 @@ int cgroup_writeback_by_id(u64 bdi_id, int memcg_id,
* And find the associated wb. If the wb isn't there already
* there's nothing to flush, don't create one.
*/
- wb = wb_get_lookup(bdi->wb_ctx[0], memcg_css);
+ for_each_bdi_wb_ctx(bdi, bdi_wb_ctx) {
+ wb = wb_get_lookup(bdi_wb_ctx, memcg_css);
+ if (wb)
+ break;
+ }
if (!wb) {
ret = -ENOENT;
goto out_css_put;
--
2.25.1