[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210312173949.2197662-1-minchan@kernel.org>
Date: Fri, 12 Mar 2021 09:39:48 -0800
From: Minchan Kim <minchan@...nel.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: joaodias@...gle.com, LKML <linux-kernel@...r.kernel.org>,
Amos Bianchi <amosbianchi@...gle.com>,
Colin Ian King <colin.king@...onical.com>,
Minchan Kim <minchan@...nel.org>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
stable@...r.kernel.org
Subject: [PATCH 1/2] zram: fix return value on writeback_store
writeback_store's return value is overwritten by submit_bio_wait's
return value. Thus, writeback_store will return zero since there
was no IO error. In the end, write syscall from userspace will
see the zero as return value, which could make the process stall
to keep trying the write until it will succeed.
Cc: Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Cc: Colin Ian King <colin.king@...onical.com>
Cc: stable@...r.kernel.org
Fixes: 3b82a051c101("drivers/block/zram/zram_drv.c: fix error return codes not being returned in writeback_store")
Signed-off-by: Minchan Kim <minchan@...nel.org>
---
drivers/block/zram/zram_drv.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index a711a2e2a794..63bbefdffc81 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -627,7 +627,7 @@ static ssize_t writeback_store(struct device *dev,
struct bio_vec bio_vec;
struct page *page;
ssize_t ret = len;
- int mode;
+ int mode, err;
unsigned long blk_idx = 0;
if (sysfs_streq(buf, "idle"))
@@ -728,12 +728,17 @@ static ssize_t writeback_store(struct device *dev,
* XXX: A single page IO would be inefficient for write
* but it would be not bad as starter.
*/
- ret = submit_bio_wait(&bio);
- if (ret) {
+ err = submit_bio_wait(&bio);
+ if (err) {
zram_slot_lock(zram, index);
zram_clear_flag(zram, index, ZRAM_UNDER_WB);
zram_clear_flag(zram, index, ZRAM_IDLE);
zram_slot_unlock(zram, index);
+ /*
+ * Return last IO error unless every IO were
+ * not suceeded.
+ */
+ ret = err;
continue;
}
--
2.31.0.rc2.261.g7f71774620-goog
Powered by blists - more mailing lists