Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2478196yba; Mon, 15 Apr 2019 12:29:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgpNnQYs+AGEyqZVudrK5VImkIsExzNdOyWGT4pLap5i6Xg/r0+iGi5ITIzAjhRHccf2ck X-Received: by 2002:a63:ef07:: with SMTP id u7mr73775253pgh.0.1555356546702; Mon, 15 Apr 2019 12:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356546; cv=none; d=google.com; s=arc-20160816; b=kA3MmQchkSNa/q3jl8z3uym8N7seFbr7VFecVQILhcVrr3XqcEew5qX/xn7rymuaRo JOtbaJEhPtoYD+/eJIeqq2WplNcSUyXGvzQYgAVZd/5hGzG3/UNp1Wn6GV85O7KuIc05 EyShOUByEOcEpVeDBfKLmmIFmMKiu00QIK3iVli0fRx0YFazOAsgRhTo2UoCqY5xpex5 06xuz1R2gGPeaUwouS03Ck52OtUv0BzELER9GfC7t5TkHosT9MLrHVzv07EHkIfAoaoW u69TVJJzLc0D1AOK/Hk5yIBZQn9cgf07c/RTY78NLYK2gFziEFY/Or1U8a4Ejhk9bv3y S25A== 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=9wmHeRY5cZvyYcHQ3U167cAGwNucHtpvpnBQ2TkGWcQ=; b=g+pNAwmnHO+Xly84qPZezjopi6UcxuZB2iOHfh646IL5xv4pofAiY7gGFKd7lLzY1g NIhjnRRh1FKoVWLmEi3v9bhytKELolCoWYcysCvHwiGEShj//vjnFq3Im9EwaC4S2HK1 8BSIj06o6JROACVgCqaAXiR/k0PekJWOzJCdJAugaF3hC41rwOZZohmdinrctUg7i0sZ SaBQ5Ae6TqijhZJ/koeA5SIRvz+VRBiC25E9RsjDFFr0bt05lEDdhDaxw2qaqm4LdaTx u6/Uo2m+osCFYbZa+OkHLyCl4rr5zr9+FVcl4AlBpY8kbha6eKw3imkKEnu+LXe+TrY5 DUvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rpvqCp7E; 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 h191si28218102pge.342.2019.04.15.12.28.50; Mon, 15 Apr 2019 12:29:06 -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=pass header.i=@kernel.org header.s=default header.b=rpvqCp7E; 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 S1729478AbfDOTEN (ORCPT + 99 others); Mon, 15 Apr 2019 15:04:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:36862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728284AbfDOTEL (ORCPT ); Mon, 15 Apr 2019 15:04:11 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 3E2502087C; Mon, 15 Apr 2019 19:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355050; bh=3MsIuSf5MLosR73rhyHPqAW5GZ0jQvlZJhG+ylYEkUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rpvqCp7EW+r/9CRFAjHv1ueplosLzeSIubHVtsTnu2nQQ3SAjs6THUXxxvGn09ML8 GnFWKJFtl6DQ9Oey3k6jUY6uYw8JvDXC3VOGT6cTvGV8hmtU5iv0V4j0Hp5NEaq3uW 2S6PXxCgK6RgXwLj6kish4+MmyKOJNbPLwwya2CI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Jens Axboe , Ming Lei , Jason Yan Subject: [PATCH 4.14 50/69] block: fix the return errno for direct IO Date: Mon, 15 Apr 2019 20:59:08 +0200 Message-Id: <20190415183734.129268852@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183726.036654568@linuxfoundation.org> References: <20190415183726.036654568@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Jason Yan commit a89afe58f1a74aac768a5eb77af95ef4ee15beaa upstream. If the last bio returned is not dio->bio, the status of the bio will not assigned to dio->bio if it is error. This will cause the whole IO status wrong. ksoftirqd/21-117 [021] ..s. 4017.966090: 8,0 C N 4883648 [0] -0 [018] ..s. 4017.970888: 8,0 C WS 4924800 + 1024 [0] -0 [018] ..s. 4017.970909: 8,0 D WS 4935424 + 1024 [] -0 [018] ..s. 4017.970924: 8,0 D WS 4936448 + 321 [] ksoftirqd/21-117 [021] ..s. 4017.995033: 8,0 C R 4883648 + 336 [65475] ksoftirqd/21-117 [021] d.s. 4018.001988: myprobe1: (blkdev_bio_end_io+0x0/0x168) bi_status=7 ksoftirqd/21-117 [021] d.s. 4018.001992: myprobe: (aio_complete_rw+0x0/0x148) x0=0xffff802f2595ad80 res=0x12a000 res2=0x0 We always have to assign bio->bi_status to dio->bio.bi_status because we will only check dio->bio.bi_status when we return the whole IO to the upper layer. Fixes: 542ff7bf18c6 ("block: new direct I/O implementation") Cc: stable@vger.kernel.org Cc: Christoph Hellwig Cc: Jens Axboe Reviewed-by: Ming Lei Signed-off-by: Jason Yan Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/block_dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -306,10 +306,10 @@ static void blkdev_bio_end_io(struct bio struct blkdev_dio *dio = bio->bi_private; bool should_dirty = dio->should_dirty; - if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) { - if (bio->bi_status && !dio->bio.bi_status) - dio->bio.bi_status = bio->bi_status; - } else { + if (bio->bi_status && !dio->bio.bi_status) + dio->bio.bi_status = bio->bi_status; + + if (!dio->multi_bio || atomic_dec_and_test(&dio->ref)) { if (!dio->is_sync) { struct kiocb *iocb = dio->iocb; ssize_t ret;