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;