diff mbox

[2/2] f2fs: better to wait for fstrim completion

Message ID 20170909191710.81288-2-jaegeuk@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Jaegeuk Kim Sept. 9, 2017, 7:17 p.m. UTC
In android, we'd better wait for fstrim completion instead of issuing the
discard commands asynchronous.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/segment.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Chao Yu Sept. 11, 2017, 10:35 a.m. UTC | #1
On 2017/9/10 3:17, Jaegeuk Kim wrote:
> In android, we'd better wait for fstrim completion instead of issuing the
> discard commands asynchronous.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

> ---
>  fs/f2fs/segment.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index f96e61e8ddf7..beb15c834a34 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1076,6 +1076,9 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond)
>  			if (dcc->pend_list_tag[i] & P_TRIM) {
>  				__submit_discard_cmd(sbi, dc);
>  				issued++;
> +
> +				if (fatal_signal_pending(current))
> +					break;
>  				continue;
>  			}
>  
> @@ -1192,7 +1195,7 @@ void stop_discard_thread(struct f2fs_sb_info *sbi)
>  	}
>  }
>  
> -/* This comes from f2fs_put_super */
> +/* This comes from f2fs_put_super and f2fs_trim_fs */
>  void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi)
>  {
>  	__issue_discard_cmd(sbi, false);
> @@ -2227,6 +2230,7 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
>  	}
>  	/* It's time to issue all the filed discards */
>  	mark_discard_range_all(sbi);
> +	f2fs_wait_discard_bios(sbi);
>  out:
>  	range->len = F2FS_BLK_TO_BYTES(cpc.trimmed);
>  	return err;
>
diff mbox

Patch

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index f96e61e8ddf7..beb15c834a34 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1076,6 +1076,9 @@  static int __issue_discard_cmd(struct f2fs_sb_info *sbi, bool issue_cond)
 			if (dcc->pend_list_tag[i] & P_TRIM) {
 				__submit_discard_cmd(sbi, dc);
 				issued++;
+
+				if (fatal_signal_pending(current))
+					break;
 				continue;
 			}
 
@@ -1192,7 +1195,7 @@  void stop_discard_thread(struct f2fs_sb_info *sbi)
 	}
 }
 
-/* This comes from f2fs_put_super */
+/* This comes from f2fs_put_super and f2fs_trim_fs */
 void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi)
 {
 	__issue_discard_cmd(sbi, false);
@@ -2227,6 +2230,7 @@  int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
 	}
 	/* It's time to issue all the filed discards */
 	mark_discard_range_all(sbi);
+	f2fs_wait_discard_bios(sbi);
 out:
 	range->len = F2FS_BLK_TO_BYTES(cpc.trimmed);
 	return err;