From patchwork Sat Jan 21 08:05:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9529989 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 248606020B for ; Sat, 21 Jan 2017 08:05:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1437628427 for ; Sat, 21 Jan 2017 08:05:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 088C328698; Sat, 21 Jan 2017 08:05:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79F8E28427 for ; Sat, 21 Jan 2017 08:05:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751050AbdAUIFQ (ORCPT ); Sat, 21 Jan 2017 03:05:16 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:25453 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750892AbdAUIFQ (ORCPT ); Sat, 21 Jan 2017 03:05:16 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v0L85F17021940 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 21 Jan 2017 08:05:15 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.13.8/8.14.4) with ESMTP id v0L85Evl015954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 21 Jan 2017 08:05:14 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v0L85DUt025280; Sat, 21 Jan 2017 08:05:14 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 21 Jan 2017 00:05:13 -0800 Subject: [PATCH 45/55] xfs: repair superblocks From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Date: Sat, 21 Jan 2017 00:05:12 -0800 Message-ID: <148498591259.15323.15311453447528825295.stgit@birch.djwong.org> In-Reply-To: <148498561504.15323.8531512066874274553.stgit@birch.djwong.org> References: <148498561504.15323.8531512066874274553.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If one of the backup superblocks is found to differ seriously from superblock 0, write out a fresh copy from the in-core sb. Signed-off-by: Darrick J. Wong --- fs/xfs/scrub/agheader.c | 35 +++++++++++++++++++++++++++++++++++ fs/xfs/scrub/common.c | 2 +- fs/xfs/scrub/common.h | 4 ++++ 3 files changed, 40 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c index d94129c..df1305e 100644 --- a/fs/xfs/scrub/agheader.c +++ b/fs/xfs/scrub/agheader.c @@ -353,6 +353,41 @@ xfs_scrub_superblock( #undef XFS_SCRUB_SB_OP_ERROR_GOTO #undef XFS_SCRUB_SB_CHECK +/* Repair the superblock. */ +int +xfs_repair_superblock( + struct xfs_scrub_context *sc) +{ + struct xfs_mount *mp = sc->tp->t_mountp; + struct xfs_buf *bp; + struct xfs_dsb *sbp; + xfs_agnumber_t agno; + int error; + + /* Don't try to repair AG 0's sb; let xfs_repair deal with it. */ + agno = sc->sm->sm_agno; + if (agno == 0) + return -EOPNOTSUPP; + + error = xfs_trans_read_buf(mp, sc->tp, mp->m_ddev_targp, + XFS_AG_DADDR(mp, agno, XFS_SB_BLOCK(mp)), + XFS_FSS_TO_BB(mp, 1), 0, &bp, NULL); + if (error) + return error; + bp->b_ops = &xfs_sb_buf_ops; + + /* Copy AG 0's superblock to this one. */ + sbp = XFS_BUF_TO_SBP(bp); + memset(sbp, 0, mp->m_sb.sb_sectsize); + xfs_sb_to_disk(sbp, &mp->m_sb); + sbp->sb_bad_features2 = sbp->sb_features2; + + /* Write this to disk. */ + xfs_trans_buf_set_type(sc->tp, bp, XFS_BLFT_SB_BUF); + xfs_trans_log_buf(sc->tp, bp, 0, mp->m_sb.sb_sectsize - 1); + return error; +} + /* AGF */ /* Tally freespace record lengths. */ diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index 9de7502..9264ce3 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -761,7 +761,7 @@ struct xfs_scrub_meta_fns { static const struct xfs_scrub_meta_fns meta_scrub_fns[] = { {xfs_scrub_setup, xfs_scrub_dummy, NULL, NULL}, - {xfs_scrub_setup_ag, xfs_scrub_superblock, NULL, NULL}, + {xfs_scrub_setup_ag, xfs_scrub_superblock, xfs_repair_superblock, NULL}, {xfs_scrub_setup_ag, xfs_scrub_agf, NULL, NULL}, {xfs_scrub_setup_ag, xfs_scrub_agfl, NULL, NULL}, {xfs_scrub_setup_ag, xfs_scrub_agi, NULL, NULL}, diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h index 992d21b..92d294c 100644 --- a/fs/xfs/scrub/common.h +++ b/fs/xfs/scrub/common.h @@ -372,4 +372,8 @@ xfs_extlen_t xfs_repair_calc_ag_resblks(struct xfs_scrub_context *sc, struct xfs_inode *ip, struct xfs_scrub_metadata *sm); +/* Metadata repairers */ + +int xfs_repair_superblock(struct xfs_scrub_context *sc); + #endif /* __XFS_REPAIR_COMMON_H__ */