OSDN Git Service

f2fs: better to wait for fstrim completion
authorJaegeuk Kim <jaegeuk@kernel.org>
Sat, 9 Sep 2017 19:03:23 +0000 (12:03 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 21 Sep 2017 21:52:38 +0000 (14:52 -0700)
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>
fs/f2fs/segment.c

index e954700..8ee473b 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/swap.h>
 #include <linux/timer.h>
 #include <linux/freezer.h>
+#include <linux/sched.h>
 
 #include "f2fs.h"
 #include "segment.h"
@@ -1141,6 +1142,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;
                        }
 
@@ -1257,7 +1261,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);
@@ -2292,6 +2296,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;