Received: by 10.213.65.68 with SMTP id h4csp1761381imn; Mon, 19 Mar 2018 12:31:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELubDKd3GHdzsBm6ZKxaLlD2usLLL7aaSQ/SoYqPknuEASIwixYZlRqFPV74c5TcdTz17GuV X-Received: by 2002:a17:902:ab84:: with SMTP id f4-v6mr13920339plr.239.1521487897163; Mon, 19 Mar 2018 12:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521487897; cv=none; d=google.com; s=arc-20160816; b=bvrS22j/YORsl8MYL74iFTY2q+9oh/kVb5yaU/+A2NF1NjDkC3SZba8CaO8bFo6oY2 pbFkGcSVkH8oBslezXrENWBja0BgIXqrZ8Sarl/cNxBiphSrniWuXpUzskDhw/N+FzeE Ynzlgl81S4vhW0vRi1kDRgj8py/GT/e/UyAIe7DWN5e3c/V878pLehSUYO7xtGNdA1L5 JXg5+32ZrQwF2Z1uvI7C9rxLXKgkeEUeAVXDK81F0f32DQyzJOXzDMhf0rY3e3KsVTNR pMV8qXT/WdCBQVT6yHrNArj7p6mSDhKn01OnaoLJTU8IC946pzCF0+09BWwHHEjZXfb4 /HOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=cMcluFtToQ5AlAkxcSSNPFVzb0RyOlNgxGlppidQGjg=; b=axguhV4/5kq9U0Fa5/xGO4iId+NfqgK37K3gK1+pg5c/DUcggknQ92pr/CTXzf+7zk HZ8jFwUJ/11MUOZD4sBgmmGzKU6FWanigzBCyFIcvDWsE5lQ7Sf9JaXdtxCM/L3buFYF lF1Of1BEz6veFu+7/FKdt0+o6i2SJSmLhscRCTma8OlPZlb5r9iewvMYjTETJGHN9P4S vKC4n2NkuQVl3CldOTN3e020vdreJrF2b6qbupCJIeg5HIsHgfpUgmZg7695hyOf6hAI mjIPB2AQvK10W/hJhqqk+0zn+PVMYofwB8xuuNiKOuXwqp3mPODDH/CfhHQRWdo/bLqf tOzg== ARC-Authentication-Results: i=1; mx.google.com; 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 p3si434902pfh.84.2018.03.19.12.31.22; Mon, 19 Mar 2018 12:31:37 -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; 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 S936050AbeCST2i (ORCPT + 99 others); Mon, 19 Mar 2018 15:28:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49736 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969562AbeCSSYE (ORCPT ); Mon, 19 Mar 2018 14:24:04 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 82536E8E; Mon, 19 Mar 2018 18:24:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Williams , NeilBrown , Shaohua Li , Sasha Levin Subject: [PATCH 4.9 136/241] md/raid6: Fix anomily when recovering a single device in RAID6. Date: Mon, 19 Mar 2018 19:06:41 +0100 Message-Id: <20180319180756.821554753@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: NeilBrown [ Upstream commit 7471fb77ce4dc4cb81291189947fcdf621a97987 ] When recoverying a single missing/failed device in a RAID6, those stripes where the Q block is on the missing device are handled a bit differently. In these cases it is easy to check that the P block is correct, so we do. This results in the P block be destroy. Consequently the P block needs to be read a second time in order to compute Q. This causes lots of seeks and hurts performance. It shouldn't be necessary to re-read P as it can be computed from the DATA. But we only compute blocks on missing devices, since c337869d9501 ("md: do not compute parity unless it is on a failed drive"). So relax the change made in that commit to allow computing of the P block in a RAID6 which it is the only missing that block. This makes RAID6 recovery run much faster as the disk just "before" the recovering device is no longer seeking back-and-forth. Reported-by-tested-by: Brad Campbell Reviewed-by: Dan Williams Signed-off-by: NeilBrown Signed-off-by: Shaohua Li Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/md/raid5.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -3391,9 +3391,20 @@ static int fetch_block(struct stripe_hea BUG_ON(test_bit(R5_Wantcompute, &dev->flags)); BUG_ON(test_bit(R5_Wantread, &dev->flags)); BUG_ON(sh->batch_head); + + /* + * In the raid6 case if the only non-uptodate disk is P + * then we already trusted P to compute the other failed + * drives. It is safe to compute rather than re-read P. + * In other cases we only compute blocks from failed + * devices, otherwise check/repair might fail to detect + * a real inconsistency. + */ + if ((s->uptodate == disks - 1) && + ((sh->qd_idx >= 0 && sh->pd_idx == disk_idx) || (s->failed && (disk_idx == s->failed_num[0] || - disk_idx == s->failed_num[1]))) { + disk_idx == s->failed_num[1])))) { /* have disk failed, and we're requested to fetch it; * do compute it */