OSDN Git Service

z3fold: fix possible reclaim races
authorVitaly Wool <vitalywool@gmail.com>
Fri, 16 Nov 2018 23:07:56 +0000 (15:07 -0800)
committer0ranko0P <ranko0p@outlook.com>
Tue, 24 Dec 2019 20:42:30 +0000 (04:42 +0800)
commit21a0a1bb778665b46c0bf14a17ee1f2349557ecb
tree969cf9969281e5dfbbe077d146b092ff8c98d986
parent98b094121e9bc6a2f245da6c1d3eb2875fdefb12
z3fold: fix possible reclaim races

Reclaim and free can race on an object which is basically fine but in
order for reclaim to be able to map "freed" object we need to encode
object length in the handle.  handle_to_chunks() is then introduced to
extract object length from a handle and use it during mapping.

Moreover, to avoid racing on a z3fold "headless" page release, we should
not try to free that page in z3fold_free() if the reclaim bit is set.
Also, in the unlikely case of trying to reclaim a page being freed, we
should not proceed with that page.

While at it, fix the page accounting in reclaim function.

This patch supersedes "[PATCH] z3fold: fix reclaim lock-ups".

Link: http://lkml.kernel.org/r/20181105162225.74e8837d03583a9b707cf559@gmail.com
Signed-off-by: Vitaly Wool <vitaly.vul@sony.com>
Signed-off-by: Jongseok Kim <ks77sj@gmail.com>
Reported-by-by: Jongseok Kim <ks77sj@gmail.com>
Reviewed-by: Snild Dolkow <snild@sony.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/z3fold.c