Skip to content

Commit 2766f18

Browse files
minchanktorvalds
authored andcommitted
zram: fix broken page writeback
commit 0d83596 ("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/[email protected] Fixes: 0d83596("zram: support page writeback") Signed-off-by: Minchan Kim <[email protected]> Reported-by: Amos Bianchi <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: John Dias <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 57e0076 commit 2766f18

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/block/zram/zram_drv.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,8 @@ static ssize_t writeback_store(struct device *dev,
638638
if (strncmp(buf, PAGE_WB_SIG, sizeof(PAGE_WB_SIG) - 1))
639639
return -EINVAL;
640640

641-
ret = kstrtol(buf + sizeof(PAGE_WB_SIG) - 1, 10, &index);
642-
if (ret || index >= nr_pages)
641+
if (kstrtol(buf + sizeof(PAGE_WB_SIG) - 1, 10, &index) ||
642+
index >= nr_pages)
643643
return -EINVAL;
644644

645645
nr_pages = 1;
@@ -663,7 +663,7 @@ static ssize_t writeback_store(struct device *dev,
663663
goto release_init_lock;
664664
}
665665

666-
while (nr_pages--) {
666+
for (; nr_pages != 0; index++, nr_pages--) {
667667
struct bio_vec bvec;
668668

669669
bvec.bv_page = page;

0 commit comments

Comments
 (0)