Archive-only list for patches
 help / color / mirror / Atom feed
From: Kundan Kumar <kundan.kumar@samsung.com>
To: mcgrof@kernel.org
Cc: patches@lists.linux.dev, Kundan Kumar <kundan.kumar@samsung.com>,
	Anuj Gupta <anuj20.g@samsung.com>
Subject: [PATCH v2 09/15] f2fs: add support in f2fs to handle multiple writeback contexts
Date: Thu,  7 Aug 2025 10:27:00 +0530	[thread overview]
Message-ID: <20250807045706.2848-10-kundan.kumar@samsung.com> (raw)
In-Reply-To: <20250807045706.2848-1-kundan.kumar@samsung.com>

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

Made a new helper for same.

Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
 fs/f2fs/node.c              |  4 ++--
 fs/f2fs/segment.h           |  2 +-
 include/linux/backing-dev.h | 20 ++++++++++++++++----
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 6c89c8f025c2..8e0220ffea29 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -73,7 +73,7 @@ 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[0]->wb.dirty_exceeded)
+		if (bdi_wb_dirty_limit_exceeded(sbi->sb->s_bdi))
 			return false;
 		mem_size = get_pages(sbi, F2FS_DIRTY_DENTS);
 		res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1);
@@ -114,7 +114,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
 		res = false;
 #endif
 	} else {
-		if (!sbi->sb->s_bdi->wb_ctx[0]->wb.dirty_exceeded)
+		if (!bdi_wb_dirty_limit_exceeded(sbi->sb->s_bdi))
 			return true;
 	}
 	return res;
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index ca8f8e53c80d..7d13b75c4fdc 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -1000,7 +1000,7 @@ 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[0]->wb.dirty_exceeded)
+	if (bdi_wb_dirty_limit_exceeded(sbi->sb->s_bdi))
 		return 0;
 
 	if (type == DATA)
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 6f744aadd83e..831cd9f51162 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -51,6 +51,22 @@ static inline bool wb_has_dirty_io(struct bdi_writeback *wb)
 	return test_bit(WB_has_dirty_io, &wb->state);
 }
 
+#define for_each_bdi_wb_ctx(bdi, wbctx) \
+	for (int __i = 0; __i < (bdi)->nr_wb_ctx \
+		&& ((wbctx) = (bdi)->wb_ctx[__i]) != NULL; __i++)
+
+
+static inline bool bdi_wb_dirty_limit_exceeded(struct backing_dev_info *bdi)
+{
+	struct bdi_writeback_ctx *bdi_wb_ctx;
+
+	for_each_bdi_wb_ctx(bdi, bdi_wb_ctx) {
+		if (bdi_wb_ctx->wb.dirty_exceeded)
+			return true;
+	}
+	return false;
+}
+
 static inline bool bdi_has_dirty_io(struct backing_dev_info *bdi)
 {
 	/*
@@ -148,10 +164,6 @@ static inline bool mapping_can_writeback(struct address_space *mapping)
 	return inode_to_bdi(mapping->host)->capabilities & BDI_CAP_WRITEBACK;
 }
 
-#define for_each_bdi_wb_ctx(bdi, wbctx) \
-	for (int __i = 0; __i < (bdi)->nr_wb_ctx \
-		&& ((wbctx) = (bdi)->wb_ctx[__i]) != NULL; __i++)
-
 static inline struct bdi_writeback_ctx *
 fetch_bdi_writeback_ctx(struct inode *inode)
 {
-- 
2.25.1


  parent reply	other threads:[~2025-08-07  4:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20250807045740epcas5p4cdec49f07b86acf2eea832890393d256@epcas5p4.samsung.com>
2025-08-07  4:56 ` [PATCH v2 00/15] Test patch Parallelizing filesystem writeback Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 01/15] writeback: add infra for parallel writeback Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 02/15] writeback: add support to initialize and free multiple writeback ctxs Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 03/15] writeback: link bdi_writeback to its corresponding bdi_writeback_ctx Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 04/15] writeback: affine inode to a writeback ctx within a bdi Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 05/15] writeback: modify bdi_writeback search logic to search across all wb ctxs Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 06/15] writeback: invoke all writeback contexts for flusher and dirtytime writeback Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 07/15] writeback: modify sync related functions to iterate over all writeback contexts Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 08/15] writeback: add support to collect stats for all writeback ctxs Kundan Kumar
2025-08-07  4:57   ` Kundan Kumar [this message]
2025-08-07  4:57   ` [PATCH v2 10/15] fuse: add support for multiple writeback contexts in fuse Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 11/15] gfs2: add support in gfs2 to handle multiple writeback contexts Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 12/15] nfs: add support in nfs " Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 13/15] writeback: set the num of writeback contexts to number of online cpus Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 14/15] writeback: segregated allocation and free of writeback contexts Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 15/15] writeback: added support to change the number of writebacks using a sysfs attribute Kundan Kumar
2025-08-07 18:34   ` [PATCH v2 00/15] Test patch Parallelizing filesystem writeback Luis Chamberlain
     [not found] <CGME20250725155506epcas5p3db90b1c2f47ed6f67c18825f0a39c51b@epcas5p3.samsung.com>
2025-07-25 15:54 ` [PATCH v2 00/15] " Kundan Kumar
2025-07-25 15:54   ` [PATCH v2 09/15] f2fs: add support in f2fs to handle multiple writeback contexts Kundan Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250807045706.2848-10-kundan.kumar@samsung.com \
    --to=kundan.kumar@samsung.com \
    --cc=anuj20.g@samsung.com \
    --cc=mcgrof@kernel.org \
    --cc=patches@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox