f2fs: show more info if fail to issue discard
Subsystems (2)
Chao Yu
maintainerPATCH 1/3 f2fs: show more info if fail to issue discard
From: Chao Yu <[email protected]>
Signed-off-by Chao Yu <[email protected]>
--- fs/f2fs/segment.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +2 -1
@@ -740,7 +740,8 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi,if (dc->error)f2fs_msg (sbi->sb,KERN_INFO , -"Issue discard failed, ret: %d" , dc->error); +"Issue discard(%u, %u, %u) failed, ret: %d" , + dc->lstart, dc->start, dc->len, dc->error);__detach_discard_cmd (dcc, dc); }
Signature · 6 lines
2.12.2.575.gb14f27f ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Chao Yu
maintainerPATCH 2/3 f2fs: wake up all waiters in f2fs_submit_discard_endio
From: Chao Yu <[email protected]>
There could be more than one waiter waiting discard IO completion, so we need use complete_all() instead of complete() in f2fs_submit_discard_endio to avoid hungtask.
Fixes ec9895add2c5 ("f2fs: don't hold cmd_lock during waiting discard
command")
Cc <[email protected]>
Signed-off-by Chao Yu <[email protected]>
--- fs/f2fs/segment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +1 -1
@@ -751,7 +751,7 @@ static void f2fs_submit_discard_endio(struct bio *bio) dc->error = bio->bi_error; dc->state =D_DONE ; -complete (&dc->wait); +complete_all (&dc->wait);bio_put (bio); }
Signature · 1 line
2.12.2.575.gb14f27f
Chao Yu
maintainerPATCH 3/3 f2fs: wait discard IO completion without cmd_lock held
In reply to Chao YuFrom: Chao Yu <[email protected]>
Wait discard IO completion outside cmd_lock to avoid long latency of holding cmd_lock in IO busy scenario.
Signed-off-by Chao Yu <[email protected]>
--- fs/f2fs/segment.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
fs/f2fs/segment.c +20 -3
@@ -1005,17 +1005,34 @@ static void __wait_discard_cmd(struct f2fs_sb_info *sbi, bool wait_cond)struct discard_cmd_control *dcc =SM_I (sbi)->dcc_info;struct list_head *wait_list = &(dcc->wait_list);struct discard_cmd *dc, *tmp; +bool need_wait; + +next: + need_wait = false;mutex_lock (&dcc->cmd_lock);list_for_each_entry_safe (dc, tmp, wait_list, list) { -if (!wait_cond || dc->state ==D_DONE ) { -if (dc->ref) -continue ; +if (!wait_cond || (dc->state ==D_DONE && !dc->ref)) {wait_for_completion_io (&dc->wait);__remove_discard_cmd (sbi, dc); + }else { + dc->ref++; + need_wait = true; +break ; } }mutex_unlock (&dcc->cmd_lock); + +if (need_wait) { +wait_for_completion_io (&dc->wait); +mutex_lock (&dcc->cmd_lock); +f2fs_bug_on (sbi, dc->state !=D_DONE ); + dc->ref--; +if (!dc->ref) +__remove_discard_cmd (sbi, dc); +mutex_unlock (&dcc->cmd_lock); + goto next; + } }/* This should be covered by global mutex, &sit_i->sentry_lock */
Signature · 6 lines
2.12.2.575.gb14f27f ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot