Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5277623imd; Tue, 30 Oct 2018 15:00:09 -0700 (PDT) X-Google-Smtp-Source: AJdET5dCsBQfg1w9kR0sqtY10m5EaznNwB3Yw0OEsff0mX5tALi5BA98FvnO/USxVe2BKlrgRglC X-Received: by 2002:a63:6781:: with SMTP id b123-v6mr445751pgc.151.1540936809895; Tue, 30 Oct 2018 15:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540936809; cv=none; d=google.com; s=arc-20160816; b=K1vkXsLrV7U4OAbRV3ZVdAUP5lgV2Aqe07m2oaA8cAXP8KLtyBtr2u6+5NRuMgmSVE dLFvSh9JP/jhpGSlE7HS/JQMjcF5WiQjSqT7VBcf+NVnXAsvKbxZj7t320VWhYqjLpWT BdQNYVNNyPS9y2YTmaI34ppiDh3SMYxA0Zw/2tQv7MRyuzCl61uDtCQklhxH7fHHpRK8 AaIYosgN/BhP8J3AWwJmsziZQkI1MYWhT2oSlqGycUczXe5/NnPgg4J422bzYv8M73E4 iJrd+wAAXJbIN3p/Wk79WMHi5bQvfmGkSOFiwp1SXAtnPjHnMpIrV1+Eg57WaVTxxtxl bWGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:mime-version:message-id:date:subject :cc:from:dkim-signature; bh=ulXauuLE2yNyr7a4rI5BK89njn86knnx0RtvbNaaQ+s=; b=eFsPkW3i9ZZawy3FXUGnL5dLCLkPEjs+W2+vyIvTf5uL03E557MYb7SPswUXTq2KV3 nk3v3DiQRzFCeDCc1DddIOw5LLnmgV6gEjMeltAhZ4hREr5KgyUg+TcGPCBoJF+hyTYS 8VO31NClnOWgyRprrtRrkAd5jFyhskZeJfPE70juY8mWAPLyNX/7LLyKwTEhbAOvEPaK cEMOdJ+aQWgpoyjweLLD011zRnH5X6DhNZ3z93quBjk5sTA0mnJneF1BXEz2dSIkaBOL 8WPPbdT1WJmuTUwTRqPIssTN9zkuuwGHS4eTYDLI2n1UUeACJTGwUa5P68bO++bIOPg3 KEtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@amazon.de header.s=amazon201209 header.b=h+6VyBDG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11-v6si23546593pgs.179.2018.10.30.14.59.54; Tue, 30 Oct 2018 15:00:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@amazon.de header.s=amazon201209 header.b=h+6VyBDG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728394AbeJaGyJ (ORCPT + 99 others); Wed, 31 Oct 2018 02:54:09 -0400 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:31568 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbeJaGyJ (ORCPT ); Wed, 31 Oct 2018 02:54:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1540936736; x=1572472736; h=from:to:cc:subject:date:message-id:mime-version; bh=ulXauuLE2yNyr7a4rI5BK89njn86knnx0RtvbNaaQ+s=; b=h+6VyBDGPtQpk/jJI1e6segyLRnOJLEPKtVLH5eJMZhQDdhIHk3ixHab Fisx2ihqKbb0RtsNHspju39iRdyWAN9p8uQeTfRAIAnuUfbW7fSovMSgY IPCHbBJHr5EwnhQV3GCndaBUKfbhaZw97Nu6gXaZMunG69IusNEaeBvrc c=; X-IronPort-AV: E=Sophos;i="5.54,446,1534809600"; d="scan'208";a="639353382" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-2a-8549039f.us-west-2.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 30 Oct 2018 21:58:53 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2a-8549039f.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w9ULwm1E067762 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Tue, 30 Oct 2018 21:58:52 GMT Received: from EX13D08UEE004.ant.amazon.com (10.43.62.182) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 30 Oct 2018 21:58:52 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D08UEE004.ant.amazon.com (10.43.62.182) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 30 Oct 2018 21:58:52 +0000 Received: from dev-dsk-mheyne-1a-d7497a7f.eu-west-1.amazon.com (10.15.98.203) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 30 Oct 2018 21:58:51 +0000 Received: by dev-dsk-mheyne-1a-d7497a7f.eu-west-1.amazon.com (Postfix, from userid 5466572) id C1D51A96E7; Tue, 30 Oct 2018 21:58:51 +0000 (UTC) From: Maximilian Heyne CC: Christoph Hellwig , Maximilian Heyne , , Torsten Mehlan , Uwe Dannowski , Amit Shah , David Woodhouse , Alexander Viro , , Subject: [PATCH] fs: fix lost error code in dio_complete Date: Tue, 30 Oct 2018 21:57:39 +0000 Message-ID: <20181030215739.4557-1-mheyne@amazon.de> X-Mailer: git-send-email 2.16.2 MIME-Version: 1.0 Content-Type: text/plain To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit e259221763a40403d5bb232209998e8c45804ab8 ("fs: simplify the generic_write_sync prototype") reworked callers of generic_write_sync(), and ended up dropping the error return for the directio path. Prior to that commit, in dio_complete(), an error would be bubbled up the stack, but after that commit, errors passed on to dio_complete were eaten up. This was reported on the list earlier, and a fix was proposed in https://lore.kernel.org/lkml/20160921141539.GA17898@infradead.org/, but never followed up with. We recently hit this bug in our testing where fencing io errors, which were previously erroring out with EIO, were being returned as success operations after this commit. The fix proposed on the list earlier was a little short -- it would have still called generic_write_sync() in case `ret` already contained an error. This fix ensures generic_write_sync() is only called when there's no pending error in the write. CC: stable@vger.kernel.org Reported-by: Ravi Nankani Signed-off-by: Maximilian Heyne Signed-off-by: Torsten Mehlan Signed-off-by: Uwe Dannowski Signed-off-by: Amit Shah Signed-off-by: David Woodhouse --- fs/direct-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index 093fb54cd316..199146036093 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -325,8 +325,8 @@ static ssize_t dio_complete(struct dio *dio, ssize_t ret, unsigned int flags) */ dio->iocb->ki_pos += transferred; - if (dio->op == REQ_OP_WRITE) - ret = generic_write_sync(dio->iocb, transferred); + if (ret > 0 && dio->op == REQ_OP_WRITE) + ret = generic_write_sync(dio->iocb, ret); dio->iocb->ki_complete(dio->iocb, ret, 0); } -- 2.16.2 Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B