From patchwork Thu Jun 12 08:26:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Hecheng X-Patchwork-Id: 4340021 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ECCD0BEEAA for ; Thu, 12 Jun 2014 08:32:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E03A202FF for ; Thu, 12 Jun 2014 08:32:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F5C0202E9 for ; Thu, 12 Jun 2014 08:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932875AbaFLIcJ (ORCPT ); Thu, 12 Jun 2014 04:32:09 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:14818 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932740AbaFLIcG (ORCPT ); Thu, 12 Jun 2014 04:32:06 -0400 X-IronPort-AV: E=Sophos;i="5.00,694,1396972800"; d="scan'208";a="31804635" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 12 Jun 2014 16:29:26 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s5C8W3NP013370; Thu, 12 Jun 2014 16:32:03 +0800 Received: from localhost.localdomain (10.167.226.111) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 12 Jun 2014 16:32:15 +0800 From: Gui Hecheng To: CC: <1i5t5.duncan@cox.net>, Gui Hecheng Subject: [PATCH v2 1/3] btrfs-progs: fix missing parity stripe for raid6 in chunk-recover Date: Thu, 12 Jun 2014 16:26:56 +0800 Message-ID: <1402561616-28949-1-git-send-email-guihc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 X-Originating-IP: [10.167.226.111] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 When deal with the p & q stripes for data profile raid6, chunk-recover forgets to insert them into the chunk record. Just insert them back freely. Also wrap the insert procedure into a new function, fill_chunk_up. Signed-off-by: Gui Hecheng --- changelog: v1->v2: cleanup changelog, 'inert' changed to 'insert' --- chunk-recover.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/chunk-recover.c b/chunk-recover.c index dfa7ff6..9b46b0b 100644 --- a/chunk-recover.c +++ b/chunk-recover.c @@ -1785,6 +1785,23 @@ static inline int count_devext_records(struct list_head *record_list) return num_of_records; } +static int fill_chunk_up(struct chunk_record *chunk, struct list_head *devexts, + struct recover_control *rc) +{ + int ret = 0; + int i; + + for (i = 0; i < chunk->num_stripes; i++) { + if (!chunk->stripes[i].devid) { + ret = insert_stripe(devexts, rc, chunk, i); + if (ret) + break; + } + } + + return ret; +} + #define EQUAL_STRIPE (1 << 0) static int rebuild_raid_data_chunk_stripes(struct recover_control *rc, @@ -1919,9 +1936,9 @@ next_csum: num_unordered = count_devext_records(&unordered); if (chunk->type_flags & BTRFS_BLOCK_GROUP_RAID6 && num_unordered == 2) { - list_splice_init(&unordered, &chunk->dextents); btrfs_release_path(&path); - return 0; + ret = fill_chunk_up(chunk, &unordered, rc); + return ret; } goto next_stripe; @@ -1966,14 +1983,7 @@ out: & BTRFS_BLOCK_GROUP_RAID5) || (num_unordered == 3 && chunk->type_flags & BTRFS_BLOCK_GROUP_RAID6)) { - for (i = 0; i < chunk->num_stripes; i++) { - if (!chunk->stripes[i].devid) { - ret = insert_stripe(&unordered, rc, - chunk, i); - if (ret) - break; - } - } + ret = fill_chunk_up(chunk, &unordered, rc); } } fail_out: