Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528187pxf; Mon, 15 Mar 2021 11:33:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMhyG2AAlotrLQ1YW/ZuZt8tJRQsFPzTMUBRe1qQmSsmpwZDRDH6eBeXS/SPz0dqIaWLpj X-Received: by 2002:a05:6402:3486:: with SMTP id v6mr31397641edc.109.1615833218801; Mon, 15 Mar 2021 11:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833218; cv=none; d=google.com; s=arc-20160816; b=D96lciLCfhJkE7ohJ2tcIopQ1Jkts4nrxyHawSvWcjhv50/JfmiwJ0fktvPoM38azr V4RJC2lO6tyar04vqeZsdKO9uAvkLXjdSHl0hHTgVvmOz7EJ+0JSp95+apbvqR12VFx4 AoOC12/asMbz8rKRQPhs3z1URmSUdY6w9s82FiZEDAwPk8guh6a2XKNSEBpluZdlVsOG VpW+mNp52coNg2oVwaZ+ipgIQQVni7T6C11Qt4/8gilty39ricy73Cq6n2duV4RANuQ7 B4sSBYU940Qk+GE6xRABdJsNuMdt3ecmPsWdAWYYI+BzfghBgWq4Zavfa3aZ8mVqpJ/F uxhA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iuS/NuJB8YqJWtd3l9wjoRN7G3g6TvMLm1EjntvOLGk=; b=WSW+nerWPEmA0q6PuIruVu2CUZYtny5hhzdwe0wWPje3L46T5TNU0hp5G6wyK2vOUk Pex07bicsjOMsK8AB54xhfWrUEsXGhOOjSJudNYdNEr07TWiRHx4hXtZNCwyDYzXEmlF n1S+qwzpHM8Ah3oBVdgZXc+Jl8VLPCmJROyc9PzlyjsJlQD4i1jc8Pl3arrbhsbO9r11 C1uGcMEhRKMqvUgm4MvF3S/7LWetEWV6nUF7qxvAB5ndVXoc9OUy+Tf9bCw0gBWdeEjZ 5O7UZxTMPjTIJW/K+OgfEXAOySWxWpQw4NM1gK1uW//MPNfU9KEZ39TrIMBw2vtwFjoz F8jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z8jcTxlU; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr7si11306184ejc.126.2021.03.15.11.33.16; Mon, 15 Mar 2021 11:33:38 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=Z8jcTxlU; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231386AbhCOOos (ORCPT + 99 others); Mon, 15 Mar 2021 10:44:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:51270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233648AbhCOOEF (ORCPT ); Mon, 15 Mar 2021 10:04:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DDE8164F00; Mon, 15 Mar 2021 14:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817045; bh=psv5oi681gfJ3dlKmVGbYsGxJ0rP+v0JLkT18VQAiRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z8jcTxlUOXtI42KiOeRtBv2zlvqM9nVQsE0u37CAbVTgQeuKhMZKy/Q4YutfY5FpH bYgm8QKb8DMWvNl9Y7Ce+p+otUc3AvHstNavvwua9lN3lV9SrJH+SdJ14HIDkWFd8i 8eBygMSt2tWVmzqae1MsijUUmIXIcMJDKH3wnPwo= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Minchan Kim , Sergey Senozhatsky , Colin Ian King , John Dias , Andrew Morton , Linus Torvalds Subject: [PATCH 5.10 261/290] zram: fix return value on writeback_store Date: Mon, 15 Mar 2021 14:55:54 +0100 Message-Id: <20210315135550.841075914@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Minchan Kim commit 57e0076e6575a7b7cef620a0bd2ee2549ef77818 upstream. writeback_store's return value is overwritten by submit_bio_wait's return value. Thus, writeback_store will return zero since there was no IO error. In the end, write syscall from userspace will see the zero as return value, which could make the process stall to keep trying the write until it will succeed. Link: https://lkml.kernel.org/r/20210312173949.2197662-1-minchan@kernel.org Fixes: 3b82a051c101("drivers/block/zram/zram_drv.c: fix error return codes not being returned in writeback_store") Signed-off-by: Minchan Kim Cc: Sergey Senozhatsky Cc: Colin Ian King Cc: John Dias Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/block/zram/zram_drv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -633,7 +633,7 @@ static ssize_t writeback_store(struct de struct bio_vec bio_vec; struct page *page; ssize_t ret = len; - int mode; + int mode, err; unsigned long blk_idx = 0; if (sysfs_streq(buf, "idle")) @@ -725,12 +725,17 @@ static ssize_t writeback_store(struct de * XXX: A single page IO would be inefficient for write * but it would be not bad as starter. */ - ret = submit_bio_wait(&bio); - if (ret) { + err = submit_bio_wait(&bio); + if (err) { zram_slot_lock(zram, index); zram_clear_flag(zram, index, ZRAM_UNDER_WB); zram_clear_flag(zram, index, ZRAM_IDLE); zram_slot_unlock(zram, index); + /* + * Return last IO error unless every IO were + * not suceeded. + */ + ret = err; continue; }