* [PATCH] zram: propagate read_from_bdev_async() errors
@ 2026-03-16 1:53 Sergey Senozhatsky
2026-03-16 2:22 ` Brian Geffon
0 siblings, 1 reply; 2+ messages in thread
From: Sergey Senozhatsky @ 2026-03-16 1:53 UTC (permalink / raw)
To: Andrew Morton, Minchan Kim, Brian Geffon
Cc: Richard Chang, linux-block, linux-mm, Sergey Senozhatsky
When read_from_bdev_async() fails to chain bio, for instance
fails to allocate request or bio, we need to propagate the
error condition so that upper layer is aware of it. zram
already does that by setting BLK_STS_IOERR ->bi_status,
but only for sync reads. Change async read path to return
its error status so that async errors are also handled.
Suggested-by: Brian Geffon <bgeffon@google.com>
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
drivers/block/zram/zram_drv.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 63f71371a7e9..b47cb1d99144 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1445,21 +1445,21 @@ static void zram_async_read_endio(struct bio *bio)
queue_work(system_highpri_wq, &req->work);
}
-static void read_from_bdev_async(struct zram *zram, struct page *page,
- u32 index, unsigned long blk_idx,
- struct bio *parent)
+static int read_from_bdev_async(struct zram *zram, struct page *page,
+ u32 index, unsigned long blk_idx,
+ struct bio *parent)
{
struct zram_rb_req *req;
struct bio *bio;
req = kmalloc_obj(*req, GFP_NOIO);
if (!req)
- return;
+ return -ENOMEM;
bio = bio_alloc(zram->bdev, 1, parent->bi_opf, GFP_NOIO);
if (!bio) {
kfree(req);
- return;
+ return -ENOMEM;
}
req->zram = zram;
@@ -1475,6 +1475,8 @@ static void read_from_bdev_async(struct zram *zram, struct page *page,
__bio_add_page(bio, page, PAGE_SIZE, 0);
bio_inc_remaining(parent);
submit_bio(bio);
+
+ return 0;
}
static void zram_sync_read(struct work_struct *w)
@@ -1523,8 +1525,7 @@ static int read_from_bdev(struct zram *zram, struct page *page, u32 index,
return -EIO;
return read_from_bdev_sync(zram, page, index, blk_idx);
}
- read_from_bdev_async(zram, page, index, blk_idx, parent);
- return 0;
+ return read_from_bdev_async(zram, page, index, blk_idx, parent);
}
#else
static inline void reset_bdev(struct zram *zram) {};
--
2.53.0.851.ga537e3e6e9-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] zram: propagate read_from_bdev_async() errors
2026-03-16 1:53 [PATCH] zram: propagate read_from_bdev_async() errors Sergey Senozhatsky
@ 2026-03-16 2:22 ` Brian Geffon
0 siblings, 0 replies; 2+ messages in thread
From: Brian Geffon @ 2026-03-16 2:22 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: Andrew Morton, Minchan Kim, Richard Chang, linux-block, linux-mm
On Mon, Mar 16, 2026 at 10:54 AM Sergey Senozhatsky
<senozhatsky@chromium.org> wrote:
>
> When read_from_bdev_async() fails to chain bio, for instance
> fails to allocate request or bio, we need to propagate the
> error condition so that upper layer is aware of it. zram
> already does that by setting BLK_STS_IOERR ->bi_status,
> but only for sync reads. Change async read path to return
> its error status so that async errors are also handled.
>
> Suggested-by: Brian Geffon <bgeffon@google.com>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: Brian Geffon <bgeffon@google.com>
> ---
> drivers/block/zram/zram_drv.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 63f71371a7e9..b47cb1d99144 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -1445,21 +1445,21 @@ static void zram_async_read_endio(struct bio *bio)
> queue_work(system_highpri_wq, &req->work);
> }
>
> -static void read_from_bdev_async(struct zram *zram, struct page *page,
> - u32 index, unsigned long blk_idx,
> - struct bio *parent)
> +static int read_from_bdev_async(struct zram *zram, struct page *page,
> + u32 index, unsigned long blk_idx,
> + struct bio *parent)
> {
> struct zram_rb_req *req;
> struct bio *bio;
>
> req = kmalloc_obj(*req, GFP_NOIO);
> if (!req)
> - return;
> + return -ENOMEM;
>
> bio = bio_alloc(zram->bdev, 1, parent->bi_opf, GFP_NOIO);
> if (!bio) {
> kfree(req);
> - return;
> + return -ENOMEM;
> }
>
> req->zram = zram;
> @@ -1475,6 +1475,8 @@ static void read_from_bdev_async(struct zram *zram, struct page *page,
> __bio_add_page(bio, page, PAGE_SIZE, 0);
> bio_inc_remaining(parent);
> submit_bio(bio);
> +
> + return 0;
> }
>
> static void zram_sync_read(struct work_struct *w)
> @@ -1523,8 +1525,7 @@ static int read_from_bdev(struct zram *zram, struct page *page, u32 index,
> return -EIO;
> return read_from_bdev_sync(zram, page, index, blk_idx);
> }
> - read_from_bdev_async(zram, page, index, blk_idx, parent);
> - return 0;
> + return read_from_bdev_async(zram, page, index, blk_idx, parent);
> }
> #else
> static inline void reset_bdev(struct zram *zram) {};
> --
> 2.53.0.851.ga537e3e6e9-goog
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-16 2:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-16 1:53 [PATCH] zram: propagate read_from_bdev_async() errors Sergey Senozhatsky
2026-03-16 2:22 ` Brian Geffon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox