Skip to contentSkip to conversation

f2fs: skip adding a discard command if exists

PATCH Applied Jaegeuk Kim 3 participants 7 messages Nov 14, 2023 – Nov 30, 2023 F2FS file system

lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/1 f2fs: skip adding a discard command if exists

When recovering zoned UFS, sometimes we add the same zone to discard multiple times. Simple workaround is to bypass adding it.

---
 fs/f2fs/segment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
index 727d016318f9..f4ffd64b44b2 100644
@@ -1380,7 +1380,8 @@ static void __insert_discard_cmd(struct f2fs_sb_info *sbi,
 			p = &(*p)->rb_right;
 			leftmost = false;
 		} else {
-			f2fs_bug_on(sbi, 1);
+			/* Let's skip to add, if exists */
+			return;
 		}
 	}
 
Signature · 1 line
2.43.0.rc0.421.g78406f8d94-goog
maintainer
#1 lore raw
Quoted 2 lines · Jaegeuk Kim

When recovering zoned UFS, sometimes we add the same zone to discard multiple times. Simple workaround is to bypass adding it.

What about skipping f2fs_bug_on() just for zoned UFS case? so that the check condition can still be used for non-zoned UFS case.

Thanks,

Quoted 20 lines
---
  fs/f2fs/segment.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
index 727d016318f9..f4ffd64b44b2 100644
@@ -1380,7 +1380,8 @@ static void __insert_discard_cmd(struct f2fs_sb_info *sbi,
  			p = &(*p)->rb_right;
  			leftmost = false;
  		} else {
-			f2fs_bug_on(sbi, 1);
+			/* Let's skip to add, if exists */
+			return;
  		}
  	}
 
author maintainer
#2 lore raw
Quoted 6 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim

When recovering zoned UFS, sometimes we add the same zone to discard multiple times. Simple workaround is to bypass adding it.

What about skipping f2fs_bug_on() just for zoned UFS case? so that the check condition can still be used for non-zoned UFS case.

Hmm, I've never seen this bug_on before, but even this really happens, it does not make sense to move forward to create duplicate commands resulting in a loop.

So, the question is, do we really need to check this? Have we hit this before?

Quoted 22 lines

Thanks,

Quoted 19 lines
---
  fs/f2fs/segment.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
index 727d016318f9..f4ffd64b44b2 100644
@@ -1380,7 +1380,8 @@ static void __insert_discard_cmd(struct f2fs_sb_info *sbi,
  			p = &(*p)->rb_right;
  			leftmost = false;
  		} else {
-			f2fs_bug_on(sbi, 1);
+			/* Let's skip to add, if exists */
+			return;
  		}
  	}
maintainer
#3 lore raw
Quoted 9 lines · Jaegeuk Kim
Quoted 6 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim

When recovering zoned UFS, sometimes we add the same zone to discard multiple times. Simple workaround is to bypass adding it.

What about skipping f2fs_bug_on() just for zoned UFS case? so that the check condition can still be used for non-zoned UFS case.

Hmm, I've never seen this bug_on before, but even this really happens, it does

I've never seen it was been triggered as well.

Quoted 1 line

not make sense to move forward to create duplicate commands resulting in a loop.

Agreed.

It looks those codes were copied from extent_cache code base, do we need to fix all cases to avoid loop?

Quoted 2 lines

So, the question is, do we really need to check this? Have we hit this before?

Not sure, just be worry about that flaw of newly developed feature can make code run into that branch.

Thanks,

Quoted 23 lines
Quoted 23 lines

Thanks,

Quoted 19 lines
---
   fs/f2fs/segment.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
index 727d016318f9..f4ffd64b44b2 100644
@@ -1380,7 +1380,8 @@ static void __insert_discard_cmd(struct f2fs_sb_info *sbi,
   			p = &(*p)->rb_right;
   			leftmost = false;
   		} else {
-			f2fs_bug_on(sbi, 1);
+			/* Let's skip to add, if exists */
+			return;
   		}
   	}
author maintainer
#4 lore raw
Quoted 11 lines · Chao Yu
Quoted 9 lines · Jaegeuk Kim
Quoted 6 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim

When recovering zoned UFS, sometimes we add the same zone to discard multiple times. Simple workaround is to bypass adding it.

What about skipping f2fs_bug_on() just for zoned UFS case? so that the check condition can still be used for non-zoned UFS case.

Hmm, I've never seen this bug_on before, but even this really happens, it does

Quoted 8 lines

I've never seen it was been triggered as well.

Quoted 1 line

not make sense to move forward to create duplicate commands resulting in a loop.

Agreed.

It looks those codes were copied from extent_cache code base, do we need to fix all cases to avoid loop?

Not sure other cases yet.. let's do one by one, since I hit this in real.

Quoted 31 lines
Quoted 3 lines

So, the question is, do we really need to check this? Have we hit this before?

Not sure, just be worry about that flaw of newly developed feature can make code run into that branch.

Thanks,

Quoted 23 lines
Quoted 23 lines

Thanks,

Quoted 19 lines
---
   fs/f2fs/segment.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
index 727d016318f9..f4ffd64b44b2 100644
@@ -1380,7 +1380,8 @@ static void __insert_discard_cmd(struct f2fs_sb_info *sbi,
   			p = &(*p)->rb_right;
   			leftmost = false;
   		} else {
-			f2fs_bug_on(sbi, 1);
+			/* Let's skip to add, if exists */
+			return;
   		}
   	}
#6 lore raw
In reply to Jaegeuk Kim
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 7 lines · On Tue, 14 Nov 2023 13:24:14 -0800 you wrote:

When recovering zoned UFS, sometimes we add the same zone to discard multiple times. Simple workaround is to bypass adding it.

---
 fs/f2fs/segment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Here is the summary with links:
- [f2fs-dev] f2fs: skip adding a discard command if exists

    https://git.kernel.org/jaegeuk/f2fs/c/bbd3efed3383

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html