From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2nam03on0120.outbound.protection.outlook.com ([104.47.42.120]:61603 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754269AbeDIA3K (ORCPT ); Sun, 8 Apr 2018 20:29:10 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Liu Bo , David Sterba , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 093/293] Btrfs: tolerate errors if we have retried successfully Date: Mon, 9 Apr 2018 00:24:06 +0000 Message-ID: <20180409002239.163177-93-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Liu Bo [ Upstream commit e3d37faba2eb19a1d459917bbf54ac1c65711510 ] With raid1 profile, dio read isn't tolerating IO errors if read length is less than the stripe length (64K). Our bio didn't get split in btrfs_submit_direct_hook() if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) is true and that happens when the read length is less than 64k. In this case, if the underlying device returns error somehow, bio->bi_error has recorded that error. If we could recover the correct data from another copy in profile raid1/10/= 5/6, with btrfs_subio_endio_read() returning 0, bio would have the correct data = in its vector, but bio->bi_error is not updated accordingly so that the follow= ing dio_end_io(dio_bio, bio->bi_error) makes directIO think this read has faile= d. This fixes the problem by setting bio's error to 0 if a good copy has been found. Signed-off-by: Liu Bo Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ffd5831ca15c..389ffaff72bf 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8219,8 +8219,11 @@ static void btrfs_endio_direct_read(struct bio *bio) struct btrfs_io_bio *io_bio =3D btrfs_io_bio(bio); int err =3D bio->bi_error; =20 - if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) + if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) { err =3D btrfs_subio_endio_read(inode, io_bio, err); + if (!err) + bio->bi_error =3D 0; + } =20 unlock_extent(&BTRFS_I(inode)->io_tree, dip->logical_offset, dip->logical_offset + dip->bytes - 1); --=20 2.15.1