zram: propagate read_from_bdev_async() errors

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.

Link: https://lkml.kernel.org/r/20260316015354.114465-1-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Suggested-by: Brian Geffon <bgeffon@google.com>
Acked-by: Brian Geffon <bgeffon@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Richard Chang <richardycc@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Sergey Senozhatsky 2026-03-16 10:53:32 +09:00 committed by Andrew Morton
parent f0f6f78714
commit bf989ade27

View File

@ -1429,21 +1429,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;
@ -1459,6 +1459,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)
@ -1507,8 +1509,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) {};