From patchwork Mon May 11 07:58:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 6373811 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F292FBEEE1 for ; Mon, 11 May 2015 07:58:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 081CC2035E for ; Mon, 11 May 2015 07:58:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 15431202EC for ; Mon, 11 May 2015 07:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752619AbbEKH6j (ORCPT ); Mon, 11 May 2015 03:58:39 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:33632 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752499AbbEKH6e (ORCPT ); Mon, 11 May 2015 03:58:34 -0400 Received: by pdbnk13 with SMTP id nk13so140527853pdb.0 for ; Mon, 11 May 2015 00:58:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=D0CW7GjEbbA3KvhVLQWPunsW14jIIBodxgeS3r9z888=; b=BOXE80unifYF4E0PMNwd7dpLOxIIf5XIFB2HBY6lKvRAC/3h/EKWKEI96ITR0RpZdx nXEDvjHk4eIK1dsnHb5gyUEi7R44XYuaS1kVXdAHFhVELPuJD5juy35Pov7/zBIw1LuG f12yNJlEpLVCpcnBvB/OtnhCH4HA2WF4gvoiLiq1GwlZb/Ej4JGS5mZ4IaV8EGYCoUZS nPzD6dDu7qo06RMqQPyZ/iIZCFaf4Gp7OlpF0lErJeKyXKwfUSFIN6exoutDkEKTeUnY azs0ZOWbuRhWh59xYPU7O0AKXlaf86oFI+8zXmlFS1D1CjNieAQIfgn5PZSCNuUo3xD7 8+Vg== X-Gm-Message-State: ALoCoQmvua5MdbCAyweNrvQRqWgmDm4eg/AzsedYUWfUPRYtARzNZyp+sHmqbDXOzjT0Drsved1T X-Received: by 10.68.178.229 with SMTP id db5mr17261984pbc.17.1431331114063; Mon, 11 May 2015 00:58:34 -0700 (PDT) Received: from mew.localdomain (c-76-104-211-44.hsd1.wa.comcast.net. [76.104.211.44]) by mx.google.com with ESMTPSA id bq3sm12174498pbd.24.2015.05.11.00.58.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 May 2015 00:58:33 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: Miao Xie , Philip , Omar Sandoval Subject: [PATCH 2/4] Btrfs: count devices correctly in readahead during RAID 5/6 replace Date: Mon, 11 May 2015 00:58:13 -0700 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 5fbc7c59fd22 ("Btrfs: fix unfinished readahead thread for raid5/6 degraded mounting") fixed a problem where we would skip a missing device when we shouldn't have because there are no other mirrors to read from in RAID 5/6. After commit 2c8cdd6ee4e7 ("Btrfs, replace: write dirty pages into the replace target device"), the fix doesn't work when we're doing a missing device replace on RAID 5/6 because the replace device is counted as a mirror so we're tricked into thinking we can safely skip the missing device. The fix is to count only the real stripes and decide based on that. Signed-off-by: Omar Sandoval --- fs/btrfs/reada.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c index 0e7beea..4645cd1 100644 --- a/fs/btrfs/reada.c +++ b/fs/btrfs/reada.c @@ -328,6 +328,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root, struct btrfs_device *prev_dev; u32 blocksize; u64 length; + int real_stripes; int nzones = 0; int i; unsigned long index = logical >> PAGE_CACHE_SHIFT; @@ -369,7 +370,8 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root, goto error; } - for (nzones = 0; nzones < bbio->num_stripes; ++nzones) { + real_stripes = bbio->num_stripes - bbio->num_tgtdevs; + for (nzones = 0; nzones < real_stripes; ++nzones) { struct reada_zone *zone; dev = bbio->stripes[nzones].dev;