From patchwork Tue Mar 20 21:47:13 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: 10298009 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 1C488602C2 for ; Tue, 20 Mar 2018 21:47:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A30228D2C for ; Tue, 20 Mar 2018 21:47:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F248E28DDA; Tue, 20 Mar 2018 21:47:57 +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 73D6528D2C for ; Tue, 20 Mar 2018 21:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751502AbeCTVr4 (ORCPT ); Tue, 20 Mar 2018 17:47:56 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:60118 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751456AbeCTVrz (ORCPT ); Tue, 20 Mar 2018 17:47:55 -0400 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 w2KLhbiA023483; Tue, 20 Mar 2018 21:47:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=Dd6krH2PsdW4w3dEA175GB1/LRdgciYgRhrgBQevud8=; b=Wi4jbaV2UDa+/7fHPEErPaRqJEtsfuqoKImw2CZBgxC6Rf5EIv9k8RacVn3W8BMNxEbA Noct3jA0EICJ87D3REKGxIc4xwTm6ck6FwPiBQg2P7kFR9N+XhmgqmR2Yg3ACgbnMA9E G5aq2Xm0poaJduoSPe0TiU/tVBnb96Fd/9svH0atRaROeYAFIjcBakj9aO5lo5J5KBh8 mhqX3GqoBS8A5TcTl2Hc/ldFeKSOvEPSVyRdKmB7K7s6oR64vY/lbSnD3Sz/FALZx4Hj XEbuAU8M47PBAxaJke1TEWF1DPViijCOwevBCqn2a1LTuK9Y75NSJqFjxl+pYYgU+XUx Pg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2guafer0e5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Mar 2018 21:47:53 +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 w2KLlE8m021200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Mar 2018 21:47:14 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 w2KLlE5F018254; Tue, 20 Mar 2018 21:47:14 GMT Received: from localhost (/10.159.242.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Mar 2018 14:47:13 -0700 Date: Tue, 20 Mar 2018 14:47:13 -0700 From: "Darrick J. Wong" To: sandeen@redhat.com Cc: linux-xfs@vger.kernel.org Subject: [PATCH v2 1/4] xfs_repair: implement custom ifork verifiers Message-ID: <20180320214712.GK1757@magnolia> References: <152151529988.18312.2660325658864402943.stgit@magnolia> <152151530602.18312.5227395146899805650.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <152151530602.18312.5227395146899805650.stgit@magnolia> User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8838 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=779 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803200127 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 There are a few cases where an early stage of xfs_repair will write an invalid inode fork buffer to signal to a later stage that it needs to correct the value. This happens in phase 4 when we detect an inline format directory with an invalid .. pointer. To avoid triggering the ifork verifiers on this, inject a custom verifier for phase 6 that lets this pass for now. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- v2: fix misleading comments, remove pointless wrappers --- libxfs/libxfs_api_defs.h | 2 ++ repair/phase6.c | 57 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) -- 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/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 5d56340..78daca0 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -150,5 +150,7 @@ #define xfs_rmap_lookup_le_range libxfs_rmap_lookup_le_range #define xfs_refc_block libxfs_refc_block #define xfs_rmap_compare libxfs_rmap_compare +#define xfs_dir_get_ops libxfs_dir_get_ops +#define xfs_default_ifork_ops libxfs_default_ifork_ops #endif /* __LIBXFS_API_DEFS_H__ */ diff --git a/repair/phase6.c b/repair/phase6.c index aff83bc..ed005e8 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -39,6 +39,61 @@ static struct xfs_name xfs_name_dot = {(unsigned char *)".", XFS_DIR3_FT_DIR}; /* + * When we're checking directory inodes, we're allowed to set a directory's + * dotdot entry to zero to signal that the parent needs to be reconnected + * during phase 6. If we're handling a shortform directory the ifork + * verifiers will fail, so temporarily patch out this canary so that we can + * verify the rest of the fork and move on to fixing the dir. + */ +static xfs_failaddr_t +phase6_verify_dir( + struct xfs_inode *ip) +{ + struct xfs_mount *mp = ip->i_mount; + const struct xfs_dir_ops *dops; + struct xfs_ifork *ifp; + struct xfs_dir2_sf_hdr *sfp; + xfs_failaddr_t fa; + xfs_ino_t old_parent; + bool parent_bypass = false; + int size; + + dops = libxfs_dir_get_ops(mp, NULL); + + ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); + sfp = (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data; + size = ifp->if_bytes; + + /* + * If this is a shortform directory, phase4 may have set the parent + * inode to zero to indicate that it must be fixed. Temporarily + * set a valid parent so that the directory verifier will pass. + */ + if (size > offsetof(struct xfs_dir2_sf_hdr, parent) && + size >= xfs_dir2_sf_hdr_size(sfp->i8count)) { + old_parent = dops->sf_get_parent_ino(sfp); + if (old_parent == 0) { + dops->sf_put_parent_ino(sfp, mp->m_sb.sb_rootino); + parent_bypass = true; + } + } + + fa = libxfs_default_ifork_ops.verify_dir(ip); + + /* Put it back. */ + if (parent_bypass) + dops->sf_put_parent_ino(sfp, old_parent); + + return fa; +} + +static struct xfs_ifork_ops phase6_ifork_ops = { + .verify_attr = xfs_attr_shortform_verify, + .verify_dir = phase6_verify_dir, + .verify_symlink = xfs_symlink_shortform_verify, +}; + +/* * Data structures used to keep track of directories where the ".." * entries are updated. These must be rebuilt after the initial pass */ @@ -2833,7 +2888,7 @@ process_dir_inode( ASSERT(!is_inode_refchecked(irec, ino_offset) || dotdot_update); - error = -libxfs_iget(mp, NULL, ino, 0, &ip, NULL); + error = -libxfs_iget(mp, NULL, ino, 0, &ip, &phase6_ifork_ops); if (error) { if (!no_modify) do_error(