Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8107248imu; Tue, 4 Dec 2018 03:07:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/U+X5mrHw0dv5rgr82oRuI31woN7/VPjAiZVdSqv+2eYwocCYe9XDAFxUVmf7YyTcXXvVuV X-Received: by 2002:a63:920a:: with SMTP id o10mr14684742pgd.141.1543921650097; Tue, 04 Dec 2018 03:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543921650; cv=none; d=google.com; s=arc-20160816; b=mx7aSToHAkgON3Zs0YNfjqW/osicyTsJ7LsB3BKns9Jj6+CJ+uxeF7Zp46uYMD1Oy4 ZQ3By2AgUcpjnumYZQBpQM/QKrS8Wqi7gtPyliGhD24GN0p9NxuHycBbgeY2Pdc490mU rdVOLqYkSkL+Nh8DhO13t8BGUrTGt2xVA6C8zLY+bs4pm0tjGPMG6eJcCVhiq9W+IpJF MuT7w5k3KL17QMsu8obcylQUu0hXwdkGI3JRIKHi6uTl2A7cTWaGnyeAnKK1pmuMfIa2 HAoGYEMntFc1iUQiNzApdeaVjyBz4fHfZ6s6kNE7OulP1WBqn8eMCYWETF6aiv0G++K4 +AVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xVsRO7ve3lpyNfSMzSRnaDirfyN7iSjEw49c5wktpn4=; b=PMpYY4ezZgmWtySkecYyJk1AjeyE/ny2yyppNDKKCqbqVbzNaKJ3NLEm2tm8RbBesW TTTmayZMalvkqpOY6qrAtt7D05TrO8iCx4mII93dFpnZ9QL0bKjJavbXBvg62R14Oy4a pNqRug9NYAnMBd6oCNYhhCKIVVIq3hdFuVVCwgZEPOHIyZ+MHqrP4MWg8+Bgktuxp+1B 0z4Rv/ig6Y9rgAqE6+iCONk8Int45kol6+NCAvDCvVikJUKiTO27wUfAEEwdz2SHuAd7 PxneI02Ok3oeYlIqblkzOudRFAIXV7/tLG5t0UNGw1GWUAj7kihisfvgl1hxENrIx6ny 9/Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2HMkJTNU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si16858821pfn.26.2018.12.04.03.07.14; Tue, 04 Dec 2018 03:07:30 -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=pass header.i=@kernel.org header.s=default header.b=2HMkJTNU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728286AbeLDLGQ (ORCPT + 99 others); Tue, 4 Dec 2018 06:06:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:54576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727909AbeLDLGP (ORCPT ); Tue, 4 Dec 2018 06:06:15 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F0F8B214DB; Tue, 4 Dec 2018 11:06:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921574; bh=LdHx4pJdyjBCKhLAe2UxM8XgIY32Qu2O530Bf9TEm+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2HMkJTNUZaQfu8vkbHPESzx4YY2pPQkmtCBKEpEWQVgJpqQD0UYcQnY0yHp870YMY agCblffmeaLhCOJa7mBUBAfIzX6jKRJnHSUwxFB03YuW3A+nfqHwTYXKNwIKQStH2Y HKagFMALbQX30tyohb2vyHcSIhg0XmfxuEcRM/tg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ravi Nankani , Maximilian Heyne , Christoph Hellwig , Torsten Mehlan , Uwe Dannowski , Amit Shah , David Woodhouse , Jens Axboe Subject: [PATCH 4.14 124/146] fs: fix lost error code in dio_complete Date: Tue, 4 Dec 2018 11:50:10 +0100 Message-Id: <20181204103731.825562140@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103726.750894136@linuxfoundation.org> References: <20181204103726.750894136@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maximilian Heyne commit 41e817bca3acd3980efe5dd7d28af0e6f4ab9247 upstream. 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. Fixes: e259221763a4 ("fs: simplify the generic_write_sync prototype") 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 Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/direct-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -304,8 +304,8 @@ static ssize_t dio_complete(struct dio * */ 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); }