From patchwork Tue Mar 20 03:08:26 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: 10296159 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 EC039602BD for ; Tue, 20 Mar 2018 03:08:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBCC9290E0 for ; Tue, 20 Mar 2018 03:08:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D067C290F9; Tue, 20 Mar 2018 03:08:32 +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 5C887290E0 for ; Tue, 20 Mar 2018 03:08:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751093AbeCTDIb (ORCPT ); Mon, 19 Mar 2018 23:08:31 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:58742 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbeCTDIa (ORCPT ); Mon, 19 Mar 2018 23:08:30 -0400 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 w2K2qNgd196531; Tue, 20 Mar 2018 03:08:28 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=ylWZgjB3c1ep+K4VFxqWlTKqM34zAzPxKi7XhRkDwYA=; b=j6rD0/Cut5GMOtFWyTMcIN7B9Hh5d2U16dKW5EzMNxLm8Kx102Y74M2rmBv5AhdRsbSJ c5fHxlq1TGKUNWQLtCPeJjpjKhC94vVW+kTjeDwF4o+OzjZXoH2vrSTYMWiJ1S8FaPNy H3X9TjDZpRza1ZXbx7IVfh4++23nt0+ct5AayrH91dcWhfc1eFh0QeTyoIQPJ99xID8s I7pn+I2Ghb7jEiFuYDw+lTdvqGXerfXmDiOYQYcV64d3wgPMAx7OLNdzk22a+/40N2K8 j2aH2PZrmjzluobPRItuCWj0H/E6v+zig6wb3dscVdnsImBtWv7Q5ZjMtUL1GYqqg8RB FA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2gtsw4r0y0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Mar 2018 03:08:28 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2K38RqY025364 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Mar 2018 03:08:27 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2K38RFA031744; Tue, 20 Mar 2018 03:08:27 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 19 Mar 2018 20:08:26 -0700 Subject: [PATCH 1/4] xfs_repair: implement custom ifork verifiers From: "Darrick J. Wong" To: sandeen@redhat.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 19 Mar 2018 20:08:26 -0700 Message-ID: <152151530602.18312.5227395146899805650.stgit@magnolia> In-Reply-To: <152151529988.18312.2660325658864402943.stgit@magnolia> References: <152151529988.18312.2660325658864402943.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8837 signatures=668693 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=776 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803200006 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 --- libxfs/libxfs_api_defs.h | 2 + repair/phase6.c | 66 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 67 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..e9189af 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -39,6 +39,70 @@ 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. The ifork verifiers would normally fail that, but we'll + * accept this canary so that we can fix 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; + + /* Don't let the NULLFSINO .. entry blow everything up. */ + 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 xfs_failaddr_t +phase6_verify_attr( + struct xfs_inode *ip) +{ + return libxfs_default_ifork_ops.verify_attr(ip); +} + +static xfs_failaddr_t +phase6_verify_symlink( + struct xfs_inode *ip) +{ + return libxfs_default_ifork_ops.verify_symlink(ip); +} + +struct xfs_ifork_ops phase6_default_ifork_ops = { + .verify_attr = phase6_verify_attr, + .verify_dir = phase6_verify_dir, + .verify_symlink = phase6_verify_symlink, +}; + +/* * Data structures used to keep track of directories where the ".." * entries are updated. These must be rebuilt after the initial pass */ @@ -2833,7 +2897,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_default_ifork_ops); if (error) { if (!no_modify) do_error(