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

Signed-off-by: Kundan Kumar <kundan.ku...@samsung.com>
Signed-off-by: Anuj Gupta <anuj2...@samsung.com>
---
 fs/f2fs/node.c    | 11 +++++++----
 fs/f2fs/segment.h |  7 +++++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 4b6568cd5bef..19f208d6c6d3 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -50,6 +50,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int 
type)
        unsigned long avail_ram;
        unsigned long mem_size = 0;
        bool res = false;
+       struct bdi_writeback_ctx *bdi_wb_ctx;
 
        if (!nm_i)
                return true;
@@ -73,8 +74,9 @@ 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_ctx_arr[0]->wb.dirty_exceeded)
-                       return false;
+               for_each_bdi_wb_ctx(sbi->sb->s_bdi, bdi_wb_ctx)
+                       if (bdi_wb_ctx->wb.dirty_exceeded)
+                               return false;
                mem_size = get_pages(sbi, F2FS_DIRTY_DENTS);
                res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1);
        } else if (type == INO_ENTRIES) {
@@ -114,8 +116,9 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, 
int type)
                res = false;
 #endif
        } else {
-               if (!sbi->sb->s_bdi->wb_ctx_arr[0]->wb.dirty_exceeded)
-                       return true;
+               for_each_bdi_wb_ctx(sbi->sb->s_bdi, bdi_wb_ctx)
+                       if (bdi_wb_ctx->wb.dirty_exceeded)
+                               return false;
        }
        return res;
 }
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index a525ccd4cfc8..2eea08549d73 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -936,8 +936,11 @@ 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_ctx_arr[0]->wb.dirty_exceeded)
-               return 0;
+       struct bdi_writeback_ctx *bdi_wb_ctx;
+
+       for_each_bdi_wb_ctx(sbi->sb->s_bdi, bdi_wb_ctx)
+               if (bdi_wb_ctx->wb.dirty_exceeded)
+                       return 0;
 
        if (type == DATA)
                return BLKS_PER_SEG(sbi);
-- 
2.25.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to