Commit 1e9460d1 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Andrew Morton

zram: return errors from read_from_bdev_sync

Propagate read errors to the caller instead of dropping them on the floor,
and stop returning the somewhat dangerous 1 on success from
read_from_bdev*.

Link: https://lkml.kernel.org/r/20230411171459.567614-18-hch@lst.deSigned-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: default avatarMinchan Kim <minchan@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 4e3c87b9
...@@ -770,6 +770,7 @@ struct zram_work { ...@@ -770,6 +770,7 @@ struct zram_work {
struct zram *zram; struct zram *zram;
unsigned long entry; unsigned long entry;
struct page *page; struct page *page;
int error;
}; };
static void zram_sync_read(struct work_struct *work) static void zram_sync_read(struct work_struct *work)
...@@ -781,7 +782,7 @@ static void zram_sync_read(struct work_struct *work) ...@@ -781,7 +782,7 @@ static void zram_sync_read(struct work_struct *work)
bio_init(&bio, zw->zram->bdev, &bv, 1, REQ_OP_READ); bio_init(&bio, zw->zram->bdev, &bv, 1, REQ_OP_READ);
bio.bi_iter.bi_sector = zw->entry * (PAGE_SIZE >> 9); bio.bi_iter.bi_sector = zw->entry * (PAGE_SIZE >> 9);
__bio_add_page(&bio, zw->page, PAGE_SIZE, 0); __bio_add_page(&bio, zw->page, PAGE_SIZE, 0);
submit_bio_wait(&bio); zw->error = submit_bio_wait(&bio);
} }
/* /*
...@@ -803,7 +804,7 @@ static int read_from_bdev_sync(struct zram *zram, struct page *page, ...@@ -803,7 +804,7 @@ static int read_from_bdev_sync(struct zram *zram, struct page *page,
flush_work(&work.work); flush_work(&work.work);
destroy_work_on_stack(&work.work); destroy_work_on_stack(&work.work);
return 1; return work.error;
} }
static int read_from_bdev(struct zram *zram, struct page *page, static int read_from_bdev(struct zram *zram, struct page *page,
...@@ -816,7 +817,7 @@ static int read_from_bdev(struct zram *zram, struct page *page, ...@@ -816,7 +817,7 @@ static int read_from_bdev(struct zram *zram, struct page *page,
return read_from_bdev_sync(zram, page, entry); return read_from_bdev_sync(zram, page, entry);
} }
read_from_bdev_async(zram, page, entry, parent); read_from_bdev_async(zram, page, entry, parent);
return 1; return 0;
} }
#else #else
static inline void reset_bdev(struct zram *zram) {}; static inline void reset_bdev(struct zram *zram) {};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment