* [PATCH 1/3] f2fs: show more info if fail to issue discard
@ 2017-05-19 15:46 ` Chao Yu
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2017-05-19 15:46 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel
From: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/segment.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index a29919330e27..d310b82caef1 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -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);
}
--
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/3] f2fs: show more info if fail to issue discard
@ 2017-05-19 15:46 ` Chao Yu
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2017-05-19 15:46 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu
From: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/segment.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index a29919330e27..d310b82caef1 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -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);
}
--
2.12.2.575.gb14f27f
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] f2fs: wake up all waiters in f2fs_submit_discard_endio
2017-05-19 15:46 ` Chao Yu
@ 2017-05-19 15:46 ` Chao Yu
-1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2017-05-19 15:46 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, stable, linux-f2fs-devel
From: Chao Yu <yuchao0@huawei.com>
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: <stable@vger.kernel.org>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/segment.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index d310b82caef1..2b11119d9071 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -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);
}
--
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
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/3] f2fs: wake up all waiters in f2fs_submit_discard_endio
@ 2017-05-19 15:46 ` Chao Yu
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2017-05-19 15:46 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu, stable
From: Chao Yu <yuchao0@huawei.com>
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: <stable@vger.kernel.org>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/segment.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index d310b82caef1..2b11119d9071 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -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);
}
--
2.12.2.575.gb14f27f
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] f2fs: wait discard IO completion without cmd_lock held
2017-05-19 15:46 ` Chao Yu
@ 2017-05-19 15:46 ` Chao Yu
-1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2017-05-19 15:46 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel
From: Chao Yu <yuchao0@huawei.com>
Wait discard IO completion outside cmd_lock to avoid long latency
of holding cmd_lock in IO busy scenario.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/segment.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 2b11119d9071..2b926db0588b 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -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 */
--
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
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/3] f2fs: wait discard IO completion without cmd_lock held
@ 2017-05-19 15:46 ` Chao Yu
0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2017-05-19 15:46 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu
From: Chao Yu <yuchao0@huawei.com>
Wait discard IO completion outside cmd_lock to avoid long latency
of holding cmd_lock in IO busy scenario.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/segment.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 2b11119d9071..2b926db0588b 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -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 */
--
2.12.2.575.gb14f27f
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-19 15:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-19 15:46 [PATCH 1/3] f2fs: show more info if fail to issue discard Chao Yu
2017-05-19 15:46 ` Chao Yu
2017-05-19 15:46 ` [PATCH 2/3] f2fs: wake up all waiters in f2fs_submit_discard_endio Chao Yu
2017-05-19 15:46 ` Chao Yu
2017-05-19 15:46 ` [PATCH 3/3] f2fs: wait discard IO completion without cmd_lock held Chao Yu
2017-05-19 15:46 ` Chao Yu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.