From patchwork Sat Dec 3 01:39:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9486641 X-Mozilla-Keys: nonjunk Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sandeen.net X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 X-Spam-HP: BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5,RP_MATCHES_RCVD=-0.1,UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001 X-Original-To: sandeen@sandeen.net Delivered-To: sandeen@sandeen.net Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by sandeen.net (Postfix) with ESMTP id DEFFF5FCC97 for ; Fri, 2 Dec 2016 19:38:44 -0600 (CST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932360AbcLCBji (ORCPT ); Fri, 2 Dec 2016 20:39:38 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:19946 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758457AbcLCBjd (ORCPT ); Fri, 2 Dec 2016 20:39:33 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uB31dBcF018578 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 3 Dec 2016 01:39:12 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 uB31dBpY013437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 3 Dec 2016 01:39:11 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id uB31dBRh006524; Sat, 3 Dec 2016 01:39:11 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Dec 2016 17:39:10 -0800 Subject: [PATCH 35/55] xfs: cross-reference extents with AG header From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 02 Dec 2016 17:39:09 -0800 Message-ID: <148072914974.12995.14395730006723595402.stgit@birch.djwong.org> In-Reply-To: <148072891404.12995.15510849192837089093.stgit@birch.djwong.org> References: <148072891404.12995.15510849192837089093.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 Ensure that none of the AG btree records overlap the AG sb/agf/agfl/agi headers except for the XFS_RMAP_OWN_FS rmap. Signed-off-by: Darrick J. Wong --- fs/xfs/repair/agheader.c | 27 +++++++++++++++++++++++++++ fs/xfs/repair/alloc.c | 4 ++++ fs/xfs/repair/bmap.c | 5 +++++ fs/xfs/repair/common.h | 3 +++ fs/xfs/repair/ialloc.c | 4 ++++ fs/xfs/repair/refcount.c | 4 ++++ fs/xfs/repair/rmap.c | 5 +++++ 7 files changed, 52 insertions(+) -- 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/repair/agheader.c b/fs/xfs/repair/agheader.c index 2bab685..c1b4b13 100644 --- a/fs/xfs/repair/agheader.c +++ b/fs/xfs/repair/agheader.c @@ -99,6 +99,30 @@ xfs_scrub_walk_agfl( return 0; } +/* Does this AG extent cover the AG headers? */ +bool +xfs_scrub_extent_covers_ag_head( + struct xfs_mount *mp, + xfs_agblock_t agbno, + xfs_extlen_t len) +{ + xfs_agblock_t bno; + + bno = XFS_SB_BLOCK(mp); + if (bno >= agbno && bno < agbno + len) + return true; + bno = XFS_AGF_BLOCK(mp); + if (bno >= agbno && bno < agbno + len) + return true; + bno = XFS_AGFL_BLOCK(mp); + if (bno >= agbno && bno < agbno + len) + return true; + bno = XFS_AGI_BLOCK(mp); + if (bno >= agbno && bno < agbno + len) + return true; + return false; +} + /* Superblock */ #define XFS_SCRUB_SB_CHECK(fs_ok) \ @@ -452,6 +476,9 @@ xfs_scrub_agfl_block( XFS_SCRUB_AGFL_CHECK(agbno < mp->m_sb.sb_agblocks); XFS_SCRUB_AGFL_CHECK(agbno < sagfl->eoag); + /* Cross-reference with the AG headers. */ + XFS_SCRUB_AGFL_CHECK(!xfs_scrub_extent_covers_ag_head(mp, agbno, 1)); + /* Cross-reference with the bnobt. */ if (sc->sa.bno_cur) { err2 = xfs_alloc_has_record(sc->sa.bno_cur, agbno, diff --git a/fs/xfs/repair/alloc.c b/fs/xfs/repair/alloc.c index 89f80f3..6369f09 100644 --- a/fs/xfs/repair/alloc.c +++ b/fs/xfs/repair/alloc.c @@ -70,6 +70,10 @@ xfs_scrub_allocbt_helper( if (error) goto out; + /* Make sure we don't cover the AG headers. */ + XFS_SCRUB_BTREC_CHECK(bs, + !xfs_scrub_extent_covers_ag_head(mp, bno, len)); + psa = &bs->sc->sa; /* * Ensure there's a corresponding cntbt/bnobt record matching diff --git a/fs/xfs/repair/bmap.c b/fs/xfs/repair/bmap.c index d81214a..b4f0abb 100644 --- a/fs/xfs/repair/bmap.c +++ b/fs/xfs/repair/bmap.c @@ -121,6 +121,11 @@ xfs_scrub_bmap_extent( XFS_SCRUB_BMAP_OP_ERROR_GOTO(out); } + /* Make sure we don't cover the AG headers. */ + if (!info->is_rt) + XFS_SCRUB_BMAP_CHECK(!xfs_scrub_extent_covers_ag_head(mp, + bno, irec->br_blockcount)); + /* Cross-reference with the bnobt. */ if (sa.bno_cur) { err2 = xfs_alloc_has_record(sa.bno_cur, bno, diff --git a/fs/xfs/repair/common.h b/fs/xfs/repair/common.h index fbde19c..f638703 100644 --- a/fs/xfs/repair/common.h +++ b/fs/xfs/repair/common.h @@ -203,6 +203,9 @@ int xfs_scrub_walk_agfl(struct xfs_scrub_context *sc, int (*fn)(struct xfs_scrub_context *, xfs_agblock_t bno, void *), void *priv); +bool xfs_scrub_extent_covers_ag_head(struct xfs_mount *mp, xfs_agblock_t agbno, + xfs_extlen_t len); + /* Metadata scrubbers */ int xfs_scrub_superblock(struct xfs_scrub_context *sc); diff --git a/fs/xfs/repair/ialloc.c b/fs/xfs/repair/ialloc.c index 70fc5fc..4f01932 100644 --- a/fs/xfs/repair/ialloc.c +++ b/fs/xfs/repair/ialloc.c @@ -76,6 +76,10 @@ xfs_scrub_iallocbt_chunk( goto out; } + /* Make sure we don't cover the AG headers. */ + XFS_SCRUB_BTREC_CHECK(bs, + !xfs_scrub_extent_covers_ag_head(mp, bno, len)); + psa = &bs->sc->sa; /* Cross-reference with the bnobt. */ if (psa->bno_cur) { diff --git a/fs/xfs/repair/refcount.c b/fs/xfs/repair/refcount.c index f5c0aef..527a916 100644 --- a/fs/xfs/repair/refcount.c +++ b/fs/xfs/repair/refcount.c @@ -76,6 +76,10 @@ xfs_scrub_refcountbt_helper( if (error) goto out; + /* Make sure we don't cover the AG headers. */ + XFS_SCRUB_BTREC_CHECK(bs, !xfs_scrub_extent_covers_ag_head(mp, + irec.rc_startblock, irec.rc_blockcount)); + psa = &bs->sc->sa; /* Cross-reference with the bnobt. */ if (psa->bno_cur) { diff --git a/fs/xfs/repair/rmap.c b/fs/xfs/repair/rmap.c index ef2aea5..401580e 100644 --- a/fs/xfs/repair/rmap.c +++ b/fs/xfs/repair/rmap.c @@ -106,6 +106,11 @@ xfs_scrub_rmapbt_helper( if (error) goto out; + /* Make sure only the AG header owner maps to the AG header. */ + XFS_SCRUB_BTREC_CHECK(bs, irec.rm_owner == XFS_RMAP_OWN_FS || + !xfs_scrub_extent_covers_ag_head(mp, irec.rm_startblock, + irec.rm_blockcount)); + psa = &bs->sc->sa; /* check there's no record in freesp btrees */ if (psa->bno_cur) {