Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2475637yba; Mon, 15 Apr 2019 12:25:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyUsa7R7Mx3lRNe1jsS1vt8QuBK6yyAJxRktK20vWtWEWtX08/6+6wxLD1vGbhgqQVvpTC X-Received: by 2002:a63:ce50:: with SMTP id r16mr70210749pgi.89.1555356343905; Mon, 15 Apr 2019 12:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356343; cv=none; d=google.com; s=arc-20160816; b=Jx5X1heUrTCp99GzHhM0nwRwD3NGubyPtcliqr3jki+rX18noQ2zfHzxkMm4DMvXBZ BsPq7JE+EEvBYCGpgza51faKkLMQF3zZkMaFMolWeomhvU0Vu8FhppAU+R32zvEQhdHc YBk7AM/v2LwsU/A7ikczEJJhpoZTHiqbC6gXGsI2E/3PL/pjEJt3en1rcJeh21SQpJlS Gfou7gKJ+ObsEK/q6itzcNlyhKiBGaWJCCLEIofdVufCjSkSZDKmIApGcsgMzG384I8n +KwvowBcd7BByRFW/B01MQdekBMRUx+q23RrlRu+pTm1LgxsaUg7xk1oDwgTAR+lTG+b 6bSQ== 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=becEwSU2b2MaVuournDskfRzaISEUEfHwXPw9Hnb2E0=; b=Zwq9qZolUrqst+ZL3ERJWazzZBY0pzxkD4DEWOMdPCM6AXXwVlr+AGy07GavQGTpCi 9rUFRwXEhZzWHYazbb9BPiFwVQRL/nShtNkM7xl9LJi9cud3NUAinDC67CLLdK5/Kjs1 CgI7A1WUsAMSUNi6Sezzl+l/cnX0bGQpdeYnQQVI7qveh2QvAEDjVm3qGjGAqZfxYYbd u2s6lVQMz6U6xXir2v00zeSbQAqMzo6NO9xYY6/rbaDpEDCJ6OyK1KXVOrhTqpacwnIs WwYfICBnB3DEZGtbZkasAc7PW6b9ge1fK1CKE/201Hf3pDbCsJyD2v4zdsE7HUtrSxFw Y5aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Nlv/DJGD"; 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 t15si45339712pgq.235.2019.04.15.12.25.27; Mon, 15 Apr 2019 12:25:43 -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="Nlv/DJGD"; 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 S1730297AbfDOTHq (ORCPT + 99 others); Mon, 15 Apr 2019 15:07:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:42790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730281AbfDOTHo (ORCPT ); Mon, 15 Apr 2019 15:07:44 -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 EDA83218A1; Mon, 15 Apr 2019 19:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355263; bh=jBd/6zuOEYXrzTpsJs3NC85Ovku+D8BYFEdprS23q2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nlv/DJGDhPkMhrliAXTs/U1UuGDXpjJIziRZXxrxO9az8lqPSnz7Qvh0D4WqtvNXY sUkAftiM41ubgZ7RlFNHZzNHbNIlDlwAUnrNfAsL4B0uj5kgcT4eYQ0cxvFYDgINXi vbjb7Fz6B6Unr5NNRvxZA+Fe26cgfH+y4ooJ35qs= 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.19 072/101] block: fix the return errno for direct IO Date: Mon, 15 Apr 2019 20:59:10 +0200 Message-Id: <20190415183744.271284645@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@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 @@ -296,10 +296,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;