UPSTREAM: zram: fix broken page writeback
commit 0d8359620d9b ("zram: support page writeback") introduced two problems. It overwrites writeback_store's return value as kstrtol's return value, which makes return value zero so user could see zero as return value of write syscall even though it wrote data successfully. It also breaks index value in the loop in that it doesn't increase the index any longer. It means it can write only first starting block index so user couldn't write all idle pages in the zram so lose memory saving chance. This patch fixes those issues. Link: https://lkml.kernel.org/r/20210312173949.2197662-2-minchan@kernel.org Fixes: 0d8359620d9b("zram: support page writeback") Signed-off-by: Minchan Kim <minchan@kernel.org> Reported-by: Amos Bianchi <amosbianchi@google.com> Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: John Dias <joaodias@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry picked from commit 2766f1821600cc7562bae2128ad0b163f744c5d9) Bug: 182850185 Signed-off-by: Amos Bianchi <amosbianchi@google.com> Change-Id: I9836b6350727dc4fffc1cc939647235781f0a4ee
This commit is contained in:

committed by
Suren Baghdasaryan

parent
542d1937ba
commit
e4636b47ef
@@ -648,8 +648,8 @@ static ssize_t writeback_store(struct device *dev,
|
|||||||
if (strncmp(buf, PAGE_WB_SIG, sizeof(PAGE_WB_SIG) - 1))
|
if (strncmp(buf, PAGE_WB_SIG, sizeof(PAGE_WB_SIG) - 1))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ret = kstrtol(buf + sizeof(PAGE_WB_SIG) - 1, 10, &index);
|
if (kstrtol(buf + sizeof(PAGE_WB_SIG) - 1, 10, &index) ||
|
||||||
if (ret || index >= nr_pages)
|
index >= nr_pages)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
nr_pages = 1;
|
nr_pages = 1;
|
||||||
@@ -673,7 +673,7 @@ static ssize_t writeback_store(struct device *dev,
|
|||||||
goto release_init_lock;
|
goto release_init_lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (nr_pages--) {
|
for (; nr_pages != 0; index++, nr_pages--) {
|
||||||
struct bio_vec bvec;
|
struct bio_vec bvec;
|
||||||
|
|
||||||
bvec.bv_page = page;
|
bvec.bv_page = page;
|
||||||
|
Reference in New Issue
Block a user