All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 4/5] f2fs: do not stop GC when requiring a free section
Date: Thu, 12 May 2022 10:04:01 +0800	[thread overview]
Message-ID: <ab569309-f639-33af-ebb3-909a02158d02@kernel.org> (raw)
In-Reply-To: <Ynvoszmp7+64NdZg@google.com>

On 2022/5/12 0:47, Jaegeuk Kim wrote:
>>>>> @@ -147,6 +147,7 @@ static int gc_thread_func(void *data)
>>>>>     		gc_control.init_gc_type = sync_mode ? FG_GC : BG_GC;
>>>>>     		gc_control.no_bg_gc = foreground;
>>>>> +		gc_control.nr_free_secs = foreground ? 1 : 0;

[snip]

> 
> I mean gc_control->nr_free_secs should be 0.

[snip]

>>>>> @@ -528,7 +528,8 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
>>>>>     				.init_gc_type = BG_GC,
>>>>>     				.no_bg_gc = true,
>>>>>     				.should_migrate_blocks = false,
>>>>> -				.err_gc_skipped = false };
>>>>> +				.err_gc_skipped = false,
>>>>> +				.nr_free_secs = 1 };

Oh, so, in above two paths, when .nr_free_secs is 1, no_bg_gc should be true
to keep skipping BG_GC flow.

How about adding a check condition in f2fs_gc() to avoid invalid argument
usage in future?

From: Chao Yu <chao@kernel.org>

---
  fs/f2fs/gc.c | 17 +++++++++++++----
  1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 385282017317..a98276fd3cc1 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -1799,10 +1799,19 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
  			gc_type = FG_GC;
  	}

-	/* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
-	if (gc_type == BG_GC && gc_control->no_bg_gc) {
-		ret = -EINVAL;
-		goto stop;
+	if (gc_type == BG_GC) {
+		/* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
+		if (gc_control->no_bg_gc) {
+			ret = -EINVAL;
+			goto stop;
+		}
+		/*
+		 * BG_GC never guarantee that blocks are migrated synchronously.
+		 */
+		if (gc_control->nr_free_secs) {
+			ret = -EINVAL;
+			goto stop;
+		}
  	}
  retry:
  	ret = __get_victim(sbi, &segno, gc_type);
-- 
2.25.1



Thanks,

WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <chao@kernel.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 4/5] f2fs: do not stop GC when requiring a free section
Date: Thu, 12 May 2022 10:04:01 +0800	[thread overview]
Message-ID: <ab569309-f639-33af-ebb3-909a02158d02@kernel.org> (raw)
In-Reply-To: <Ynvoszmp7+64NdZg@google.com>

On 2022/5/12 0:47, Jaegeuk Kim wrote:
>>>>> @@ -147,6 +147,7 @@ static int gc_thread_func(void *data)
>>>>>     		gc_control.init_gc_type = sync_mode ? FG_GC : BG_GC;
>>>>>     		gc_control.no_bg_gc = foreground;
>>>>> +		gc_control.nr_free_secs = foreground ? 1 : 0;

[snip]

> 
> I mean gc_control->nr_free_secs should be 0.

[snip]

>>>>> @@ -528,7 +528,8 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
>>>>>     				.init_gc_type = BG_GC,
>>>>>     				.no_bg_gc = true,
>>>>>     				.should_migrate_blocks = false,
>>>>> -				.err_gc_skipped = false };
>>>>> +				.err_gc_skipped = false,
>>>>> +				.nr_free_secs = 1 };

Oh, so, in above two paths, when .nr_free_secs is 1, no_bg_gc should be true
to keep skipping BG_GC flow.

How about adding a check condition in f2fs_gc() to avoid invalid argument
usage in future?

From: Chao Yu <chao@kernel.org>

---
  fs/f2fs/gc.c | 17 +++++++++++++----
  1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 385282017317..a98276fd3cc1 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -1799,10 +1799,19 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control)
  			gc_type = FG_GC;
  	}

-	/* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
-	if (gc_type == BG_GC && gc_control->no_bg_gc) {
-		ret = -EINVAL;
-		goto stop;
+	if (gc_type == BG_GC) {
+		/* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
+		if (gc_control->no_bg_gc) {
+			ret = -EINVAL;
+			goto stop;
+		}
+		/*
+		 * BG_GC never guarantee that blocks are migrated synchronously.
+		 */
+		if (gc_control->nr_free_secs) {
+			ret = -EINVAL;
+			goto stop;
+		}
  	}
  retry:
  	ret = __get_victim(sbi, &segno, gc_type);
