Skip to content

Commit b8d3ff7

Browse files
sergey-senozhatskyakpm00
authored andcommitted
zram: use zram_read_from_zspool() in writeback
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/[email protected] Signed-off-by: Sergey Senozhatsky <[email protected]> Cc: Minchan Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent e355b25 commit b8d3ff7

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

drivers/block/zram/zram_drv.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ static size_t huge_class_size;
5555
static const struct block_device_operations zram_devops;
5656

5757
static void zram_free_page(struct zram *zram, size_t index);
58-
static int zram_read_page(struct zram *zram, struct page *page, u32 index,
59-
struct bio *parent);
58+
static int zram_read_from_zspool(struct zram *zram, struct page *page,
59+
u32 index);
6060

6161
static int zram_slot_trylock(struct zram *zram, u32 index)
6262
{
@@ -831,13 +831,10 @@ static ssize_t writeback_store(struct device *dev,
831831
*/
832832
if (!zram_test_flag(zram, index, ZRAM_PP_SLOT))
833833
goto next;
834+
if (zram_read_from_zspool(zram, page, index))
835+
goto next;
834836
zram_slot_unlock(zram, index);
835837

836-
if (zram_read_page(zram, page, index, NULL)) {
837-
release_pp_slot(zram, pps);
838-
continue;
839-
}
840-
841838
bio_init(&bio, zram->bdev, &bio_vec, 1,
842839
REQ_OP_WRITE | REQ_SYNC);
843840
bio.bi_iter.bi_sector = blk_idx * (PAGE_SIZE >> 9);

0 commit comments

Comments
 (0)