From patchwork Tue Nov 6 04:08:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10669575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B97CA14E2 for ; Tue, 6 Nov 2018 04:08:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A746E29FF5 for ; Tue, 6 Nov 2018 04:08:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BB0F2A036; Tue, 6 Nov 2018 04:08:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 3923A29FF5 for ; Tue, 6 Nov 2018 04:08:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729319AbeKFNb2 (ORCPT ); Tue, 6 Nov 2018 08:31:28 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:60822 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbeKFNb2 (ORCPT ); Tue, 6 Nov 2018 08:31:28 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA640A4X031258 for ; Tue, 6 Nov 2018 04:08:15 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-2018-07-02; bh=QyPJ3n+V98p05UigWxo9PTrEEnHTgfMfy8SMmmQyEZY=; b=OvCsYbh7edzPBUzPH17XaHOjgac86t+J3yMgyK046RbtOdlV0S9gRPeDehrKbiqXMb2O w15e4/ujiizkUhZqT1hwTCqooNclw1g54LflZUMKLJ2i7liv0glh8+1BWgtKkyA/NtL+ jcWhk0SYlLdqp+4r8r9UPMHikE1R5R/hfjf2TVXWDBWZIikHwBOVF9YBWyv9ymd9fGpN mxbvQVq06tGdW9MSFvg117sWG9g1baqCVTxhW/blNEo/Qc4Bm5d2RA47BnTBaMSY+NKJ 3nCm9CXWhkGZJavwVf4LfuZ4Jk6mGzZ3VNMDgC1JdrbagwhoVcmrNiWCf4D3krlLoI7B pA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2nh3mpjt1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 06 Nov 2018 04:08:14 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wA648EeA012065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 6 Nov 2018 04:08:14 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wA648DqE011390 for ; Tue, 6 Nov 2018 04:08:14 GMT Received: from localhost (/10.159.235.241) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Nov 2018 20:08:13 -0800 Subject: [PATCH 1/8] xfs: count inode blocks correctly in inobt scrub From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 05 Nov 2018 20:08:12 -0800 Message-ID: <154147729274.32496.16585638036818485278.stgit@magnolia> In-Reply-To: <154147728649.32496.4515247239602322709.stgit@magnolia> References: <154147728649.32496.4515247239602322709.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9068 signatures=668683 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-1807170000 definitions=main-1811060032 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 A big block filesystem might require more than one inobt record to cover all the inodes in the block. In these cases it is not correct to round the irec count up to the nearest block because this causes us to overestimate the number of inode blocks we expect to find. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/scrub/ialloc.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c index 224dba937492..76ae8338a42e 100644 --- a/fs/xfs/scrub/ialloc.c +++ b/fs/xfs/scrub/ialloc.c @@ -44,6 +44,11 @@ xchk_setup_ag_iallocbt( /* Inode btree scrubber. */ +struct xchk_iallocbt { + /* Number of inodes we see while scanning inobt. */ + unsigned long long inodes; +}; + /* * If we're checking the finobt, cross-reference with the inobt. * Otherwise we're checking the inobt; if there is an finobt, make sure @@ -272,7 +277,7 @@ xchk_iallocbt_rec( union xfs_btree_rec *rec) { struct xfs_mount *mp = bs->cur->bc_mp; - xfs_filblks_t *inode_blocks = bs->private; + struct xchk_iallocbt *iabt = bs->private; struct xfs_inobt_rec_incore irec; uint64_t holes; xfs_agnumber_t agno = bs->cur->bc_private.a.agno; @@ -310,8 +315,7 @@ xchk_iallocbt_rec( (agbno & (xfs_icluster_size_fsb(mp) - 1))) xchk_btree_set_corrupt(bs->sc, bs->cur, 0); - *inode_blocks += XFS_B_TO_FSB(mp, - irec.ir_count * mp->m_sb.sb_inodesize); + iabt->inodes += irec.ir_count; /* Handle non-sparse inodes */ if (!xfs_inobt_issparse(irec.ir_holemask)) { @@ -405,10 +409,11 @@ STATIC void xchk_iallocbt_xref_rmap_inodes( struct xfs_scrub *sc, int which, - xfs_filblks_t inode_blocks) + unsigned long long inodes) { struct xfs_owner_info oinfo; xfs_filblks_t blocks; + xfs_filblks_t inode_blocks; int error; if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm)) @@ -420,6 +425,7 @@ xchk_iallocbt_xref_rmap_inodes( &blocks); if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur)) return; + inode_blocks = XFS_B_TO_FSB(sc->mp, inodes * sc->mp->m_sb.sb_inodesize); if (blocks != inode_blocks) xchk_btree_xref_set_corrupt(sc, sc->sa.rmap_cur, 0); } @@ -432,13 +438,14 @@ xchk_iallocbt( { struct xfs_btree_cur *cur; struct xfs_owner_info oinfo; - xfs_filblks_t inode_blocks = 0; + struct xchk_iallocbt iabt = { + .inodes = 0, + }; int error; xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INOBT); cur = which == XFS_BTNUM_INO ? sc->sa.ino_cur : sc->sa.fino_cur; - error = xchk_btree(sc, cur, xchk_iallocbt_rec, &oinfo, - &inode_blocks); + error = xchk_btree(sc, cur, xchk_iallocbt_rec, &oinfo, &iabt); if (error) return error; @@ -452,7 +459,7 @@ xchk_iallocbt( * to inode chunks with free inodes. */ if (which == XFS_BTNUM_INO) - xchk_iallocbt_xref_rmap_inodes(sc, which, inode_blocks); + xchk_iallocbt_xref_rmap_inodes(sc, which, iabt.inodes); return error; } From patchwork Tue Nov 6 04:08:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10669577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DF9514E2 for ; Tue, 6 Nov 2018 04:08:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFB7229FF5 for ; Tue, 6 Nov 2018 04:08:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E12C42A036; Tue, 6 Nov 2018 04:08:23 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 73C9A29FF5 for ; Tue, 6 Nov 2018 04:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729326AbeKFNbe (ORCPT ); Tue, 6 Nov 2018 08:31:34 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:40708 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbeKFNbe (ORCPT ); Tue, 6 Nov 2018 08:31:34 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA63x1oq023723 for ; Tue, 6 Nov 2018 04:08:21 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-2018-07-02; bh=LIApYYHbUfnC3ZYb2O37GjNnZzZrbk1fZrJo4m+YJik=; b=ZbDa6ZYzjfFafqYHy265SV74ydl9ywMW7o/Hbl/C3Tcw5OT4q99945Gt4ri3pK87WUhF RZ/+EY+ir6H7n4ffs5zblFpXFSCPaY4kGIMQMpWd00b1XQNXtfmn2Tyg4CGPqf0PEhFP uU7TN6QjMzMmHVx9fagC3ToN0e58oETTTDeBetLrYqvB3PmqAxas5HQfhJGLUGF0YxNt NEznLnWMkcZgYXIbn/ixchDZpHK9NF3HC+ooWM5u679Ok4+luh0pOqO41fR5vxTF8AIi 44r9ywGrTsrLkvJK+AkGFq4WQgwihcrvj4DOIFaIwxSg+Zoc0Xd/dL11WRKaqO0l7OyP 6g== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2nh33ttufb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 06 Nov 2018 04:08:21 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wA648K4r012424 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 6 Nov 2018 04:08:20 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wA648KbW010874 for ; Tue, 6 Nov 2018 04:08:20 GMT Received: from localhost (/10.159.235.241) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Nov 2018 20:08:19 -0800 Subject: [PATCH 2/8] xfs: calculate inode cluster geometry once during inobt scrub From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 05 Nov 2018 20:08:18 -0800 Message-ID: <154147729891.32496.12191035015614129432.stgit@magnolia> In-Reply-To: <154147728649.32496.4515247239602322709.stgit@magnolia> References: <154147728649.32496.4515247239602322709.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9068 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 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-1807170000 definitions=main-1811060032 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 Hoist all the inode cluster geometry information into struct xchk_iallocbt instead of recomputing them over and over. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/scrub/ialloc.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c index 76ae8338a42e..3c12a0fe3b38 100644 --- a/fs/xfs/scrub/ialloc.c +++ b/fs/xfs/scrub/ialloc.c @@ -45,8 +45,18 @@ xchk_setup_ag_iallocbt( /* Inode btree scrubber. */ struct xchk_iallocbt { + /* owner info for inode blocks */ + struct xfs_owner_info oinfo; + /* Number of inodes we see while scanning inobt. */ unsigned long long inodes; + + /* Blocks and inodes per inode cluster. */ + unsigned int blocks_per_cluster; + unsigned int inodes_per_cluster; + + /* Block alignment of inode clusters. */ + unsigned int cluster_align; }; /* @@ -189,32 +199,30 @@ xchk_iallocbt_check_cluster_freemask( STATIC int xchk_iallocbt_check_freemask( struct xchk_btree *bs, + struct xchk_iallocbt *iabt, struct xfs_inobt_rec_incore *irec) { - struct xfs_owner_info oinfo; struct xfs_imap imap; struct xfs_mount *mp = bs->cur->bc_mp; struct xfs_dinode *dip; struct xfs_buf *bp; xfs_ino_t fsino; - xfs_agino_t nr_inodes; + unsigned int nr_inodes; xfs_agino_t agino; xfs_agino_t chunkino; xfs_agino_t clusterino; xfs_agblock_t agbno; - int blks_per_cluster; uint16_t holemask; uint16_t ir_holemask; int error = 0; /* Make sure the freemask matches the inode records. */ - blks_per_cluster = xfs_icluster_size_fsb(mp); - nr_inodes = XFS_OFFBNO_TO_AGINO(mp, blks_per_cluster, 0); - xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INODES); + nr_inodes = min_t(unsigned int, iabt->inodes_per_cluster, + XFS_INODES_PER_CHUNK); for (agino = irec->ir_startino; agino < irec->ir_startino + XFS_INODES_PER_CHUNK; - agino += blks_per_cluster * mp->m_sb.sb_inopblock) { + agino += iabt->blocks_per_cluster * mp->m_sb.sb_inopblock) { fsino = XFS_AGINO_TO_INO(mp, bs->cur->bc_private.a.agno, agino); chunkino = agino - irec->ir_startino; agbno = XFS_AGINO_TO_AGBNO(mp, agino); @@ -235,17 +243,17 @@ xchk_iallocbt_check_freemask( /* If any part of this is a hole, skip it. */ if (ir_holemask) { xchk_xref_is_not_owned_by(bs->sc, agbno, - blks_per_cluster, &oinfo); + iabt->blocks_per_cluster, &iabt->oinfo); continue; } - xchk_xref_is_owned_by(bs->sc, agbno, blks_per_cluster, - &oinfo); + xchk_xref_is_owned_by(bs->sc, agbno, iabt->blocks_per_cluster, + &iabt->oinfo); /* Grab the inode cluster buffer. */ imap.im_blkno = XFS_AGB_TO_DADDR(mp, bs->cur->bc_private.a.agno, agbno); - imap.im_len = XFS_FSB_TO_BB(mp, blks_per_cluster); + imap.im_len = XFS_FSB_TO_BB(mp, iabt->blocks_per_cluster); imap.im_boffset = 0; error = xfs_imap_to_bp(mp, bs->cur->bc_tp, &imap, @@ -311,8 +319,8 @@ xchk_iallocbt_rec( /* Make sure this record is aligned to cluster and inoalignmnt size. */ agbno = XFS_AGINO_TO_AGBNO(mp, irec.ir_startino); - if ((agbno & (xfs_ialloc_cluster_alignment(mp) - 1)) || - (agbno & (xfs_icluster_size_fsb(mp) - 1))) + if ((agbno & (iabt->cluster_align - 1)) || + (agbno & (iabt->blocks_per_cluster - 1))) xchk_btree_set_corrupt(bs->sc, bs->cur, 0); iabt->inodes += irec.ir_count; @@ -353,7 +361,7 @@ xchk_iallocbt_rec( xchk_btree_set_corrupt(bs->sc, bs->cur, 0); check_freemask: - error = xchk_iallocbt_check_freemask(bs, &irec); + error = xchk_iallocbt_check_freemask(bs, iabt, &irec); if (error) goto out; @@ -440,9 +448,15 @@ xchk_iallocbt( struct xfs_owner_info oinfo; struct xchk_iallocbt iabt = { .inodes = 0, + .cluster_align = xfs_ialloc_cluster_alignment(sc->mp), + .blocks_per_cluster = xfs_icluster_size_fsb(sc->mp), }; int error; + xfs_rmap_ag_owner(&iabt.oinfo, XFS_RMAP_OWN_INODES); + iabt.inodes_per_cluster = XFS_OFFBNO_TO_AGINO(sc->mp, + iabt.blocks_per_cluster, 0); + xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_INOBT); cur = which == XFS_BTNUM_INO ? sc->sa.ino_cur : sc->sa.fino_cur; error = xchk_btree(sc, cur, xchk_iallocbt_rec, &oinfo, &iabt); From patchwork Tue Nov 6 04:08:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10669579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C9011751 for ; Tue, 6 Nov 2018 04:08:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 163352932E for ; Tue, 6 Nov 2018 04:08:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 075A129372; Tue, 6 Nov 2018 04:08:29 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 A1FE12932E for ; Tue, 6 Nov 2018 04:08:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729349AbeKFNbj (ORCPT ); Tue, 6 Nov 2018 08:31:39 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:60972 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbeKFNbj (ORCPT ); Tue, 6 Nov 2018 08:31:39 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA63xbsJ030585 for ; Tue, 6 Nov 2018 04:08:26 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-2018-07-02; bh=1mSfTEFJmWCErItWcsX86Bm+polbVI26j2CgAwvGPKY=; b=sWafgwhYGulf6zAUvm0IyOFiWvOiBKlOIbxLvyqwl6fsZhEfNsdxRDtrBtHtV+xMMDGL 1JyMKgnRjLrX4rx4yYGy0pvPn+HURupriRIfa2i+6zTHEbInsNtm4UtGDumukWE104/Y eN6Y6aEHOcQeVciUw2zDJl27xH+djr8vJUn0RNdnRbvYcHgUDRXCP+GxyAvCYIlNwSG+ svbFrzUsbqAPH3G57m5X51gtOs4wZCwC/Y9zSjKc6O6w6ysvq0YCI2p8NzbtxLCWzZBc Msx6Zp6h1xlDIdvGmveh8cQZFEcUlaMXhx4Gyw/85WMQ8Ule5KxgXSBJb1cz2VSXderG +g== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2nh3mpjt1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 06 Nov 2018 04:08:26 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wA648QPL032406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 6 Nov 2018 04:08:26 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 wA648QZs027072 for ; Tue, 6 Nov 2018 04:08:26 GMT Received: from localhost (/10.159.235.241) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Nov 2018 20:08:25 -0800 Subject: [PATCH 3/8] xfs: check the ir_startino alignment directly From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 05 Nov 2018 20:08:25 -0800 Message-ID: <154147730502.32496.4086322277755351139.stgit@magnolia> In-Reply-To: <154147728649.32496.4515247239602322709.stgit@magnolia> References: <154147728649.32496.4515247239602322709.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9068 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 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-1807170000 definitions=main-1811060032 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 In xchk_iallocbt_rec, check the alignment of ir_startino by converting the inode cluster block alignment into units of inodes instead of the other way around (converting ir_startino to blocks). This prevents us from tripping over off-by-one errors in ir_startino which are obscured by the inode -> block conversion. Signed-off-by: Darrick J. Wong --- fs/xfs/scrub/ialloc.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c index 3c12a0fe3b38..f498dfca3312 100644 --- a/fs/xfs/scrub/ialloc.c +++ b/fs/xfs/scrub/ialloc.c @@ -278,6 +278,29 @@ xchk_iallocbt_check_freemask( return error; } +/* Make sure this record is aligned to cluster and inoalignmnt size. */ +STATIC void +xchk_iallocbt_rec_alignment( + struct xchk_btree *bs, + struct xfs_inobt_rec_incore *irec) +{ + struct xfs_mount *mp = bs->cur->bc_mp; + struct xchk_iallocbt *iabt = bs->private; + xfs_agino_t imask; + + imask = XFS_OFFBNO_TO_AGINO(mp, iabt->cluster_align, 0) - 1; + if (irec->ir_startino & imask) { + xchk_btree_set_corrupt(bs->sc, bs->cur, 0); + return; + } + + imask = XFS_OFFBNO_TO_AGINO(mp, iabt->blocks_per_cluster, 0) - 1; + if (irec->ir_startino & imask) { + xchk_btree_set_corrupt(bs->sc, bs->cur, 0); + return; + } +} + /* Scrub an inobt/finobt record. */ STATIC int xchk_iallocbt_rec( @@ -290,7 +313,6 @@ xchk_iallocbt_rec( uint64_t holes; xfs_agnumber_t agno = bs->cur->bc_private.a.agno; xfs_agino_t agino; - xfs_agblock_t agbno; xfs_extlen_t len; int holecount; int i; @@ -317,11 +339,9 @@ xchk_iallocbt_rec( goto out; } - /* Make sure this record is aligned to cluster and inoalignmnt size. */ - agbno = XFS_AGINO_TO_AGBNO(mp, irec.ir_startino); - if ((agbno & (iabt->cluster_align - 1)) || - (agbno & (iabt->blocks_per_cluster - 1))) - xchk_btree_set_corrupt(bs->sc, bs->cur, 0); + xchk_iallocbt_rec_alignment(bs, &irec); + if (bs->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) + goto out; iabt->inodes += irec.ir_count; From patchwork Tue Nov 6 04:08:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10669581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D18CE1751 for ; Tue, 6 Nov 2018 04:08:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0A6D294FD for ; Tue, 6 Nov 2018 04:08:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B413C29546; Tue, 6 Nov 2018 04:08:38 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 59E52294FD for ; Tue, 6 Nov 2018 04:08:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729420AbeKFNbt (ORCPT ); Tue, 6 Nov 2018 08:31:49 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:40854 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbeKFNbt (ORCPT ); Tue, 6 Nov 2018 08:31:49 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA63x2Wp023753 for ; Tue, 6 Nov 2018 04:08:36 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-2018-07-02; bh=5FbwuVfovpMoJ0+6SNLiUo7WMTTUfWi7ghPa5a5bIA8=; b=MlEeAUcuKU0KC2a2uQpO8LDp6FMkCSZ8at6S0/tdmk9axO1J0B+PyfQ+WgBt811QYgQd y+PThzWA1J1w0uyJXzWiKzt0A9lNVEgVPC8NTN2TI+tCi1v4I5YUHbEOuHv5BNUEsOHy UdSDGKEBovGjw2oLFrdtjjQo+x+lfD7Z2libAYy1nNS5o7qI1TX+xF3H4KwzLZkJxREn pne4F6TuxCmPrlsVA29N9oEjLpfxPcmYv2lE95fU1cjBQXE6HBVDKiW3eH0C8YQNjTIf 3fUF4C7CE4h54a5cetHvwV5SDhJ7HoKm7fnSA/t7L76SBhtzahuUvAoGfT7HXbgLh/4O bw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2nh33ttufh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 06 Nov 2018 04:08:36 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wA648ZEG009543 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 6 Nov 2018 04:08:36 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wA648Z0d010919 for ; Tue, 6 Nov 2018 04:08:35 GMT Received: from localhost (/10.159.235.241) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Nov 2018 20:08:35 -0800 Subject: [PATCH 4/8] xfs: check inobt record alignment on big block filesystems From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 05 Nov 2018 20:08:31 -0800 Message-ID: <154147731114.32496.5929393143346043196.stgit@magnolia> In-Reply-To: <154147728649.32496.4515247239602322709.stgit@magnolia> References: <154147728649.32496.4515247239602322709.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9068 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 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-1807170000 definitions=main-1811060032 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 On a big block filesystem, there may be multiple inobt records covering a single inode cluster. These records obviously won't be aligned to cluster alignment rules, and they must cover the entire cluster. Teach scrub to check for these things. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/scrub/ialloc.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c index f498dfca3312..4fadea892440 100644 --- a/fs/xfs/scrub/ialloc.c +++ b/fs/xfs/scrub/ialloc.c @@ -57,6 +57,12 @@ struct xchk_iallocbt { /* Block alignment of inode clusters. */ unsigned int cluster_align; + + /* Expected next startino, for big block filesystems. */ + xfs_agino_t next_startino; + + /* Expected end of the current inode cluster. */ + xfs_agino_t next_cluster_ino; }; /* @@ -288,6 +294,27 @@ xchk_iallocbt_rec_alignment( struct xchk_iallocbt *iabt = bs->private; xfs_agino_t imask; + if (iabt->next_startino != NULLAGINO) { + /* + * We're midway through a cluster of inodes that is mapped by + * multiple inobt records. Did we get the record for the next + * irec in the sequence? + */ + if (irec->ir_startino != iabt->next_startino) { + xchk_btree_set_corrupt(bs->sc, bs->cur, 0); + return; + } + + iabt->next_startino += XFS_INODES_PER_CHUNK; + + /* Are we done with the cluster? */ + if (iabt->next_startino >= iabt->next_cluster_ino) { + iabt->next_startino = NULLAGINO; + iabt->next_cluster_ino = NULLAGINO; + } + return; + } + imask = XFS_OFFBNO_TO_AGINO(mp, iabt->cluster_align, 0) - 1; if (irec->ir_startino & imask) { xchk_btree_set_corrupt(bs->sc, bs->cur, 0); @@ -299,6 +326,17 @@ xchk_iallocbt_rec_alignment( xchk_btree_set_corrupt(bs->sc, bs->cur, 0); return; } + + if (iabt->inodes_per_cluster <= XFS_INODES_PER_CHUNK) + return; + + /* + * If this is the start of an inode cluster that can be mapped by + * multiple inobt records, the next inobt record must follow exactly + * after this one. + */ + iabt->next_startino = irec->ir_startino + XFS_INODES_PER_CHUNK; + iabt->next_cluster_ino = irec->ir_startino + iabt->inodes_per_cluster; } /* Scrub an inobt/finobt record. */ @@ -470,6 +508,8 @@ xchk_iallocbt( .inodes = 0, .cluster_align = xfs_ialloc_cluster_alignment(sc->mp), .blocks_per_cluster = xfs_icluster_size_fsb(sc->mp), + .next_startino = NULLAGINO, + .next_cluster_ino = NULLAGINO, }; int error; From patchwork Tue Nov 6 04:08:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10669583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C527D14E2 for ; Tue, 6 Nov 2018 04:08:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B37132953C for ; Tue, 6 Nov 2018 04:08:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7D2129550; Tue, 6 Nov 2018 04:08:45 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 31F332953C for ; Tue, 6 Nov 2018 04:08:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729512AbeKFNb4 (ORCPT ); Tue, 6 Nov 2018 08:31:56 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:32930 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbeKFNb4 (ORCPT ); Tue, 6 Nov 2018 08:31:56 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA640jw2031438 for ; Tue, 6 Nov 2018 04:08:43 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-2018-07-02; bh=GaLXL2EYICwtihiOd2tVyZZymfrjE89TMH/5f+f5vdM=; b=QQKcrVNECP+Q91aclkJmCyfZeF9DAT2f9rF10FJmDxm38hhsJ8qbkXy19X7wOP9/a4uB 5lFsv64K9rzLfRUfkiuHw0l1dgFMeZ2VQahX/oHbC3SEFhxgnXaN5knYCahG7s3LLkVx yy4P0fcq1rhssm2JuXc5nut3+4/kpIznXqE3AEdJffYqm8V79RTFLVhQIztEFK4mOMQX nX2ClVma/WhOVsVgWedhOZ24tFYzHhR+rxLih94nlPPvSQcMOAnilxYCdvoBAWecpy4X jLMysIWIMH3K2pafN/WcvT+cNE0aA6NIJDuHI9gYD+GzIzVravd3KJjsaH4+RnbawjzG mw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2nh3mpjt2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 06 Nov 2018 04:08:43 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wA648fig001815 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 6 Nov 2018 04:08:42 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wA648f9I018598 for ; Tue, 6 Nov 2018 04:08:41 GMT Received: from localhost (/10.159.235.241) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Nov 2018 20:08:41 -0800 Subject: [PATCH 5/8] xfs: hoist inode cluster checks out of loop From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 05 Nov 2018 20:08:40 -0800 Message-ID: <154147732071.32496.10360183009741260995.stgit@magnolia> In-Reply-To: <154147728649.32496.4515247239602322709.stgit@magnolia> References: <154147728649.32496.4515247239602322709.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9068 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 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-1807170000 definitions=main-1811060032 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 Hoist the inode cluster checks out of the inobt record check loop into a separate function in preparation for refactoring of that loop. No functional changes here; that's in the next patch. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/scrub/ialloc.c | 120 +++++++++++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 54 deletions(-) diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c index 4fadea892440..12158ed8ad29 100644 --- a/fs/xfs/scrub/ialloc.c +++ b/fs/xfs/scrub/ialloc.c @@ -201,12 +201,13 @@ xchk_iallocbt_check_cluster_freemask( return 0; } -/* Make sure the free mask is consistent with what the inodes think. */ +/* Check an inode cluster. */ STATIC int -xchk_iallocbt_check_freemask( +xchk_iallocbt_check_cluster( struct xchk_btree *bs, struct xchk_iallocbt *iabt, - struct xfs_inobt_rec_incore *irec) + struct xfs_inobt_rec_incore *irec, + xfs_agino_t agino) { struct xfs_imap imap; struct xfs_mount *mp = bs->cur->bc_mp; @@ -214,7 +215,6 @@ xchk_iallocbt_check_freemask( struct xfs_buf *bp; xfs_ino_t fsino; unsigned int nr_inodes; - xfs_agino_t agino; xfs_agino_t chunkino; xfs_agino_t clusterino; xfs_agblock_t agbno; @@ -226,59 +226,71 @@ xchk_iallocbt_check_freemask( nr_inodes = min_t(unsigned int, iabt->inodes_per_cluster, XFS_INODES_PER_CHUNK); - for (agino = irec->ir_startino; - agino < irec->ir_startino + XFS_INODES_PER_CHUNK; - agino += iabt->blocks_per_cluster * mp->m_sb.sb_inopblock) { - fsino = XFS_AGINO_TO_INO(mp, bs->cur->bc_private.a.agno, agino); - chunkino = agino - irec->ir_startino; - agbno = XFS_AGINO_TO_AGBNO(mp, agino); - - /* Compute the holemask mask for this cluster. */ - for (clusterino = 0, holemask = 0; clusterino < nr_inodes; - clusterino += XFS_INODES_PER_HOLEMASK_BIT) - holemask |= XFS_INOBT_MASK((chunkino + clusterino) / - XFS_INODES_PER_HOLEMASK_BIT); - - /* The whole cluster must be a hole or not a hole. */ - ir_holemask = (irec->ir_holemask & holemask); - if (ir_holemask != holemask && ir_holemask != 0) { - xchk_btree_set_corrupt(bs->sc, bs->cur, 0); - continue; - } + fsino = XFS_AGINO_TO_INO(mp, bs->cur->bc_private.a.agno, agino); + chunkino = agino - irec->ir_startino; + agbno = XFS_AGINO_TO_AGBNO(mp, agino); - /* If any part of this is a hole, skip it. */ - if (ir_holemask) { - xchk_xref_is_not_owned_by(bs->sc, agbno, - iabt->blocks_per_cluster, &iabt->oinfo); - continue; - } + /* Compute the holemask mask for this cluster. */ + for (clusterino = 0, holemask = 0; clusterino < nr_inodes; + clusterino += XFS_INODES_PER_HOLEMASK_BIT) + holemask |= XFS_INOBT_MASK((chunkino + clusterino) / + XFS_INODES_PER_HOLEMASK_BIT); - xchk_xref_is_owned_by(bs->sc, agbno, iabt->blocks_per_cluster, - &iabt->oinfo); - - /* Grab the inode cluster buffer. */ - imap.im_blkno = XFS_AGB_TO_DADDR(mp, bs->cur->bc_private.a.agno, - agbno); - imap.im_len = XFS_FSB_TO_BB(mp, iabt->blocks_per_cluster); - imap.im_boffset = 0; - - error = xfs_imap_to_bp(mp, bs->cur->bc_tp, &imap, - &dip, &bp, 0, 0); - if (!xchk_btree_xref_process_error(bs->sc, bs->cur, 0, - &error)) - continue; - - /* Which inodes are free? */ - for (clusterino = 0; clusterino < nr_inodes; clusterino++) { - error = xchk_iallocbt_check_cluster_freemask(bs, - fsino, chunkino, clusterino, irec, bp); - if (error) { - xfs_trans_brelse(bs->cur->bc_tp, bp); - return error; - } - } + /* The whole cluster must be a hole or not a hole. */ + ir_holemask = (irec->ir_holemask & holemask); + if (ir_holemask != holemask && ir_holemask != 0) { + xchk_btree_set_corrupt(bs->sc, bs->cur, 0); + return 0; + } + + /* If any part of this is a hole, skip it. */ + if (ir_holemask) { + xchk_xref_is_not_owned_by(bs->sc, agbno, + iabt->blocks_per_cluster, &iabt->oinfo); + return 0; + } + + xchk_xref_is_owned_by(bs->sc, agbno, iabt->blocks_per_cluster, + &iabt->oinfo); + + /* Grab the inode cluster buffer. */ + imap.im_blkno = XFS_AGB_TO_DADDR(mp, bs->cur->bc_private.a.agno, agbno); + imap.im_len = XFS_FSB_TO_BB(mp, iabt->blocks_per_cluster); + imap.im_boffset = 0; - xfs_trans_brelse(bs->cur->bc_tp, bp); + error = xfs_imap_to_bp(mp, bs->cur->bc_tp, &imap, &dip, &bp, 0, 0); + if (!xchk_btree_xref_process_error(bs->sc, bs->cur, 0, &error)) + return 0; + + /* Which inodes are free? */ + for (clusterino = 0; clusterino < nr_inodes; clusterino++) { + error = xchk_iallocbt_check_cluster_freemask(bs, fsino, + chunkino, clusterino, irec, bp); + if (error) + break; + } + + xfs_trans_brelse(bs->cur->bc_tp, bp); + return error; +} + +/* Make sure the free mask is consistent with what the inodes think. */ +STATIC int +xchk_iallocbt_check_freemask( + struct xchk_btree *bs, + struct xchk_iallocbt *iabt, + struct xfs_inobt_rec_incore *irec) +{ + struct xfs_mount *mp = bs->cur->bc_mp; + xfs_agino_t agino; + int error = 0; + + for (agino = irec->ir_startino; + agino < irec->ir_startino + XFS_INODES_PER_CHUNK; + agino += iabt->blocks_per_cluster * mp->m_sb.sb_inopblock) { + error = xchk_iallocbt_check_cluster(bs, iabt, irec, agino); + if (error) + break; } return error; From patchwork Tue Nov 6 04:08:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10669585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 351FD1751 for ; Tue, 6 Nov 2018 04:08:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22ED32953C for ; Tue, 6 Nov 2018 04:08:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1779829550; Tue, 6 Nov 2018 04:08:52 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 517752953C for ; Tue, 6 Nov 2018 04:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729608AbeKFNcC (ORCPT ); Tue, 6 Nov 2018 08:32:02 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:33014 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbeKFNcC (ORCPT ); Tue, 6 Nov 2018 08:32:02 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA63wuUX030162 for ; Tue, 6 Nov 2018 04:08:49 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-2018-07-02; bh=l1enHKkihly4M6Yk+DAImsArA4i0V7wSkHxTNY1AMUY=; b=CiNt1XJ5iAKkcE5WSwJp4RboL3j3aBRd0Am7ffEC3738dbwe1kQE/JsA+zgc3QGOFDt/ ohWmOP1iFzjlqcZI2gQ9YjejtY58DuaUKEe/huclX2QfgqwiXQf/eIOZJFdPNsIRVn9x THag5hC/j+EeNJFx2GOJiP3ld/aXLVwKXgj8hpVNYngtnaVsZ0JhtAeqprolkroKAcn7 mkhFQuAqYPd3SSifRgbRJtscAmoqX0lkm7zpuI5BktA68M3Tvv6H04OAmjKSTH+F1xgt yJx/fvNmuhtRA7ySc84Q6o9NPZZlaaPepleO7toGN9wrk6XIzmy9KTMG6aqy687Jn81k ow== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2nh3mpjt2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 06 Nov 2018 04:08:49 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wA648mAH001962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 6 Nov 2018 04:08:48 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wA648m5m011477 for ; Tue, 6 Nov 2018 04:08:48 GMT Received: from localhost (/10.159.235.241) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Nov 2018 20:08:47 -0800 Subject: [PATCH 6/8] xfs: clean up the inode cluster checking in the inobt scrub From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 05 Nov 2018 20:08:46 -0800 Message-ID: <154147732686.32496.17362148568991301258.stgit@magnolia> In-Reply-To: <154147728649.32496.4515247239602322709.stgit@magnolia> References: <154147728649.32496.4515247239602322709.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9068 signatures=668683 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-1807170000 definitions=main-1811060032 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 The code to check inobt records against inode clusters is a mess of poorly named variables and unnecessary parameters. Clean the unnecessary inode number parameters out of _check_cluster_freemask in favor of computing them inside the function instead of making the caller do it. In xchk_iallocbt_check_cluster, rename the variables to make it more obvious just what chunk_ino and cluster_ino represent. Signed-off-by: Darrick J. Wong --- fs/xfs/scrub/ialloc.c | 130 ++++++++++++++++++++++++++++++------------------- fs/xfs/scrub/trace.h | 45 +++++++++++++++++ 2 files changed, 125 insertions(+), 50 deletions(-) diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c index 12158ed8ad29..645b248faa80 100644 --- a/fs/xfs/scrub/ialloc.c +++ b/fs/xfs/scrub/ialloc.c @@ -147,41 +147,63 @@ xchk_iallocbt_freecount( return hweight64(freemask); } -/* Check a particular inode with ir_free. */ +/* + * Given the number of an inode within an inode cluster, check that the inode's + * allocation status matches ir_free in the inobt record. + * + * @chunk_ioff is the inode offset of the cluster within the @irec. + * @irec is the inobt record. + * @bp is the cluster buffer. + * @loop_ioff is the inode offset within the inode cluster. + */ STATIC int -xchk_iallocbt_check_cluster_freemask( +xchk_iallocbt_check_cluster_ifree( struct xchk_btree *bs, - xfs_ino_t fsino, - xfs_agino_t chunkino, - xfs_agino_t clusterino, struct xfs_inobt_rec_incore *irec, - struct xfs_buf *bp) + unsigned int chunk_ioff, + struct xfs_buf *bp, + unsigned int loop_ioff) { - struct xfs_dinode *dip; struct xfs_mount *mp = bs->cur->bc_mp; - bool inode_is_free = false; + struct xfs_dinode *dip; + xfs_ino_t fsino; + xfs_agino_t agino; + unsigned int offset; + bool irec_free; + bool ino_inuse; bool freemask_ok; - bool inuse; - int error = 0; + int error; if (xchk_should_terminate(bs->sc, &error)) return error; - dip = xfs_buf_offset(bp, clusterino * mp->m_sb.sb_inodesize); + /* + * Given an inobt record, an offset of a cluster within the record, + * and an offset of an inode within a cluster, compute which fs inode + * we're talking about and the offset of the inode record within the + * inode buffer. + */ + agino = irec->ir_startino + chunk_ioff + loop_ioff; + fsino = XFS_AGINO_TO_INO(mp, bs->cur->bc_private.a.agno, agino); + offset = loop_ioff * mp->m_sb.sb_inodesize; + if (offset >= BBTOB(bp->b_length)) { + xchk_btree_set_corrupt(bs->sc, bs->cur, 0); + goto out; + } + dip = xfs_buf_offset(bp, offset); + irec_free = (irec->ir_free & XFS_INOBT_MASK(chunk_ioff + loop_ioff)); + if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC || - (dip->di_version >= 3 && - be64_to_cpu(dip->di_ino) != fsino + clusterino)) { + (dip->di_version >= 3 && be64_to_cpu(dip->di_ino) != fsino)) { xchk_btree_set_corrupt(bs->sc, bs->cur, 0); goto out; } - if (irec->ir_free & XFS_INOBT_MASK(chunkino + clusterino)) - inode_is_free = true; - error = xfs_icache_inode_is_allocated(mp, bs->cur->bc_tp, - fsino + clusterino, &inuse); + error = xfs_icache_inode_is_allocated(mp, bs->cur->bc_tp, fsino, + &ino_inuse); if (error == -ENODATA) { /* Not cached, just read the disk buffer */ - freemask_ok = inode_is_free ^ !!(dip->di_mode); + freemask_ok = irec_free ^ !!(dip->di_mode); if (!bs->sc->try_harder && !freemask_ok) return -EDEADLOCK; } else if (error < 0) { @@ -193,7 +215,7 @@ xchk_iallocbt_check_cluster_freemask( goto out; } else { /* Inode is all there. */ - freemask_ok = inode_is_free ^ inuse; + freemask_ok = irec_free ^ ino_inuse; } if (!freemask_ok) xchk_btree_set_corrupt(bs->sc, bs->cur, 0); @@ -201,44 +223,57 @@ xchk_iallocbt_check_cluster_freemask( return 0; } -/* Check an inode cluster. */ +/* + * Check that the holemask and freemask of a hypothetical inode cluster match + * what's actually on disk. If sparse inodes are enabled, the cluster does + * not actually have to map to inodes if the corresponding holemask bit is set. + * + * @chunk_ioff is the inode offset of the cluster within the @irec. + */ STATIC int xchk_iallocbt_check_cluster( struct xchk_btree *bs, struct xchk_iallocbt *iabt, struct xfs_inobt_rec_incore *irec, - xfs_agino_t agino) + unsigned int chunk_ioff) { struct xfs_imap imap; struct xfs_mount *mp = bs->cur->bc_mp; struct xfs_dinode *dip; struct xfs_buf *bp; - xfs_ino_t fsino; unsigned int nr_inodes; - xfs_agino_t chunkino; - xfs_agino_t clusterino; + xfs_agnumber_t agno = bs->cur->bc_private.a.agno; xfs_agblock_t agbno; - uint16_t holemask; + unsigned int loop_ioff; + uint16_t cluster_mask = 0; uint16_t ir_holemask; int error = 0; - /* Make sure the freemask matches the inode records. */ nr_inodes = min_t(unsigned int, iabt->inodes_per_cluster, XFS_INODES_PER_CHUNK); - fsino = XFS_AGINO_TO_INO(mp, bs->cur->bc_private.a.agno, agino); - chunkino = agino - irec->ir_startino; - agbno = XFS_AGINO_TO_AGBNO(mp, agino); + /* Map this inode cluster */ + agbno = XFS_AGINO_TO_AGBNO(mp, irec->ir_startino + chunk_ioff); - /* Compute the holemask mask for this cluster. */ - for (clusterino = 0, holemask = 0; clusterino < nr_inodes; - clusterino += XFS_INODES_PER_HOLEMASK_BIT) - holemask |= XFS_INOBT_MASK((chunkino + clusterino) / + /* Compute a bitmask for this cluster that can be used for holemask. */ + for (loop_ioff = 0; + loop_ioff < nr_inodes; + loop_ioff += XFS_INODES_PER_HOLEMASK_BIT) + cluster_mask |= XFS_INOBT_MASK((chunk_ioff + loop_ioff) / XFS_INODES_PER_HOLEMASK_BIT); + ir_holemask = (irec->ir_holemask & cluster_mask); + imap.im_blkno = XFS_AGB_TO_DADDR(mp, agno, agbno); + imap.im_len = XFS_FSB_TO_BB(mp, iabt->blocks_per_cluster); + imap.im_boffset = 0; + + trace_xchk_iallocbt_check_cluster(mp, agno, irec->ir_startino, + imap.im_blkno, imap.im_len, chunk_ioff, nr_inodes, + cluster_mask, ir_holemask, + XFS_INO_TO_OFFSET(mp, irec->ir_startino + chunk_ioff)); + /* The whole cluster must be a hole or not a hole. */ - ir_holemask = (irec->ir_holemask & holemask); - if (ir_holemask != holemask && ir_holemask != 0) { + if (ir_holemask != cluster_mask && ir_holemask != 0) { xchk_btree_set_corrupt(bs->sc, bs->cur, 0); return 0; } @@ -254,18 +289,14 @@ xchk_iallocbt_check_cluster( &iabt->oinfo); /* Grab the inode cluster buffer. */ - imap.im_blkno = XFS_AGB_TO_DADDR(mp, bs->cur->bc_private.a.agno, agbno); - imap.im_len = XFS_FSB_TO_BB(mp, iabt->blocks_per_cluster); - imap.im_boffset = 0; - error = xfs_imap_to_bp(mp, bs->cur->bc_tp, &imap, &dip, &bp, 0, 0); if (!xchk_btree_xref_process_error(bs->sc, bs->cur, 0, &error)) - return 0; + return error; - /* Which inodes are free? */ - for (clusterino = 0; clusterino < nr_inodes; clusterino++) { - error = xchk_iallocbt_check_cluster_freemask(bs, fsino, - chunkino, clusterino, irec, bp); + /* Check free status of each inode within this cluster. */ + for (loop_ioff = 0; loop_ioff < nr_inodes; loop_ioff++) { + error = xchk_iallocbt_check_cluster_ifree(bs, irec, chunk_ioff, + bp, loop_ioff); if (error) break; } @@ -281,14 +312,13 @@ xchk_iallocbt_check_freemask( struct xchk_iallocbt *iabt, struct xfs_inobt_rec_incore *irec) { - struct xfs_mount *mp = bs->cur->bc_mp; - xfs_agino_t agino; + unsigned int chunk_ioff; int error = 0; - for (agino = irec->ir_startino; - agino < irec->ir_startino + XFS_INODES_PER_CHUNK; - agino += iabt->blocks_per_cluster * mp->m_sb.sb_inopblock) { - error = xchk_iallocbt_check_cluster(bs, iabt, irec, agino); + for (chunk_ioff = 0; + chunk_ioff < XFS_INODES_PER_CHUNK; + chunk_ioff += iabt->inodes_per_cluster) { + error = xchk_iallocbt_check_cluster(bs, iabt, irec, chunk_ioff); if (error) break; } diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 4e20f0e48232..f1c144c6dcc5 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -480,6 +480,51 @@ TRACE_EVENT(xchk_xref_error, __entry->ret_ip) ); +TRACE_EVENT(xchk_iallocbt_check_cluster, + TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, + xfs_agino_t startino, xfs_daddr_t map_daddr, + unsigned short map_len, unsigned int chunk_ino, + unsigned int nr_inodes, uint16_t cluster_mask, + uint16_t holemask, unsigned int cluster_ino), + TP_ARGS(mp, agno, startino, map_daddr, map_len, chunk_ino, nr_inodes, + cluster_mask, holemask, cluster_ino), + TP_STRUCT__entry( + __field(dev_t, dev) + __field(xfs_agnumber_t, agno) + __field(xfs_agino_t, startino) + __field(xfs_daddr_t, map_daddr) + __field(unsigned short, map_len) + __field(unsigned int, chunk_ino) + __field(unsigned int, nr_inodes) + __field(unsigned int, cluster_ino) + __field(uint16_t, cluster_mask) + __field(uint16_t, holemask) + ), + TP_fast_assign( + __entry->dev = mp->m_super->s_dev; + __entry->agno = agno; + __entry->startino = startino; + __entry->map_daddr = map_daddr; + __entry->map_len = map_len; + __entry->chunk_ino = chunk_ino; + __entry->nr_inodes = nr_inodes; + __entry->cluster_mask = cluster_mask; + __entry->holemask = holemask; + __entry->cluster_ino = cluster_ino; + ), + TP_printk("dev %d:%d agno %d startino %u daddr 0x%llx len %d chunkino %u nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino %u", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->agno, + __entry->startino, + __entry->map_daddr, + __entry->map_len, + __entry->chunk_ino, + __entry->nr_inodes, + __entry->cluster_mask, + __entry->holemask, + __entry->cluster_ino) +) + /* repair tracepoints */ #if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR) From patchwork Tue Nov 6 04:08:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10669587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8FD8214E2 for ; Tue, 6 Nov 2018 04:08:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D04C2A069 for ; Tue, 6 Nov 2018 04:08:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7163C2A06E; Tue, 6 Nov 2018 04:08:58 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 20C092A069 for ; Tue, 6 Nov 2018 04:08:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729628AbeKFNcJ (ORCPT ); Tue, 6 Nov 2018 08:32:09 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:39692 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbeKFNcJ (ORCPT ); Tue, 6 Nov 2018 08:32:09 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA6406RB173834 for ; Tue, 6 Nov 2018 04:08:56 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-2018-07-02; bh=s9I88Jr4q7az/tynorqXh20W+YuU6eSWYc0ZvydJJVc=; b=wPOQ60uHJ/ItBAEmXf7M6AD9AHfbgX2YWyQWIlpI20tuQYGbxavb/l+9FjE/0QO0BhW2 35uLOkFfo3osaStUKd5JA8MtHuB1MTa8WkwUUh5c1ncbRcfABKZPuHsdSiyC/N5SfzPD ieqYhMN812qPySFsAZ54GPLGNOXLVL9vQN7379mz2TrFL6EVh8TI/W1W8kpc6OF5iLEO UX7zavWvobiUJvLo+T/wZIR/KYKxxh9vblwd5yPVBFO/dPcwQlNuXmmPmduK/OLeyOLt RkO3i/z9Tug1YL4aavvU0GRLhC6y9BUAzkZ3r4LXvt6u6QZK2Vw4uD0fEKaR3O4ahcpx Mw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2nh4aqjpxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 06 Nov 2018 04:08:56 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wA648sAv014113 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 6 Nov 2018 04:08:55 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wA648s4q011004 for ; Tue, 6 Nov 2018 04:08:54 GMT Received: from localhost (/10.159.235.241) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Nov 2018 20:08:54 -0800 Subject: [PATCH 7/8] xfs: rename xchk_iallocbt_check_freemask From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 05 Nov 2018 20:08:53 -0800 Message-ID: <154147733302.32496.14353755611959314260.stgit@magnolia> In-Reply-To: <154147728649.32496.4515247239602322709.stgit@magnolia> References: <154147728649.32496.4515247239602322709.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9068 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 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-1807170000 definitions=main-1811060032 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 Change the name of xchk_iallocbt_check_freemask so that it represents what the function actually does. Signed-off-by: Darrick J. Wong --- fs/xfs/scrub/ialloc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c index 645b248faa80..10c3aaefc2a3 100644 --- a/fs/xfs/scrub/ialloc.c +++ b/fs/xfs/scrub/ialloc.c @@ -305,9 +305,13 @@ xchk_iallocbt_check_cluster( return error; } -/* Make sure the free mask is consistent with what the inodes think. */ +/* + * For all the inode clusters that could map to this inobt record, make sure + * that the holemask makes sense and that the allocation status of each inode + * matches the freemask. + */ STATIC int -xchk_iallocbt_check_freemask( +xchk_iallocbt_check_clusters( struct xchk_btree *bs, struct xchk_iallocbt *iabt, struct xfs_inobt_rec_incore *irec) @@ -315,6 +319,13 @@ xchk_iallocbt_check_freemask( unsigned int chunk_ioff; int error = 0; + /* + * For the common case where this inobt record maps to multiple inode + * clusters this will call _check_cluster for each cluster. + * + * For the case that multiple inobt records map to a single cluster, + * this will call _check_cluster once. + */ for (chunk_ioff = 0; chunk_ioff < XFS_INODES_PER_CHUNK; chunk_ioff += iabt->inodes_per_cluster) { @@ -461,7 +472,7 @@ xchk_iallocbt_rec( xchk_btree_set_corrupt(bs->sc, bs->cur, 0); check_freemask: - error = xchk_iallocbt_check_freemask(bs, iabt, &irec); + error = xchk_iallocbt_check_clusters(bs, iabt, &irec); if (error) goto out; From patchwork Tue Nov 6 04:08:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10669589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB69314E2 for ; Tue, 6 Nov 2018 04:09:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A13F2A069 for ; Tue, 6 Nov 2018 04:09:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E9C92A06E; Tue, 6 Nov 2018 04:09:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 3CE042A069 for ; Tue, 6 Nov 2018 04:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729640AbeKFNcW (ORCPT ); Tue, 6 Nov 2018 08:32:22 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:33326 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbeKFNcW (ORCPT ); Tue, 6 Nov 2018 08:32:22 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA6499lM037005 for ; Tue, 6 Nov 2018 04:09:09 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-2018-07-02; bh=HfNaZY0Mg4cLnxI4Fv5xznEJNIFNS+xX/zxcqcLtBu8=; b=0GRQ9okHecrAD7n/NlU7XlNlHIZCv0B4uGiEMJpjJLj0E+Qcw5oov4g8oxGYpMZhs9SD +CJyUPSicMxsOr4s50ChtZr/67l6jLBTXkhDbwMCi9LjJqDbRBb4JryJWdVXlGYcYZwa VGzA8335VAMamTgjHnV2YeKHDNzvzdNY/AUQVQfJ3wCqVKt4+CKBkLZTuJX2QV9bdN/9 RQMCnSZpU5FnSmU8109a917jpjNuizKq7QbCAd1fU2fwOr7jk6+DZagTliiV97fcJOL2 KzoIEiwIngzKjgFzY9h6vxtBCKYR3EjWqWLPV5aVLbXUHApmHA3lIdekTYt7UeARNZVh cA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2nh3mpjt39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 06 Nov 2018 04:09:09 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wA6495cB010414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 6 Nov 2018 04:09:05 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wA6495ii011115 for ; Tue, 6 Nov 2018 04:09:05 GMT Received: from localhost (/10.159.235.241) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Nov 2018 20:09:05 -0800 Subject: [PATCH 8/8] xfs: scrub big block inode btrees correctly From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 05 Nov 2018 20:08:59 -0800 Message-ID: <154147733964.32496.6293258964746388898.stgit@magnolia> In-Reply-To: <154147728649.32496.4515247239602322709.stgit@magnolia> References: <154147728649.32496.4515247239602322709.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9068 signatures=668683 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-1807170000 definitions=main-1811060034 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 Teach scrub how to handle the case that there are one or more inobt records covering a given inode cluster. This fixes the operation on big block filesystems (e.g. 64k blocks, 512 byte inodes). Signed-off-by: Darrick J. Wong --- fs/xfs/scrub/ialloc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c index 10c3aaefc2a3..5a5f8ae31803 100644 --- a/fs/xfs/scrub/ialloc.c +++ b/fs/xfs/scrub/ialloc.c @@ -169,6 +169,7 @@ xchk_iallocbt_check_cluster_ifree( xfs_ino_t fsino; xfs_agino_t agino; unsigned int offset; + unsigned int cluster_ioff; bool irec_free; bool ino_inuse; bool freemask_ok; @@ -181,11 +182,13 @@ xchk_iallocbt_check_cluster_ifree( * Given an inobt record, an offset of a cluster within the record, * and an offset of an inode within a cluster, compute which fs inode * we're talking about and the offset of the inode record within the - * inode buffer. + * inode buffer, being careful about inobt records that don't align + * with the start of the inode buffer when block sizes are large. */ agino = irec->ir_startino + chunk_ioff + loop_ioff; fsino = XFS_AGINO_TO_INO(mp, bs->cur->bc_private.a.agno, agino); - offset = loop_ioff * mp->m_sb.sb_inodesize; + cluster_ioff = XFS_INO_TO_OFFSET(mp, irec->ir_startino + chunk_ioff); + offset = (cluster_ioff + loop_ioff) * mp->m_sb.sb_inodesize; if (offset >= BBTOB(bp->b_length)) { xchk_btree_set_corrupt(bs->sc, bs->cur, 0); goto out;