From patchwork Thu Aug 25 23:42:21 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: 9300403 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 9439B60757 for ; Thu, 25 Aug 2016 23:43:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8486229354 for ; Thu, 25 Aug 2016 23:43:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 793B0293CD; Thu, 25 Aug 2016 23:43:26 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EEE6429354 for ; Thu, 25 Aug 2016 23:43:25 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id 0C61E7F17; Thu, 25 Aug 2016 18:42:34 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay2.corp.sgi.com [137.38.102.29]) by oss.sgi.com (Postfix) with ESMTP id DABFE7F07 for ; Thu, 25 Aug 2016 18:42:32 -0500 (CDT) Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by relay2.corp.sgi.com (Postfix) with ESMTP id 8F5B9304039 for ; Thu, 25 Aug 2016 16:42:32 -0700 (PDT) X-ASG-Debug-ID: 1472168550-0bf81509b01df730001-NocioJ Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by cuda.sgi.com with ESMTP id 1JpIekqy8XTTDRvV (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 25 Aug 2016 16:42:30 -0700 (PDT) X-Barracuda-Envelope-From: darrick.wong@oracle.com X-Barracuda-Effective-Source-IP: userp1040.oracle.com[156.151.31.81] X-Barracuda-Apparent-Source-IP: 156.151.31.81 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u7PNgT2K025236 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Aug 2016 23:42:29 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u7PNgSl3016527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Aug 2016 23:42:29 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u7PNgSMk031035; Thu, 25 Aug 2016 23:42:28 GMT Received: from localhost (/10.145.178.207) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 25 Aug 2016 16:42:28 -0700 Subject: [PATCH 20/25] xfs: cross-reference extents with AG header From: "Darrick J. Wong" X-ASG-Orig-Subj: [PATCH 20/25] xfs: cross-reference extents with AG header To: david@fromorbit.com, darrick.wong@oracle.com Date: Thu, 25 Aug 2016 16:42:21 -0700 Message-ID: <147216854170.3108.4876331933510244657.stgit@birch.djwong.org> In-Reply-To: <147216841262.3108.10746252464845687338.stgit@birch.djwong.org> References: <147216841262.3108.10746252464845687338.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: userv0021.oracle.com [156.151.31.71] X-Barracuda-Connect: userp1040.oracle.com[156.151.31.81] X-Barracuda-Start-Time: 1472168550 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.157.11:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 4139 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=2.7 tests=BSF_SC0_MISMATCH_TO, UNPARSEABLE_RELAY X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.32328 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header 0.00 UNPARSEABLE_RELAY Informational: message has unparseable relay lines Cc: linux-xfs@vger.kernel.org, xfs@oss.sgi.com X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com X-Virus-Scanned: ClamAV using ClamSMTP 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/xfs_scrub.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/fs/xfs/xfs_scrub.c b/fs/xfs/xfs_scrub.c index 66365e2..63a7434 100644 --- a/fs/xfs/xfs_scrub.c +++ b/fs/xfs/xfs_scrub.c @@ -434,6 +434,30 @@ xfs_scrub_put_ag_headers( *agi_bpp = *agf_bpp = NULL; } +/* Does this AG extent cover the AG headers? */ +STATIC 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; +} + /* * For scrub, grab the AGI and the AGF headers, in that order. * Locking order requires us to get the AGI before the AGF. @@ -1013,6 +1037,10 @@ xfs_scrub_agfl( XFS_SCRUB_CHECK(mp, agfl_bp, "AGFL", agbno < eoag); + /* Cross-reference with the AG headers. */ + XFS_SCRUB_CHECK(mp, agfl_bp, "AGFL", + !xfs_scrub_extent_covers_ag_head(mp, agbno, 1)); + /* Cross-reference with the bnobt. */ err2 = xfs_alloc_has_record(xcur, agbno, 1, &is_freesp); if (!err2) @@ -1117,6 +1145,10 @@ xfs_scrub_allocbt_helper( XFS_BTREC_SCRUB_CHECK(bs, (unsigned long long)bno + len <= be32_to_cpu(agf->agf_length)); + /* Make sure we don't cover the AG headers. */ + XFS_BTREC_SCRUB_CHECK(bs, + !xfs_scrub_extent_covers_ag_head(mp, bno, len)); + /* * Ensure there's a corresponding cntbt/bnobt record matching * this bnobt/cntbt record, respectively. @@ -1233,6 +1265,10 @@ xfs_scrub_iallocbt_helper( XFS_BTREC_SCRUB_CHECK(bs, (unsigned long long)bno + len <= eoag); + /* Make sure we don't cover the AG headers. */ + XFS_BTREC_SCRUB_CHECK(bs, + !xfs_scrub_extent_covers_ag_head(mp, bno, len)); + /* Cross-reference with the bnobt. */ err2 = xfs_alloc_has_record(bs->bno_cur, bno, len, &is_freesp); @@ -1267,6 +1303,10 @@ xfs_scrub_iallocbt_helper( XFS_BTREC_SCRUB_CHECK(bs, (unsigned long long)bno + len <= eoag); + /* Make sure we don't cover the AG headers. */ + XFS_BTREC_SCRUB_CHECK(bs, + !xfs_scrub_extent_covers_ag_head(mp, bno, len)); + /* Cross-reference with the bnobt. */ err2 = xfs_alloc_has_record(bs->bno_cur, bno, len, &is_freesp); @@ -1378,6 +1418,11 @@ xfs_scrub_rmapbt_helper( XFS_BTREC_SCRUB_CHECK(bs, !non_inode || !(is_bmbt || is_unwritten || is_attr)); + /* Make sure only the AG header owner maps to the AG header. */ + XFS_BTREC_SCRUB_CHECK(bs, irec.rm_owner == XFS_RMAP_OWN_FS || + !xfs_scrub_extent_covers_ag_head(mp, irec.rm_startblock, + irec.rm_blockcount)); + /* check there's no record in freesp btrees */ err2 = xfs_alloc_has_record(bs->bno_cur, irec.rm_startblock, irec.rm_blockcount, &is_freesp); @@ -1452,6 +1497,10 @@ xfs_scrub_refcountbt_helper( irec.rc_blockcount <= eoag); XFS_BTREC_SCRUB_CHECK(bs, irec.rc_refcount >= 1); + /* Make sure we don't cover the AG headers. */ + XFS_BTREC_SCRUB_CHECK(bs, !xfs_scrub_extent_covers_ag_head(mp, + irec.rc_startblock, irec.rc_blockcount)); + /* Cross-reference with the bnobt. */ err2 = xfs_alloc_has_record(bs->bno_cur, irec.rc_startblock, irec.rc_blockcount, &is_freesp); @@ -1639,6 +1688,11 @@ xfs_scrub_bmap_extent( if (error) goto out; + /* Make sure we don't cover the AG headers. */ + XFS_INO_SCRUB_CHECK(ip, bp, info->type, info->is_rt || + !xfs_scrub_extent_covers_ag_head(mp, bno, + irec->br_blockcount)); + /* Cross-reference with the bnobt. */ xcur = xfs_allocbt_init_cursor(mp, NULL, agf_bp, agno, XFS_BTNUM_BNO);