-- 
2.25.1



Thanks,


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

  reply	other threads:[~2022-05-12  2:04 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06 23:20 [PATCH 1/5] f2fs: stop allocating pinned sections if EAGAIN happens Jaegeuk Kim
2022-05-06 23:20 ` [f2fs-dev] " Jaegeuk Kim
2022-05-06 23:20 ` [PATCH 2/5] f2fs: introduce f2fs_gc_control to consolidate f2fs_gc parameters Jaegeuk Kim
2022-05-06 23:20   ` [f2fs-dev] " Jaegeuk Kim
2022-05-08 14:27   ` Chao Yu
2022-05-08 14:27     ` Chao Yu
2022-05-09 16:46     ` Jaegeuk Kim
2022-05-09 16:46       ` Jaegeuk Kim
2022-05-09 16:47   ` [f2fs-dev] [PATCH 2/5 v2] " Jaegeuk Kim
2022-05-09 16:47     ` Jaegeuk Kim
2022-05-11  3:16     ` [f2fs-dev] " Chao Yu
2022-05-11  3:16       ` Chao Yu
2022-05-11  3:30       ` Jaegeuk Kim
2022-05-11  3:30         ` Jaegeuk Kim
2022-05-11  3:30     ` Jaegeuk Kim
2022-05-11  3:30       ` Jaegeuk Kim
2022-05-11  8:54       ` Chao Yu
2022-05-11  8:54         ` Chao Yu
2022-05-12 20:51   ` Jaegeuk Kim
2022-05-12 20:51     ` [f2fs-dev] " Jaegeuk Kim
2022-05-06 23:20 ` [PATCH 3/5] f2fs: keep wait_ms if EAGAIN happens Jaegeuk Kim
2022-05-06 23:20   ` [f2fs-dev] " Jaegeuk Kim
2022-05-08 14:41   ` Chao Yu
2022-05-08 14:41     ` Chao Yu
2022-05-08 15:22     ` Chao Yu
2022-05-08 15:22       ` Chao Yu
2022-05-06 23:20 ` [PATCH 4/5] f2fs: do not stop GC when requiring a free section Jaegeuk Kim
2022-05-06 23:20   ` [f2fs-dev] " Jaegeuk Kim
2022-05-07  3:33   ` Chao Yu
2022-05-07  3:33     ` Chao Yu
2022-05-09 16:58     ` Jaegeuk Kim
2022-05-09 16:58       ` Jaegeuk Kim
2022-05-08 15:25   ` Chao Yu
2022-05-08 15:25     ` Chao Yu
2022-05-09 16:55     ` Jaegeuk Kim
2022-05-09 16:55       ` Jaegeuk Kim
2022-05-11  8:53       ` Chao Yu
2022-05-11  8:53         ` Chao Yu
2022-05-11 16:47         ` Jaegeuk Kim
2022-05-11 16:47           ` Jaegeuk Kim
2022-05-12  2:04           ` Chao Yu [this message]
2022-05-12  2:04             ` Chao Yu
2022-05-12 21:05             ` Jaegeuk Kim
2022-05-12 21:05               ` Jaegeuk Kim
2022-05-12 20:50   ` [PATCH 4/5 v2] " Jaegeuk Kim
2022-05-12 20:50     ` [f2fs-dev] " Jaegeuk Kim
2022-05-12 21:54     ` Jaegeuk Kim
2022-05-12 21:54       ` Jaegeuk Kim
2022-05-15 14:26     ` Chao Yu
2022-05-15 14:26       ` Chao Yu
2022-05-16 17:29       ` Jaegeuk Kim
2022-05-16 17:29         ` Jaegeuk Kim
2022-05-17  2:19         ` Chao Yu
2022-05-17  2:19           ` Chao Yu
2022-05-06 23:20 ` [PATCH 5/5] f2fs: don't need inode lock for system hidden quota Jaegeuk Kim
2022-05-06 23:20   ` [f2fs-dev] " Jaegeuk Kim
2022-05-08 13:56 ` [f2fs-dev] [PATCH 1/5] f2fs: stop allocating pinned sections if EAGAIN happens Chao Yu
2022-05-08 13:56   ` Chao Yu

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=ab569309-f639-33af-ebb3-909a02158d02@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.