Skip to contentSkip to conversation

f2fs: forbid to do fstrim if fs has some error

PATCH In review Yunlei He 3 participants 5 messages Sep 1, 2016 – Sep 9, 2016 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: forbid to do fstrim if fs has some error

This patch skip fstrim if sbi set SBI_NEED_FSCK flag

---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)
fs/f2fs/segment.c +3 -0
index 93c5e26..1b62213 100644
@@ -1353,6 +1353,9 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
 	if (end <= MAIN_BLKADDR(sbi))
 		goto out;
 
+	if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
+		goto out;
+
 	/* start/end segment number in main_area */
 	start_segno = (start <= MAIN_BLKADDR(sbi)) ? 0 : GET_SEGNO(sbi, start);
 	end_segno = (end >= MAX_BLKADDR(sbi)) ? MAIN_SEGS(sbi) - 1 :
Signature · 4 lines
1.9.1


------------------------------------------------------------------------------
maintainer
#1 lore raw

Hi Yunlei,

Quoted 12 lines · Yunlei He

This patch skip fstrim if sbi set SBI_NEED_FSCK flag

---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)
fs/f2fs/segment.c +0 -0
index 93c5e26..1b62213 100644

fs/f2fs/segment.c int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) · line 1357

Quoted 5 lines
fs/f2fs/segment.c +2 -0
@@ -1353,6 +1353,9 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
 	if (end <= MAIN_BLKADDR(sbi))
 		goto out;
 
+	if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
+		goto out;

IMO, it's better to check this condition in f2fs_ioc_fstrim, and return error number to user, such as EIO?

Thanks,

fs/f2fs/segment.c int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) · line 1361

Quoted 5 lines
fs/f2fs/segment.c +1 -0
+
 	/* start/end segment number in main_area */
 	start_segno = (start <= MAIN_BLKADDR(sbi)) ? 0 : GET_SEGNO(sbi, start);
 	end_segno = (end >= MAX_BLKADDR(sbi)) ? MAIN_SEGS(sbi) - 1 :

------------------------------------------------------------------------------

maintainer
#2 lore raw
Quoted 18 lines · Chao Yu

Hi Yunlei,

Quoted 15 lines · Yunlei He

This patch skip fstrim if sbi set SBI_NEED_FSCK flag

---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)
fs/f2fs/segment.c +0 -0
index 93c5e26..1b62213 100644
@@ -1353,6 +1353,9 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
 	if (end <= MAIN_BLKADDR(sbi))
 		goto out;
 
Quoted 5 lines

fs/f2fs/segment.c int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) · line 1357

Quoted 2 lines
fs/f2fs/segment.c +2 -0
+	if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
+		goto out;

IMO, it's better to check this condition in f2fs_ioc_fstrim, and return error number to user, such as EIO?

I don't think it's an error case such as EIO, ENOMEM, EINVAL, and so on. Instead, It'd be okay to return trimmed size with zero.
Oh, we'd better give a message to notify like this?

	f2fs_msg(sbi->sb, KERN_WARNING,
		"Found FS corruption, run fsck to fix.");

Thanks,

------------------------------------------------------------------------------

maintainer
#3 lore raw
Quoted 25 lines · Jaegeuk Kim
Quoted 18 lines · Chao Yu

Hi Yunlei,

Quoted 15 lines · Yunlei He

This patch skip fstrim if sbi set SBI_NEED_FSCK flag

---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)
fs/f2fs/segment.c +0 -0
index 93c5e26..1b62213 100644
@@ -1353,6 +1353,9 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
 	if (end <= MAIN_BLKADDR(sbi))
 		goto out;
 
Quoted 5 lines

fs/f2fs/segment.c int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) · line 1357

Quoted 2 lines
fs/f2fs/segment.c +2 -0
+	if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
+		goto out;

IMO, it's better to check this condition in f2fs_ioc_fstrim, and return error number to user, such as EIO?

Quoted 6 lines

I don't think it's an error case such as EIO, ENOMEM, EINVAL, and so on. Instead, It'd be okay to return trimmed size with zero.
Oh, we'd better give a message to notify like this?

	f2fs_msg(sbi->sb, KERN_WARNING,
		"Found FS corruption, run fsck to fix.");

Hmm.. leave some dmesg looks okay to me.

So, Yunlei, how do you think of it?

Thanks,

Quoted 3 lines

Thanks,

------------------------------------------------------------------------------

author
#4 lore raw
Quoted 3 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
Quoted 1 line · Chao Yu

Hi Yunlei,

Hi all,

Quoted 27 lines
Quoted 27 lines
Quoted 17 lines · Yunlei He
Quoted 15 lines

This patch skip fstrim if sbi set SBI_NEED_FSCK flag

---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)
fs/f2fs/segment.c +0 -0
index 93c5e26..1b62213 100644
@@ -1353,6 +1353,9 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
 	if (end <= MAIN_BLKADDR(sbi))
 		goto out;
 
Quoted 5 lines

fs/f2fs/segment.c int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) · line 1357

Quoted 2 lines
fs/f2fs/segment.c +2 -0
+	if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
+		goto out;

IMO, it's better to check this condition in f2fs_ioc_fstrim, and return error number to user, such as EIO?

I don't think it's an error case such as EIO, ENOMEM, EINVAL, and so on. Instead, It'd be okay to return trimmed size with zero.
Oh, we'd better give a message to notify like this?

Quoted 6 lines
Quoted 2 lines
	f2fs_msg(sbi->sb, KERN_WARNING,
		"Found FS corruption, run fsck to fix.");

Hmm.. leave some dmesg looks okay to me.

So, Yunlei, how do you think of it?

Yes, it looks good to me, which make debug is easy when we do fstrim to discard some invalid blocks, but zero is return.

Thanks,

Quoted 9 lines

Thanks,

Quoted 3 lines

Thanks,

.

------------------------------------------------------------------------------