Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp839670imu; Tue, 11 Dec 2018 08:20:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uo4FRcDS/V9+xEcHsvXQd5xf0TeRgtV7yC4BujYUKJGg9mpatqt+xK1QgNc7T3ywuL+qBS X-Received: by 2002:a63:31d0:: with SMTP id x199mr15002519pgx.10.1544545242582; Tue, 11 Dec 2018 08:20:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544545242; cv=none; d=google.com; s=arc-20160816; b=ZA/hzjtLgz05Jb4Exh426rZWjn77MrL3fayKT3KuBDhNTwwiYac09qBRZE29h30wEf 5dxLK99d/lRFDlj+1NPcaxrqJgMMxexCHrKiYDYDE1n9u6gej45XFGIaIoqTivS3Y01V zO0yNum0lD/sn+iSBeMs40jMTocwQuy6FoT/spgZiQRtRyqp+I7dwQKtafqscfzS4d9W Q7QeD6nIP2eDxcMCPJMX9Vm76/oeVE1HXBREcCC0gmivrYoetpXa5WPIsX49xam75sEj nMadaM8T3G0ufE8A5WBNP2U272Rabo20mpu0y8PSC5WowDHTBF8uAEV5MMWfvzPvWviZ BSiA== 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=WNWfxl2dVnVHUGWQLPO1K2eKMS72SrHZNh7SUcasHgE=; b=PYeCtK5iBRRml83FYXsuEgkbnfXzVgVycteUlPR4SYjXGPChuFh5+rPXAiLm0kI6A9 6+69ZPMG7QCFw2VR64nF8dIlAgx94jBukR1pP7Mjw8gpz/5z8H1nwVMzPmDyhQ/dcUIK /wdKLRZmXOfJ/nu0jZ6KB7/vleTpWqtgpJjaBOi4z82rKwHGek2Lf2sVc7eHFU017jQ8 OYKGoJD3/k8lXy5pBJ0kKUWwwG1gNs3xf6LeRHP21Lc7f9raSHRhFKhOWTIqo65j5rVO l0Nv9pX8xnZ1ivZ+jMS5i9jpIMPtj0mE4d38KLArFhVSSU1pFDvJv5hgmUZbzXMxR0P5 c8hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hRbWshgx; 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 q14si12123048pgq.197.2018.12.11.08.20.27; Tue, 11 Dec 2018 08:20:42 -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=hRbWshgx; 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 S1727658AbeLKPq7 (ORCPT + 99 others); Tue, 11 Dec 2018 10:46:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:35330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727048AbeLKPq5 (ORCPT ); Tue, 11 Dec 2018 10:46:57 -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 7F3BE2086D; Tue, 11 Dec 2018 15:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543217; bh=gKNmLvABvUveaEPIlorXQsFj/fLnbemq4KidqLiOnHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hRbWshgxsY0POTBM0ennS+VjLFMKd/O6k8+cV3rlz6bXiLQ+zEN8qDz363lfpbMrk JvleJk9rAbeFPlIRkM4uokDxsPg9kd9WoUYpw+s6s9xqJLtFuybpTGkbIBKNg0zx/6 HAz48fIgNRDwLyG8r7tikFrrYUjHTqhvnScoLqLM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qu Wenruo , Nikolay Borisov , David Sterba Subject: [PATCH 4.4 50/91] btrfs: Always try all copies when reading extent buffers Date: Tue, 11 Dec 2018 16:41:09 +0100 Message-Id: <20181211151610.015380170@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151606.026852373@linuxfoundation.org> References: <20181211151606.026852373@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikolay Borisov commit f8397d69daef06d358430d3054662fb597e37c00 upstream. When a metadata read is served the endio routine btree_readpage_end_io_hook is called which eventually runs the tree-checker. If tree-checker fails to validate the read eb then it sets EXTENT_BUFFER_CORRUPT flag. This leads to btree_read_extent_buffer_pages wrongly assuming that all available copies of this extent buffer are wrong and failing prematurely. Fix this modify btree_read_extent_buffer_pages to read all copies of the data. This failure was exhibitted in xfstests btrfs/124 which would spuriously fail its balance operations. The reason was that when balance was run following re-introduction of the missing raid1 disk __btrfs_map_block would map the read request to stripe 0, which corresponded to devid 2 (the disk which is being removed in the test): item 2 key (FIRST_CHUNK_TREE CHUNK_ITEM 3553624064) itemoff 15975 itemsize 112 length 1073741824 owner 2 stripe_len 65536 type DATA|RAID1 io_align 65536 io_width 65536 sector_size 4096 num_stripes 2 sub_stripes 1 stripe 0 devid 2 offset 2156920832 dev_uuid 8466c350-ed0c-4c3b-b17d-6379b445d5c8 stripe 1 devid 1 offset 3553624064 dev_uuid 1265d8db-5596-477e-af03-df08eb38d2ca This caused read requests for a checksum item that to be routed to the stale disk which triggered the aforementioned logic involving EXTENT_BUFFER_CORRUPT flag. This then triggered cascading failures of the balance operation. Fixes: a826d6dcb32d ("Btrfs: check items for correctness as we search") CC: stable@vger.kernel.org # 4.4+ Suggested-by: Qu Wenruo Reviewed-by: Qu Wenruo Signed-off-by: Nikolay Borisov Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/disk-io.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -445,9 +445,9 @@ static int btree_read_extent_buffer_page int mirror_num = 0; int failed_mirror = 0; - clear_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags); io_tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree; while (1) { + clear_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags); ret = read_extent_buffer_pages(io_tree, eb, start, WAIT_COMPLETE, btree_get_extent, mirror_num); @@ -459,14 +459,6 @@ static int btree_read_extent_buffer_page ret = -EIO; } - /* - * This buffer's crc is fine, but its contents are corrupted, so - * there is no reason to read the other copies, they won't be - * any less wrong. - */ - if (test_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags)) - break; - num_copies = btrfs_num_copies(root->fs_info, eb->start, eb->len); if (num_copies == 1)