Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp480348imu; Thu, 8 Nov 2018 11:01:22 -0800 (PST) X-Google-Smtp-Source: AJdET5eOsKg9qG4E94bdlEMR0xcfmU0CRynrAYTtoDWAHHc/LONaPcmIYLw4zZG0r3ACxvNe3mij X-Received: by 2002:a62:9989:: with SMTP id t9-v6mr5653452pfk.179.1541703682510; Thu, 08 Nov 2018 11:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541703682; cv=none; d=google.com; s=arc-20160816; b=0OxqdrbqUlpPzDojTtzA8QWynFrdsf05jJNjON/VhZNtB+JfRZA83kqxdSBaZCvxFA ssyzfQfcf5v/Is+plp1ZrOjBKdHx92MSHN+wdQUQ2mDJcN9I4m1MbH+KWijbRK5WX7tI 4CVz/ElKcqjMsGR5uTtJJl1OkBgYUeNUiv/A5lTQ2jf7QLthxGgaTSA53MvE8CXTXzEr BHiCpaIOMVVEbLpFr+um2QYBkBOwJwGbaARvjZXjmlzOF0B24K2Vy5yx/+3QkOCcmkGx 2YtXngVS696NtXJDzx+DcL9lTj1bQVVPckkI/EO66C2zSMKom1ZHuKdQeRPYOydYatBO 1ebw== 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=QXnDituIZ9win6qVC9KoJnjwrBgkMuF0lvbTNnhU0Vg=; b=PdUcc/MpF3p/MQBjsyrLeGeYywJ6lq5EiVAB2JE5G5YTcoIG+fl46aPt1TAzhXikPK iL0y52vXWsXCCXnTFwjbR0j1ndm7OxGboWviPCb/o+f9SRX1POQE2mhSBAiKbYYEMbxZ 4YtYDnUK6POURKRcycrUFcOr6KNz4GEr8yZg7C2/gh3q2cqMGpRAvDMMiB5ASXWKlP2g jbm4GIl1JwVcy/Ikcdan0p+3RdI5DigBa2B4VOFucDCxyM/5oK/KBaA8bfTNJ7DaQTlu Mu1NjSBf1yW2tU8Hlb6b6A1P5U3eztKTg/fKGnFBlZxBeBPassHiYM4j92xL1eAMIXIR 9E9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@amazon.de header.s=amazon201209 header.b=MCUGjObE; 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 v10si4996622pgg.510.2018.11.08.11.01.06; Thu, 08 Nov 2018 11:01:22 -0800 (PST) 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=MCUGjObE; 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 S1727223AbeKIEgR (ORCPT + 99 others); Thu, 8 Nov 2018 23:36:17 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:61701 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726751AbeKIEgR (ORCPT ); Thu, 8 Nov 2018 23:36:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1541703567; x=1573239567; h=from:to:cc:subject:date:message-id:mime-version; bh=QXnDituIZ9win6qVC9KoJnjwrBgkMuF0lvbTNnhU0Vg=; b=MCUGjObEcbZ0kIG9K10EuKSp+ZU2vtt3JVTVya3MKAtN3H03O0KTnE9v QXQLZxcsBf8VRuWVXmfbZ3zHwjRUiPImgTxI25/de6jxzg06E2J5XD9mk +Q1OIq7GWF9QJVqwj+PiXYAlRGUdmPL+pDqLB0YGa78HdNEmTwYP1tT+f Y=; X-IronPort-AV: E=Sophos;i="5.54,480,1534809600"; d="scan'208";a="372533464" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-c6afef2e.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Nov 2018 18:59:21 +0000 Received: from EX13MTAUEB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2c-c6afef2e.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id wA8IxI5T125445 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Thu, 8 Nov 2018 18:59:20 GMT Received: from EX13D08UEB001.ant.amazon.com (10.43.60.245) by EX13MTAUEB001.ant.amazon.com (10.43.60.96) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 8 Nov 2018 18:59:19 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D08UEB001.ant.amazon.com (10.43.60.245) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 8 Nov 2018 18:59:19 +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; Thu, 8 Nov 2018 18:59:19 +0000 Received: by dev-dsk-mheyne-1a-d7497a7f.eu-west-1.amazon.com (Postfix, from userid 5466572) id 62A82B03BF; Thu, 8 Nov 2018 18:59:19 +0000 (UTC) From: Maximilian Heyne CC: Christoph Hellwig , Maximilian Heyne , Torsten Mehlan , Uwe Dannowski , Amit Shah , David Woodhouse , , Alexander Viro , , Subject: [PATCH v2] fs: fix lost error code in dio_complete Date: Thu, 8 Nov 2018 18:58:34 +0000 Message-ID: <20181108185835.17803-1-mheyne@amazon.de> X-Mailer: git-send-email 2.16.5 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. Additionally, transferred is replaced with ret to bring this code in line with other callers. Reported-by: Ravi Nankani Signed-off-by: Maximilian Heyne Reviewed-by: Christoph Hellwig CC: Torsten Mehlan CC: Uwe Dannowski CC: Amit Shah CC: David Woodhouse CC: stable@vger.kernel.org --- v2: add description for s/transferred/ret/ change 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 722d17c88edb..41a0e97252ae 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.5 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich Ust-ID: DE 289 237 879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B