f2fs: better to wait for fstrim completion

In android, we'd better wait for fstrim completion instead of issuing the
discard commands asynchronous.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

+6 -1
+6 -1
fs/f2fs/segment.c
··· 17 17 #include <linux/swap.h> 18 18 #include <linux/timer.h> 19 19 #include <linux/freezer.h> 20 + #include <linux/sched/signal.h> 20 21 21 22 #include "f2fs.h" 22 23 #include "segment.h" ··· 1062 1061 if (dcc->pend_list_tag[i] & P_TRIM) { 1063 1062 __submit_discard_cmd(sbi, dc); 1064 1063 issued++; 1064 + 1065 + if (fatal_signal_pending(current)) 1066 + break; 1065 1067 continue; 1066 1068 } 1067 1069 ··· 1181 1177 } 1182 1178 } 1183 1179 1184 - /* This comes from f2fs_put_super */ 1180 + /* This comes from f2fs_put_super and f2fs_trim_fs */ 1185 1181 void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi) 1186 1182 { 1187 1183 __issue_discard_cmd(sbi, false); ··· 2216 2212 } 2217 2213 /* It's time to issue all the filed discards */ 2218 2214 mark_discard_range_all(sbi); 2215 + f2fs_wait_discard_bios(sbi); 2219 2216 out: 2220 2217 range->len = F2FS_BLK_TO_BYTES(cpc.trimmed); 2221 2218 return err;