Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1449861pxf; Fri, 12 Mar 2021 09:44:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyimxKohRq23NN0PRqSOqpMgfcArG+y0VjIIMqVbJj0OSD1mA79ZNlJ+f0wfjQBwhoruVPc X-Received: by 2002:a17:906:b297:: with SMTP id q23mr9932562ejz.315.1615571050943; Fri, 12 Mar 2021 09:44:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615571050; cv=none; d=google.com; s=arc-20160816; b=d9vtzeHI0u6x5VgjbIPQYdgPfPIOfQHzfIhiOwE83DfCJURU4eQS4e9GVLlYdasXSP KwVct6/JVf29ayT5+dYSDGJgLRJh10LhGB6LI8fEHBzAmAQOLx/ajYBgzXqlKpCX30+Z ugWAyxEvRirGOWzC04+fNv+BCMxtuafDEFGwbeMBvegbfgj1IYD2w0zJfxGca2w13fhi UZklZYp53lQa0D2AghoXR8qnetzHfCLCQ29Ap4t1Ynzdz/6lzTfNXQA38j7Ul6sRsiVE AU2u3ws/K52jV8kX8M8kvXnAPq8QKReC55baizuBc4o5kkLQ4/DgaUJIFwlEZs6buQaI R3RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=Um41cau/4cI5zZ0IFqq13GRE02mbM3czC6F6elPaPlY=; b=ARrPMzARHmBI23q9OC98Cb93WtvWLw2jbCfPR+JBA62AftqvFjkY9M7NPpjjAHEpD9 BDZTUsav71sQCWbOCeAK9r4lPniSIbsmpcFCNKoggUHXaNFsOBUjCfrlkWGLjkLMW10O NuKMQf+K/O524ad4teOE1EK3DEc8n0uhh4CRj7Zt82P44r8JMveLfOjvmsdZMCXWglT6 TCKDXrCYDwbYyCKBC7zICKJWd0M3Rnv73EkQPxGc5wAs0yKa1weP822FlYd6CDuK38mk yIl1RwnUJ1seNkeaAS0KyKhOAWheef6VBOIkJq39zWWRFuosaBvhtn0/jaQ2UaWNvfH/ Gzsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jMixJe4t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i14si4546968eje.519.2021.03.12.09.43.47; Fri, 12 Mar 2021 09:44:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jMixJe4t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232871AbhCLRkI (ORCPT + 99 others); Fri, 12 Mar 2021 12:40:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232602AbhCLRkB (ORCPT ); Fri, 12 Mar 2021 12:40:01 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8EFBC061574; Fri, 12 Mar 2021 09:40:01 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id c16so12275549ply.0; Fri, 12 Mar 2021 09:40:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Um41cau/4cI5zZ0IFqq13GRE02mbM3czC6F6elPaPlY=; b=jMixJe4t1LMYNSBJap26jButQmWlKnEZrOAPlkS0RrI7DelOA0vKb7j29BQMM5SVm2 Xh6aCuObFfIL/4OfMm+iiSV77LLp4zP6ESMqpB/jdoERxPsJ3Nql+QiUj93tyhZ4tUj0 DepqiabV0uYOPqw0b8+kk24TliM7NFr9NMv0Lpz/V/y3NlHcGHG/T6CcwOHTDBY8fDqg VvBJVWz289so/cWa0O00do1k8x9I5qISz7dUZc7FHV9r0FpRLJU37ldg3fTmWeTZ9AoL uAQJ0d+86tc7SrgZnpfdQrmDx+BTMmJhzFSmruJsXHlLONFRMh1llRNd+wwXgLXuwfSY y2XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Um41cau/4cI5zZ0IFqq13GRE02mbM3czC6F6elPaPlY=; b=NGnjwGtCukGMzbAbgmpiNqtZCV4f1tG40qb4Kjr+g4FZyYXi7jFaOi0Y+WJ4l9Uedy l2SXdh4hZA8bEJFFi9Huctjr8kOgrC2j1DaihU2Gbtd8iKPj19TSqiqv6yCqu/2j/Mlb qo5xk8Wwvao12b6jTVQpXNlIQTkpGTbbJsmRvcdFTsvHTkZGXbLDzlSl6D1gyDV8nBmV BFG+sMcq7roTPjJmz46nnCEWcg5tgIvrVxMMJ9RIQCK8aHUQtIgj769cbrny7eIjPbA6 wEjQulxVDr1zv0xRzZn5W+cWQ32wviUzFGvZvbPuNvLQnYuxZ6crF9uYLA8HkxRXstJp +inw== X-Gm-Message-State: AOAM530eckfaY3Mw4gjJFYelIHQIVhiZpyeVu9njPWn0Huy09+xgc0Od h/Fr+XXFoB+XhO4NiijruYGNSHSzdIc= X-Received: by 2002:a17:90a:8a8b:: with SMTP id x11mr15208004pjn.151.1615570801371; Fri, 12 Mar 2021 09:40:01 -0800 (PST) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:201:8d76:9272:43a9:a6d0]) by smtp.gmail.com with ESMTPSA id g21sm2694958pjl.28.2021.03.12.09.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:40:00 -0800 (PST) Sender: Minchan Kim From: Minchan Kim To: Andrew Morton Cc: joaodias@google.com, LKML , Amos Bianchi , Colin Ian King , Minchan Kim , Sergey Senozhatsky , stable@vger.kernel.org Subject: [PATCH 2/2] zram: fix broken page writeback Date: Fri, 12 Mar 2021 09:39:49 -0800 Message-Id: <20210312173949.2197662-2-minchan@kernel.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210312173949.2197662-1-minchan@kernel.org> References: <20210312173949.2197662-1-minchan@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cc: Sergey Senozhatsky Cc: stable@vger.kernel.org Reported-by: Amos Bianchi Fixes: 0d8359620d9b("zram: support page writeback") Signed-off-by: Minchan Kim --- drivers/block/zram/zram_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 63bbefdffc81..cf8deecc39ef 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -638,8 +638,8 @@ static ssize_t writeback_store(struct device *dev, if (strncmp(buf, PAGE_WB_SIG, sizeof(PAGE_WB_SIG) - 1)) return -EINVAL; - ret = kstrtol(buf + sizeof(PAGE_WB_SIG) - 1, 10, &index); - if (ret || index >= nr_pages) + if (kstrtol(buf + sizeof(PAGE_WB_SIG) - 1, 10, &index) || + index >= nr_pages) return -EINVAL; nr_pages = 1; @@ -663,7 +663,7 @@ static ssize_t writeback_store(struct device *dev, goto release_init_lock; } - while (nr_pages--) { + for (; nr_pages != 0; index++, nr_pages--) { struct bio_vec bvec; bvec.bv_page = page; -- 2.31.0.rc2.261.g7f71774620-goog