Skip to content

Commit

Permalink
f2fs: better to wait for fstrim completion
Browse files Browse the repository at this point in the history
In android, we'd better wait for fstrim completion instead of issuing the
discard commands asynchronous.

Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
Jaegeuk Kim committed Sep 12, 2017
1 parent 27161f1 commit 1eb1ef4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/swap.h>
#include <linux/timer.h>
#include <linux/freezer.h>
#include <linux/sched/signal.h>

#include "f2fs.h"
#include "segment.h"
Expand Down Expand Up @@ -1061,6 +1062,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;
}

Expand Down Expand Up @@ -1177,7 +1181,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);
Expand Down Expand Up @@ -2212,6 +2216,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;
Expand Down

0 comments on commit 1eb1ef4

Please sign in to comment.