summaryrefslogtreecommitdiff
path: root/fs/f2fs/segment.c
diff options
context:
space:
mode:
authorSahitya Tummala <stummala@codeaurora.org>2020-04-15 09:35:54 +0530
committerJaegeuk Kim <jaegeuk@kernel.org>2020-04-17 09:17:00 -0700
commit3fa6a8c5b55d063c6a759e0b354f9d7fc09ffbc0 (patch)
treed55cb1cf7d1c9bf321eac927d0aa95e65aa2b119 /fs/f2fs/segment.c
parent141af6ba5216d4d49de683582b600d5c9b51792c (diff)
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 <stummala@codeaurora.org> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r--fs/f2fs/segment.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 90c75822fef6..728ff6e316ac 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1029,9 +1029,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;