2020-04-15 22:07:29

by Sahitya Tummala

[permalink] [raw]
Subject: [PATCH] f2fs: report the discard cmd errors properly

In case a discard_cmd is split into several bios, the dc->error
must not be overwritten once an error is reported by a bio. Also,
move it under dc->lock.

Signed-off-by: Sahitya Tummala <[email protected]>
---
fs/f2fs/segment.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index bd6dd19..745e4dd 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1031,9 +1031,9 @@ static void f2fs_submit_discard_endio(struct bio *bio)
struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private;
unsigned long flags;

- dc->error = blk_status_to_errno(bio->bi_status);
-
spin_lock_irqsave(&dc->lock, flags);
+ if (!dc->error)
+ dc->error = blk_status_to_errno(bio->bi_status);
dc->bio_ref--;
if (!dc->bio_ref && dc->state == D_SUBMIT) {
dc->state = D_DONE;
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


2020-04-15 22:12:03

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH] f2fs: report the discard cmd errors properly

On 2020/4/15 12:05, Sahitya Tummala wrote:
> In case a discard_cmd is split into several bios, the dc->error
> must not be overwritten once an error is reported by a bio. Also,
> move it under dc->lock.
>
> Signed-off-by: Sahitya Tummala <[email protected]>

Reviewed-by: Chao Yu <[email protected]>

Thanks,