Skip to content
Commit 25cd2414 authored by Johannes Weiner's avatar Johannes Weiner Committed by Andrew Morton
Browse files

mm: zswap: fix data loss on SWP_SYNCHRONOUS_IO devices

Zhongkun He reports data corruption when combining zswap with zram.

The issue is the exclusive loads we're doing in zswap. They assume
that all reads are going into the swapcache, which can assume
authoritative ownership of the data and so the zswap copy can go.

However, zram files are marked SWP_SYNCHRONOUS_IO, and faults will try to
bypass the swapcache.  This results in an optimistic read of the swap data
into a page that will be dismissed if the fault fails due to races.  In
this case, zswap mustn't drop its authoritative copy.

Link: https://lore.kernel.org/all/CACSyD1N+dUvsu8=zV9P691B9bVq33erwOXNTmEaUbi9DrDeJzw@mail.gmail.com/
Fixes: b9c91c43 ("mm: zswap: support exclusive loads")
Link: https://lkml.kernel.org/r/20240324210447.956973-1-hannes@cmpxchg.org


Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Reported-by: default avatarZhongkun He <hezhongkun.hzk@bytedance.com>
Tested-by: default avatarZhongkun He <hezhongkun.hzk@bytedance.com>
Acked-by: default avatarYosry Ahmed <yosryahmed@google.com>
Acked-by: default avatarBarry Song <baohua@kernel.org>
Reviewed-by: default avatarChengming Zhou <chengming.zhou@linux.dev>
Reviewed-by: default avatarNhat Pham <nphamcs@gmail.com>
Acked-by: default avatarChris Li <chrisl@kernel.org>
Cc: <stable@vger.kernel.org>	[6.5+]
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 8c864371
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment