Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

zram: read slot block idx under slot lock

Read slot's block id under slot-lock. We release the slot-lock for bdev
read so, technically, slot still can get freed in the meantime, but at
least we will read bdev block (page) that holds previous know slot data,
not from slot->handle bdev block, which can be anything at that point.

Link: https://lkml.kernel.org/r/20251122074029.3948921-7-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Brian Geffon <bgeffon@google.com>
Cc: Minchan Kim <minchan@google.com>
Cc: Richard Chang <richardycc@google.com>
Cc: Yuwen Chen <ywen.chen@foxmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Sergey Senozhatsky and committed by
Andrew Morton
1b1a4e4d e87ddea3

+3 -3
+3 -3
drivers/block/zram/zram_drv.c
··· 1995 1995 ret = zram_read_from_zspool(zram, page, index); 1996 1996 zram_slot_unlock(zram, index); 1997 1997 } else { 1998 + unsigned long blk_idx = zram_get_handle(zram, index); 1999 + 1998 2000 /* 1999 2001 * The slot should be unlocked before reading from the backing 2000 2002 * device. 2001 2003 */ 2002 2004 zram_slot_unlock(zram, index); 2003 - 2004 - ret = read_from_bdev(zram, page, zram_get_handle(zram, index), 2005 - parent); 2005 + ret = read_from_bdev(zram, page, blk_idx, parent); 2006 2006 } 2007 2007 2008 2008 /* Should NEVER happen. Return bio error if it does. */