From patchwork Wed Dec 13 23:57:48 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: 10111203 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 BC129600CA for ; Wed, 13 Dec 2017 23:57:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD8029811 for ; Wed, 13 Dec 2017 23:57:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A27F629845; Wed, 13 Dec 2017 23:57:54 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 2614929826 for ; Wed, 13 Dec 2017 23:57:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751101AbdLMX5x (ORCPT ); Wed, 13 Dec 2017 18:57:53 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:37570 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750916AbdLMX5x (ORCPT ); Wed, 13 Dec 2017 18:57:53 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vBDNm2CU025054 for ; Wed, 13 Dec 2017 23:57:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=/E2WfRHl5/zcHoHdAiF4511TuJ9PRmOd8i0GJRuuWSI=; b=mRzGso7Wc25ynb21UjaL1YBhI7ALdHZ8JCveC3cowtV/U+I+8bVtlWFoHZrrc6aW/uk6 eh7tUQjiP7b19I+wioJRlZYIMUU3vrd1oIvDOXBRNSBiU/gsPIxVAqtmB2+TeYcIXHqa Bre4EqiW51uOnRgJqsGN01LUlJmjcKzusvs38YUDoaPHkinZl4tlcokvhwedcXtEGsjG Q9x4gIuhZti+AgO2ctbgCOcNK+a9qMea5lvgPmIIuhaMGce7evTes5V/fN92K4x4/jbO 5anFJ9GkjqfDTJDSvcURZHTm7wstWEZ2z7hjkTH2tSoBmfxGL2AGvHCRjdkjG6SKpwbU Pw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2eudq605da-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 13 Dec 2017 23:57:52 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vBDNvpNZ003035 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 13 Dec 2017 23:57:51 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 vBDNvoDB026377 for ; Wed, 13 Dec 2017 23:57:51 GMT Received: from localhost (/10.145.179.124) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 13 Dec 2017 15:57:50 -0800 Subject: [PATCH 14/15] xfs: cross-reference the realtime bitmap From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Wed, 13 Dec 2017 15:57:48 -0800 Message-ID: <151320946799.30154.6332590349439931573.stgit@magnolia> In-Reply-To: <151320938254.30154.1046660005648421683.stgit@magnolia> References: <151320938254.30154.1046660005648421683.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8744 signatures=668646 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712130322 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 From: Darrick J. Wong While we're scrubbing various btrees, cross-reference the records with the other metadata. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_rtbitmap.c | 30 ++++++++++++++++++++++++++++++ fs/xfs/scrub/bmap.c | 2 ++ fs/xfs/scrub/rtbitmap.c | 20 ++++++++++++++++++++ fs/xfs/scrub/scrub.h | 6 ++++++ fs/xfs/xfs_rtalloc.h | 4 ++++ 5 files changed, 62 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/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c index 3fb29a5..a3f25a2 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.c +++ b/fs/xfs/libxfs/xfs_rtbitmap.c @@ -1097,3 +1097,33 @@ xfs_verify_rtbno( { return rtbno < mp->m_sb.sb_rblocks; } + +/* Is the given extent all free? */ +int +xfs_rtalloc_extent_is_free( + struct xfs_mount *mp, + struct xfs_trans *tp, + xfs_rtblock_t start, + xfs_rtblock_t len, + bool *is_free) +{ + xfs_rtblock_t end; + xfs_extlen_t clen; + int matches; + int error; + + *is_free = false; + while (len) { + clen = len > ~0U ? ~0U : len; + error = xfs_rtcheck_range(mp, tp, start, clen, 1, &end, + &matches); + if (error || !matches || end < start + clen) + return error; + + len -= end - start; + start = end + 1; + } + + *is_free = true; + return error; +} diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c index 2b99f06..1e5ab53 100644 --- a/fs/xfs/scrub/bmap.c +++ b/fs/xfs/scrub/bmap.c @@ -276,6 +276,8 @@ xfs_scrub_bmap_rt_extent_xref( struct xfs_btree_cur *cur, struct xfs_bmbt_irec *irec) { + xfs_scrub_xref_not_rtfree(info->sc, irec->br_startblock, + irec->br_blockcount); } /* Cross-reference a single datadev extent record. */ diff --git a/fs/xfs/scrub/rtbitmap.c b/fs/xfs/scrub/rtbitmap.c index 6860d5d..bdf1484 100644 --- a/fs/xfs/scrub/rtbitmap.c +++ b/fs/xfs/scrub/rtbitmap.c @@ -98,3 +98,23 @@ xfs_scrub_rtsummary( /* XXX: implement this some day */ return -ENOENT; } + + +/* xref check that the extent is not free in the rtbitmap */ +void +xfs_scrub_xref_not_rtfree( + struct xfs_scrub_context *sc, + xfs_fsblock_t fsbno, + xfs_fsblock_t len) +{ + bool is_free; + int error; + + xfs_ilock(sc->mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP); + error = xfs_rtalloc_extent_is_free(sc->mp, sc->tp, fsbno, len, + &is_free); + if (xfs_scrub_should_xref(sc, &error, NULL) && is_free) + xfs_scrub_ino_xref_set_corrupt(sc, sc->mp->m_rbmip->i_ino, + NULL); + xfs_iunlock(sc->mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP); +} diff --git a/fs/xfs/scrub/scrub.h b/fs/xfs/scrub/scrub.h index 83cdcd8..91cc094 100644 --- a/fs/xfs/scrub/scrub.h +++ b/fs/xfs/scrub/scrub.h @@ -148,5 +148,11 @@ void xfs_scrub_xref_has_cow_staging(struct xfs_scrub_context *sc, void xfs_scrub_xref_not_shared(struct xfs_scrub_context *sc, struct xfs_btree_cur **pcur, xfs_agblock_t bno, xfs_extlen_t len); +#ifdef CONFIG_XFS_RT +void xfs_scrub_xref_not_rtfree(struct xfs_scrub_context *sc, + xfs_fsblock_t fsbno, xfs_fsblock_t len); +#else +# define xfs_scrub_xref_not_rtfree(sc, fsbno, len) do { } while (0) +#endif #endif /* __XFS_SCRUB_SCRUB_H__ */ diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h index 3f30f84..540d506 100644 --- a/fs/xfs/xfs_rtalloc.h +++ b/fs/xfs/xfs_rtalloc.h @@ -139,6 +139,9 @@ int xfs_rtalloc_query_all(struct xfs_trans *tp, xfs_rtalloc_query_range_fn fn, void *priv); bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); +int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp, + xfs_rtblock_t start, xfs_rtblock_t len, + bool *is_free); #else # define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (ENOSYS) # define xfs_rtfree_extent(t,b,l) (ENOSYS) @@ -148,6 +151,7 @@ bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); # define xfs_rtalloc_query_all(t,f,p) (ENOSYS) # define xfs_rtbuf_get(m,t,b,i,p) (ENOSYS) # define xfs_verify_rtbno(m, r) (false) +# define xfs_rtalloc_extent_is_free(m,t,s,l,i) (ENOSYS) static inline int /* error */ xfs_rtmount_init( xfs_mount_t *mp) /* file system mount structure */