From patchwork Sun Jun 10 05:07:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 10456565 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 AF181601F7 for ; Sun, 10 Jun 2018 05:10:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CE3C20700 for ; Sun, 10 Jun 2018 05:10:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FEF625D99; Sun, 10 Jun 2018 05:10:27 +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 69EA820700 for ; Sun, 10 Jun 2018 05:10:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932158AbeFJFKZ (ORCPT ); Sun, 10 Jun 2018 01:10:25 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49360 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932163AbeFJFKY (ORCPT ); Sun, 10 Jun 2018 01:10:24 -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 w5A59wHP143264 for ; Sun, 10 Jun 2018 05:10:24 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=nzufktAIdnkwGsEvXomwhmhz9Xw4ikwVaDLcqCVNzuw=; b=VRhgcLV9xwD8uvFfNSx298F9KpBsyhuRJ0gu2LiWYnp4kOQzVE7tBDFx4ssN81amqaxj Z5EnIAnVpx7F9y5bY/xSlYvpHMlS/lq00B9g+quj+U1ECCJJbyt1M408sWlPDxAiczq0 P8U428VA82QTydFHOifpulbSQRE8NMSXo2k1NBRRiNf9mNo99nQAp7KUrQndBaipLfFK DZsSsD/pMbHmovtpbwji7oZazVbc2ITrHty9dnchaWuyfEl5U5n/lXf+c8tB/njSJKWE dWJHruoQyrUBC4bz3cAbEWE6LJMnZIEaIpe3wh4yiUmxIrO1+2E+ty4tp9hwG7wr0fSL 5Q== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2jgecx94pr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 10 Jun 2018 05:10:23 +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 w5A5AMcq006244 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sun, 10 Jun 2018 05:10:23 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 w5A5AMLZ030510 for ; Sun, 10 Jun 2018 05:10:22 GMT Received: from localhost.localdomain (/72.210.40.165) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 09 Jun 2018 22:10:22 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v2 25/27] xfsprogs: Add parent pointers during protofile creation Date: Sat, 9 Jun 2018 22:07:50 -0700 Message-Id: <1528607272-11122-26-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=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=992 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 created from protofile parsing will also need to add the appropriate parent pointers Signed-off-by: Allison Henderson --- mkfs/proto.c | 55 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/mkfs/proto.c b/mkfs/proto.c index 67c228a..222479f 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -19,6 +19,7 @@ #include "libxfs.h" #include #include "xfs_multidisk.h" +#include "xfs_parent.h" /* * Prototypes for internal functions. @@ -318,23 +319,25 @@ newregfile( static void newdirent( - xfs_mount_t *mp, - xfs_trans_t *tp, - xfs_inode_t *pip, - struct xfs_name *name, - xfs_ino_t inum, - xfs_fsblock_t *first, - struct xfs_defer_ops *dfops) + struct xfs_mount *mp, + struct xfs_trans *tp, + struct xfs_inode *pip, + struct xfs_name *name, + struct xfs_inode *ip, + xfs_fsblock_t *first, + struct xfs_defer_ops *dfops, + xfs_dir2_dataptr_t *offset) { - int error; - int rsv; + int error; + int rsv; rsv = XFS_DIRENTER_SPACE_RES(mp, name->len); - error = -libxfs_dir_createname(tp, pip, name, inum, first, dfops, rsv, - NULL); + error = -libxfs_dir_createname(tp, pip, name, ip->i_ino, first, dfops, rsv, + offset); if (error) fail(_("directory createname error"), error); + } static void @@ -387,6 +390,7 @@ parseproto( cred_t creds; char *value; struct xfs_name xname; + xfs_dir2_dataptr_t offset; memset(&creds, 0, sizeof(creds)); mstr = getstr(pp); @@ -470,7 +474,7 @@ parseproto( free(buf); libxfs_trans_ijoin(tp, pip, 0); xname.type = XFS_DIR3_FT_REG_FILE; - newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &dfops); + newdirent(mp, tp, pip, &xname, ip, &first, &dfops, &offset); break; case IF_RESERVED: /* pre-allocated space only */ @@ -493,7 +497,7 @@ parseproto( libxfs_trans_ijoin(tp, pip, 0); xname.type = XFS_DIR3_FT_REG_FILE; - newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &dfops); + newdirent(mp, tp, pip, &xname, ip, &first, &dfops, &offset); libxfs_trans_log_inode(tp, ip, flags); libxfs_defer_ijoin(&dfops, ip); @@ -516,7 +520,7 @@ parseproto( } libxfs_trans_ijoin(tp, pip, 0); xname.type = XFS_DIR3_FT_BLKDEV; - newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &dfops); + newdirent(mp, tp, pip, &xname, ip, &first, &dfops, &offset); flags |= XFS_ILOG_DEV; break; @@ -530,7 +534,7 @@ parseproto( fail(_("Inode allocation failed"), error); libxfs_trans_ijoin(tp, pip, 0); xname.type = XFS_DIR3_FT_CHRDEV; - newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &dfops); + newdirent(mp, tp, pip, &xname, ip, &first, &dfops, &offset); flags |= XFS_ILOG_DEV; break; @@ -542,7 +546,7 @@ parseproto( fail(_("Inode allocation failed"), error); libxfs_trans_ijoin(tp, pip, 0); xname.type = XFS_DIR3_FT_FIFO; - newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &dfops); + newdirent(mp, tp, pip, &xname, ip, &first, &dfops, &offset); break; case IF_SYMLINK: buf = getstr(pp); @@ -555,7 +559,7 @@ parseproto( flags |= newfile(tp, ip, &dfops, &first, 1, 1, buf, len); libxfs_trans_ijoin(tp, pip, 0); xname.type = XFS_DIR3_FT_SYMLINK; - newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &dfops); + newdirent(mp, tp, pip, &xname, ip, &first, &dfops, &offset); break; case IF_DIRECTORY: tp = getres(mp, 0); @@ -572,8 +576,8 @@ parseproto( } else { libxfs_trans_ijoin(tp, pip, 0); xname.type = XFS_DIR3_FT_DIR; - newdirent(mp, tp, pip, &xname, ip->i_ino, - &first, &dfops); + newdirent(mp, tp, pip, &xname, ip, + &first, &dfops, &offset); inc_nlink(VFS_I(pip)); libxfs_trans_log_inode(tp, pip, XFS_ILOG_CORE); } @@ -612,6 +616,19 @@ parseproto( fail(_("Error encountered creating file from prototype file"), error); } + + if (xfs_sb_version_hasparent(&mp->m_sb)) { + error = xfs_parent_add(pip, ip, &xname, offset, &first, &dfops); + if (error) + fail(_("Error creating parent pointer"), error); + + libxfs_trans_log_inode(tp, ip, flags); + libxfs_defer_ijoin(&dfops, ip); + error = -libxfs_defer_finish(&tp, &dfops); + if (error) + fail(_("Directory creation failed"), error); + } + libxfs_trans_commit(tp); IRELE(ip); }