From patchwork Mon Dec 2 02:52:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 3263401 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 851C69F373 for ; Mon, 2 Dec 2013 02:52:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BEBDB20117 for ; Mon, 2 Dec 2013 02:52:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 687A6200F1 for ; Mon, 2 Dec 2013 02:52:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752879Ab3LBCwx (ORCPT ); Sun, 1 Dec 2013 21:52:53 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:6720 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752849Ab3LBCwv (ORCPT ); Sun, 1 Dec 2013 21:52:51 -0500 X-IronPort-AV: E=Sophos;i="4.93,807,1378828800"; d="scan'208";a="9167829" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 02 Dec 2013 10:49:22 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id rB22qnOo020115; Mon, 2 Dec 2013 10:52:49 +0800 Received: from wangs.fnst.cn.fujitsu.com ([10.167.226.104]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013120210524602-27179 ; Mon, 2 Dec 2013 10:52:46 +0800 From: Wang Shilong To: linux-btrfs@vger.kernel.org Cc: ochmann@informatik.uni-bonn.de Subject: [PATCH] Btrfs: fix wrong superblock generation mismatch while scrubbing superblocks Date: Mon, 2 Dec 2013 10:52:31 +0800 Message-Id: <1385952751-4251-1-git-send-email-wangsl.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/12/02 10:52:46, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/12/02 10:52:46, Serialize complete at 2013/12/02 10:52:46 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, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 While scrubbing superblocks we will check every superblock's checksum and generation. However, checking superblock's generation may cause some problems, this is because tree log sync only flush first superblock , while this will cause other superblocks' generation mismatch. We only report superblock generation mismatch if it is first superblock or we make sure we are not doing tree log. Reported-by: Sebastian Ochmann Signed-off-by: Wang Shilong Reviewed-by: Miao Xie --- fs/btrfs/scrub.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 2544805..b29a91f 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -1794,8 +1794,15 @@ static int scrub_checksum_super(struct scrub_block *sblock) if (sblock->pagev[0]->logical != btrfs_super_bytenr(s)) ++fail_cor; - if (sblock->pagev[0]->generation != btrfs_super_generation(s)) - ++fail_gen; + if (sblock->pagev[0]->generation != btrfs_super_generation(s)) { + /* + * we only report a generation mismatch if this is first + * superblock or we can make sure we are not doing tree log. + */ + if (btrfs_super_bytenr(s) == btrfs_sb_offset(0) || + !root->fs_info->log_root_tree) + ++fail_gen; + } if (memcmp(s->fsid, fs_info->fsid, BTRFS_UUID_SIZE)) ++fail_cor;