Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3351710pxf; Mon, 15 Mar 2021 07:46:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+YawXw/wlqrQT95PdbKvTeJvJnLztpFMDyOB/nynSBkT2GkwvXO2PHkkcX9JVVGWX9dgm X-Received: by 2002:a05:6402:1004:: with SMTP id c4mr30516629edu.364.1615819574266; Mon, 15 Mar 2021 07:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615819574; cv=none; d=google.com; s=arc-20160816; b=S1D5Umjva4yUbmiaWltdrTnu6XHKk4XAcfbWn12c5aUqNoGVc+8dazAQC/X1P0tvA8 s71KhDLSQezIkMgUXJWn5GvLtFyuMqqYsLxZ2NXZPQ+QiuTMXe8k6xcl8O72Oz14s20L hFzH3OhNAq5a6UYmFJFZPawM8VtH1VN7oefRYHtL6aCkRC1wI+ajLQH3A1mSA1slX48E lZdqIeu3p5+Ikiuo3Usgb4wLX0Xo3ywACqVdhzELU2paQ0YfCygju1FKNQkN20XUoAEi uF995WMVapXvfHO8f/z5G2UnUeKz3+MM8Aekns3cqpb7QNaiPVLxvC4jrct2l8bvkqL4 pnHA== 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=RhKns22YEGZn2GQAaNNws0RdJvrPmicCgbXWsz7MaW0=; b=JMuoYr0Brk3FXWtPlZNLE2ORBQhgwGie/8fMFu21s4Gnl9iSZfKiKf2e804Ocadi7C 7xEyro1DVREEYAqoDa0PZ8r0hJMmoh9/j4Bn/Srd/4V/cJ7EDo2obC8aW40IMsgiJvHN a6Pymsmgn3NXFxiOWS7VSXA36dLKSG6MEGE+metESDvetB8PdqQoL8ZKThsQacPfVI+l jTUzXd7LA9UGoGTdeXrT8Fb7XzXGSuwdeo+rNRTjf0ZSDj2tj8oHC2qvXBck76YwmS9U WWr5RxUkX/aM015JparoWNYRhMajemOPtWY4HB2mAEdVeus2vh38DCR4n9tawzVxDkbF SnrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ABBpMOAP; 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 b13si11794077eja.326.2021.03.15.07.45.50; Mon, 15 Mar 2021 07:46:14 -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=ABBpMOAP; 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 S232024AbhCOOoa (ORCPT + 99 others); Mon, 15 Mar 2021 10:44:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:50774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232959AbhCOOD4 (ORCPT ); Mon, 15 Mar 2021 10:03:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 63EFE64EFE; Mon, 15 Mar 2021 14:03:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817035; bh=gBfXCs28r8ABvjy41oG9UdBYScySp7cRYPNfKWEh9Zk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ABBpMOAPQtxl0HlSrKKE2ULNQ4btDROe5r45dXtAmopI49mLfr+Ba2Fabeg9lmK7S KiPwONkLw5SWXRtzxVeOtMw7wEQRWyLQQKnYEF52Vli4TsI0i4aSFAvW1N7JWAoMrS 8EWYNVuPywrGVuWRpMiuedzXUrityx/Ayhl80hJA= 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.11 269/306] zram: fix return value on writeback_store Date: Mon, 15 Mar 2021 14:55:32 +0100 Message-Id: <20210315135516.745775749@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 @@ -628,7 +628,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")) @@ -729,12 +729,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; }