From patchwork Sun Jun 10 05:07:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 10456567 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 6E7DB601F7 for ; Sun, 10 Jun 2018 05:10:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F58820700 for ; Sun, 10 Jun 2018 05:10:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53E9525D99; Sun, 10 Jun 2018 05:10:28 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 E543120700 for ; Sun, 10 Jun 2018 05:10:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932195AbeFJFK1 (ORCPT ); Sun, 10 Jun 2018 01:10:27 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34030 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932183AbeFJFKX (ORCPT ); Sun, 10 Jun 2018 01:10:23 -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 w5A58d3U095700 for ; Sun, 10 Jun 2018 05:10:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=dLrFdsdVy5GomdR4czN0ro7DSvBp+grHGgPHKTPtiEY=; b=h3JwXx/0luFeOBVFtaYo+GAICfg5OuhP7cykAVOsc4UfNQEygNXhPqmFJHIbZeBWcP9E 0Luv8YmwJQ5mTRgz/izRGZEBRFMLM9PJGZg0CoXJEtKb5iftD8wX+3mIzUZ/gB6QqtRT rftkbRGQWFsiS/XyErcWkV4dy7bK1ecIgx6SzxnZb7KWYSE5kNdCbn2JPNp0pufUV+x8 l04z0mrG+VX39AuD0rPZ9DkTtYLmVe2zwxjjKMJMFzNVx46omlC+ZxJvCIlZ2+JqPc3U gpXGzyG+Ul/0z0YYnFMhvljw2BdTP7M/oQukl5HBq7XonCjyeX7FGXdo4c1g1st3ZrA/ ZQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2jg7hwstd5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 10 Jun 2018 05:10:22 +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 w5A5ALWQ006226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 10 Jun 2018 05:10:22 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5A5AL3E030497 for ; Sun, 10 Jun 2018 05:10:21 GMT Received: from localhost.localdomain (/72.210.40.165) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 Jun 2018 22:10:21 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v2 24/27] xfsprogs: Add parent pointers to recreated inodes Date: Sat, 9 Jun 2018 22:07:49 -0700 Message-Id: <1528607272-11122-25-git-send-email-allison.henderson@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528607272-11122-1-git-send-email-allison.henderson@oracle.com> References: <1528607272-11122-1-git-send-email-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8919 signatures=668702 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-1805220000 definitions=main-1806100059 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 Inodes that are not recovered from the orphanage will be recreated, so we will need to re-add the parent pointers here too. Signed-off-by: Allison Henderson --- libxfs/libxfs_api_defs.h | 1 + repair/phase6.c | 40 +++++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 78daca0..4b47479 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -152,5 +152,6 @@ #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 +#define xfs_parent_add libxfs_parent_add #endif /* __LIBXFS_API_DEFS_H__ */ diff --git a/repair/phase6.c b/repair/phase6.c index 4fedb35..96ffade 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -29,6 +29,7 @@ #include "dinode.h" #include "progress.h" #include "versions.h" +#include "xfs_parent.h" static struct cred zerocr; static struct fsxattr zerofsx; @@ -962,19 +963,20 @@ mk_root_dir(xfs_mount_t *mp) static xfs_ino_t mk_orphanage(xfs_mount_t *mp) { - xfs_ino_t ino; - xfs_trans_t *tp; - xfs_inode_t *ip; - xfs_inode_t *pip; - xfs_fsblock_t first; - ino_tree_node_t *irec; - int ino_offset = 0; - int i; - int error; + xfs_ino_t ino; + struct xfs_trans *tp; + struct xfs_inode *ip; + struct xfs_inode *pip; + xfs_fsblock_t first; + struct ino_tree_node *irec; + int ino_offset = 0; + int i; + int error; struct xfs_defer_ops dfops; - const int mode = 0755; - int nres; - struct xfs_name xname; + const int mode = 0755; + int nres; + struct xfs_name xname; + xfs_dir2_dataptr_t offset; /* * check for an existing lost+found first, if it exists, return @@ -1061,7 +1063,7 @@ mk_orphanage(xfs_mount_t *mp) * create the actual entry */ error = -libxfs_dir_createname(tp, pip, &xname, ip->i_ino, &first, - &dfops, nres, NULL); + &dfops, nres, &offset); if (error) do_error( _("can't make %s, createname error %d\n"), @@ -1083,6 +1085,18 @@ mk_orphanage(xfs_mount_t *mp) libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); libxfs_defer_ijoin(&dfops, ip); + + if (xfs_sb_version_hasparent(&mp->m_sb)) { + error = -libxfs_parent_add(pip, ip, &xname, offset, + &first, &dfops); + if (error) + do_error(_("Error creating parent pointer: %d\n"), + error); + libxfs_trans_log_inode(tp, pip, XFS_ILOG_CORE); + libxfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); + libxfs_defer_ijoin(&dfops, pip); + } + error = -libxfs_defer_finish(&tp, &dfops); if (error) { do_error(_("%s directory creation failed -- bmapf error %d\n"),