mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
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>
This commit is contained in:
committed by
Andrew Morton
parent
e87ddea345
commit
1b1a4e4d67
@@ -1995,14 +1995,14 @@ static int zram_read_page(struct zram *zram, struct page *page, u32 index,
|
||||
ret = zram_read_from_zspool(zram, page, index);
|
||||
zram_slot_unlock(zram, index);
|
||||
} else {
|
||||
unsigned long blk_idx = zram_get_handle(zram, index);
|
||||
|
||||
/*
|
||||
* The slot should be unlocked before reading from the backing
|
||||
* device.
|
||||
*/
|
||||
zram_slot_unlock(zram, index);
|
||||
|
||||
ret = read_from_bdev(zram, page, zram_get_handle(zram, index),
|
||||
parent);
|
||||
ret = read_from_bdev(zram, page, blk_idx, parent);
|
||||
}
|
||||
|
||||
/* Should NEVER happen. Return bio error if it does. */
|
||||
|
||||
Reference in New Issue
Block a user