diff options
author | Chao Yu <yuchao0@huawei.com> | 2017-06-05 06:29:06 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2017-07-04 05:11:36 -0400 |
commit | 2a510c005c9d3fafbaae1a6d27da8256c95542f9 (patch) | |
tree | 5779f9476578ef9056399d726da159d0f5d14edc /fs/f2fs | |
parent | 5a3a2d83cda82df7f8c306df85647d2c368e829a (diff) |
f2fs: introduce __wait_one_discard_bio
In order to avoid copied codes.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/segment.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index a739803b6513..0fa717a47394 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -995,6 +995,20 @@ out: | |||
995 | mutex_unlock(&dcc->cmd_lock); | 995 | mutex_unlock(&dcc->cmd_lock); |
996 | } | 996 | } |
997 | 997 | ||
998 | static void __wait_one_discard_bio(struct f2fs_sb_info *sbi, | ||
999 | struct discard_cmd *dc) | ||
1000 | { | ||
1001 | struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; | ||
1002 | |||
1003 | wait_for_completion_io(&dc->wait); | ||
1004 | mutex_lock(&dcc->cmd_lock); | ||
1005 | f2fs_bug_on(sbi, dc->state != D_DONE); | ||
1006 | dc->ref--; | ||
1007 | if (!dc->ref) | ||
1008 | __remove_discard_cmd(sbi, dc); | ||
1009 | mutex_unlock(&dcc->cmd_lock); | ||
1010 | } | ||
1011 | |||
998 | static void __wait_discard_cmd(struct f2fs_sb_info *sbi, bool wait_cond) | 1012 | static void __wait_discard_cmd(struct f2fs_sb_info *sbi, bool wait_cond) |
999 | { | 1013 | { |
1000 | struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; | 1014 | struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; |
@@ -1019,13 +1033,7 @@ next: | |||
1019 | mutex_unlock(&dcc->cmd_lock); | 1033 | mutex_unlock(&dcc->cmd_lock); |
1020 | 1034 | ||
1021 | if (need_wait) { | 1035 | if (need_wait) { |
1022 | wait_for_completion_io(&dc->wait); | 1036 | __wait_one_discard_bio(sbi, dc); |
1023 | mutex_lock(&dcc->cmd_lock); | ||
1024 | f2fs_bug_on(sbi, dc->state != D_DONE); | ||
1025 | dc->ref--; | ||
1026 | if (!dc->ref) | ||
1027 | __remove_discard_cmd(sbi, dc); | ||
1028 | mutex_unlock(&dcc->cmd_lock); | ||
1029 | goto next; | 1037 | goto next; |
1030 | } | 1038 | } |
1031 | } | 1039 | } |
@@ -1049,15 +1057,8 @@ void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr) | |||
1049 | } | 1057 | } |
1050 | mutex_unlock(&dcc->cmd_lock); | 1058 | mutex_unlock(&dcc->cmd_lock); |
1051 | 1059 | ||
1052 | if (need_wait) { | 1060 | if (need_wait) |
1053 | wait_for_completion_io(&dc->wait); | 1061 | __wait_one_discard_bio(sbi, dc); |
1054 | mutex_lock(&dcc->cmd_lock); | ||
1055 | f2fs_bug_on(sbi, dc->state != D_DONE); | ||
1056 | dc->ref--; | ||
1057 | if (!dc->ref) | ||
1058 | __remove_discard_cmd(sbi, dc); | ||
1059 | mutex_unlock(&dcc->cmd_lock); | ||
1060 | } | ||
1061 | } | 1062 | } |
1062 | 1063 | ||
1063 | /* This comes from f2fs_put_super */ | 1064 | /* This comes from f2fs_put_super */ |