Skip to content

Commit f852190

Browse files
sergey-senozhatskyakpm00
authored andcommitted
zram: clear IDLE flag after recompression
Patch series "zram: IDLE flag handling fixes", v2. zram can wrongly preserve ZRAM_IDLE flag on its entries which can result in premature post-processing (writeback and recompression) of such entries. This patch (of 2) Recompression should clear ZRAM_IDLE flag on the entries it has accessed, because otherwise some entries, specifically those for which recompression has failed, become immediate candidate entries for another post-processing (e.g. writeback). Consider the following case: - recompression marks entries IDLE every 4 hours and attempts to recompress them - some entries are incompressible, so we keep them intact and hence preserve IDLE flag - writeback marks entries IDLE every 8 hours and writebacks IDLE entries, however we have IDLE entries left from recompression, so writeback prematurely writebacks those entries. The bug was reported by Shin Kawamura. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 84b33bf ("zram: introduce recompress sysfs knob") Signed-off-by: Sergey Senozhatsky <[email protected]> Reported-by: Shin Kawamura <[email protected]> Acked-by: Brian Geffon <[email protected]> Cc: Minchan Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: <[email protected]>
1 parent 408a8dc commit f852190

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/block/zram/zram_drv.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,13 @@ static int recompress_slot(struct zram *zram, u32 index, struct page *page,
18641864
if (ret)
18651865
return ret;
18661866

1867+
/*
1868+
* We touched this entry so mark it as non-IDLE. This makes sure that
1869+
* we don't preserve IDLE flag and don't incorrectly pick this entry
1870+
* for different post-processing type (e.g. writeback).
1871+
*/
1872+
zram_clear_flag(zram, index, ZRAM_IDLE);
1873+
18671874
class_index_old = zs_lookup_class_index(zram->mem_pool, comp_len_old);
18681875
/*
18691876
* Iterate the secondary comp algorithms list (in order of priority)

0 commit comments

Comments
 (0)