zram: return early on error in zram_bvec_rw
authorChristoph Hellwig <hch@lst.de>
Tue, 11 Apr 2023 17:14:48 +0000 (19:14 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 18 Apr 2023 23:29:57 +0000 (16:29 -0700)
When the low-level access fails, don't clear the idle flag or clear the
caches, and just return.

Link: https://lkml.kernel.org/r/20230411171459.567614-7-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/block/zram/zram_drv.c

index 00f13eb..46dc7a2 100644 (file)
@@ -1933,23 +1933,23 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
 
        if (!op_is_write(op)) {
                ret = zram_bvec_read(zram, bvec, index, offset, bio);
+               if (unlikely(ret < 0)) {
+                       atomic64_inc(&zram->stats.failed_reads);
+                       return ret;
+               }
                flush_dcache_page(bvec->bv_page);
        } else {
                ret = zram_bvec_write(zram, bvec, index, offset, bio);
+               if (unlikely(ret < 0)) {
+                       atomic64_inc(&zram->stats.failed_writes);
+                       return ret;
+               }
        }
 
        zram_slot_lock(zram, index);
        zram_accessed(zram, index);
        zram_slot_unlock(zram, index);
-
-       if (unlikely(ret < 0)) {
-               if (!op_is_write(op))
-                       atomic64_inc(&zram->stats.failed_reads);
-               else
-                       atomic64_inc(&zram->stats.failed_writes);
-       }
-
-       return ret;
+       return 0;
 }
 
 static void __zram_make_request(struct zram *zram, struct bio *bio)