]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
zram: use zram_read_from_zspool() in writeback
authorSergey Senozhatsky <senozhatsky@chromium.org>
Wed, 18 Dec 2024 06:34:23 +0000 (15:34 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 26 Jan 2025 04:22:20 +0000 (20:22 -0800)
We only can read pages from zspool in writeback, zram_read_page() is not
really right in that context not only because it's a more generic function
that handles ZRAM_WB pages, but also because it requires us to unlock slot
between slot flag check and actual page read.  Use zram_read_from_zspool()
instead and do slot flags check and page read under the same slot lock.

Link: https://lkml.kernel.org/r/20241218063513.297475-7-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/block/zram/zram_drv.c

index c4454ceee4ddc407003aaf3c9107475cb8a68f8a..faa58d85cef846e77635d172d78e1a37eddbf394 100644 (file)
@@ -55,8 +55,8 @@ static size_t huge_class_size;
 static const struct block_device_operations zram_devops;
 
 static void zram_free_page(struct zram *zram, size_t index);
-static int zram_read_page(struct zram *zram, struct page *page, u32 index,
-                         struct bio *parent);
+static int zram_read_from_zspool(struct zram *zram, struct page *page,
+                                u32 index);
 
 static int zram_slot_trylock(struct zram *zram, u32 index)
 {
@@ -831,13 +831,10 @@ static ssize_t writeback_store(struct device *dev,
                 */
                if (!zram_test_flag(zram, index, ZRAM_PP_SLOT))
                        goto next;
+               if (zram_read_from_zspool(zram, page, index))
+                       goto next;
                zram_slot_unlock(zram, index);
 
-               if (zram_read_page(zram, page, index, NULL)) {
-                       release_pp_slot(zram, pps);
-                       continue;
-               }
-
                bio_init(&bio, zram->bdev, &bio_vec, 1,
                         REQ_OP_WRITE | REQ_SYNC);
                bio.bi_iter.bi_sector = blk_idx * (PAGE_SIZE >> 9);