From patchwork Tue Aug 28 19:22:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 10579009 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 5C2311805 for ; Tue, 28 Aug 2018 19:25:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D2612A519 for ; Tue, 28 Aug 2018 19:25:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 415EB2AB06; Tue, 28 Aug 2018 19:25:03 +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 D34BE2A9C5 for ; Tue, 28 Aug 2018 19:25:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727130AbeH1XSG (ORCPT ); Tue, 28 Aug 2018 19:18:06 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59978 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbeH1XSG (ORCPT ); Tue, 28 Aug 2018 19:18:06 -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 w7SJJSmj081073 for ; Tue, 28 Aug 2018 19:25:01 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-2018-07-02; bh=qmNIcpwonXHiFavMwLVxkQihvEuCQ6yPchkhaYVgoVI=; b=c2+jH2l4FpYevMYajoeRDWc81AGAKSkgnLA5z8bKbZFu8bPhxySOu+gH/5gnkU2ttAOv WgC0QxjZFScTBwPR2lTOj4N0/xRi04kp8sWnY4KySmuQuYGm23bQiL0mPmEOsaZ1YYHh Qm2I7Zr4EcwMBl+f+YphqvuxLuaXQRVGlC29R8D+INwKiIGeXz/diCyt6u3sfQwHSCxS SfY32yojaqd0VTwkkn9WJJx5QiTvSQjQ00SMrojYtkyG2CGd/bz6qLRsYzj/GkRn3aHx pNcMoXtA9mNcBkO3jgteOmMuLF/T6K64S9BcAglCAj+DGuFTxkZC9NsQ4xsRewynTH3c ZQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2m2yrq5tj4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 28 Aug 2018 19:25:00 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7SJOxqn019006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 28 Aug 2018 19:25:00 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 w7SJOxm5014927 for ; Tue, 28 Aug 2018 19:24:59 GMT Received: from localhost.localdomain (/70.176.225.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 28 Aug 2018 12:24:59 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v8 21/28] xfs: add parent attributes to link Date: Tue, 28 Aug 2018 12:22:34 -0700 Message-Id: <1535484161-11059-22-git-send-email-allison.henderson@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535484161-11059-1-git-send-email-allison.henderson@oracle.com> References: <1535484161-11059-1-git-send-email-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8999 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=748 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808280187 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: Dave Chinner This patch modifies xfs_link to add a parent pointer to the inode. xfs_link will also need to create an attribute fork if the inode does not already have one. [bfoster: rebase, use VFS inode fields, fix xfs_bmap_finish() usage] [achender: rebased, changed __unint32_t to xfs_dir2_dataptr_t, fixed null pointer bugs] Signed-off-by: Dave Chinner Signed-off-by: Allison Henderson --- fs/xfs/xfs_inode.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 3f722e6..4a32eb1 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1409,6 +1409,7 @@ xfs_link( xfs_trans_t *tp; int error; int resblks; + xfs_dir2_dataptr_t diroffset; trace_xfs_link(tdp, target_name); @@ -1436,8 +1437,8 @@ xfs_link( xfs_lock_two_inodes(sip, XFS_ILOCK_EXCL, tdp, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, sip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, tdp, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, sip, 0); + xfs_trans_ijoin(tp, tdp, 0); /* * If we are using project inheritance, we only allow hard link @@ -1466,15 +1467,28 @@ xfs_link( } error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino, - resblks, NULL); + resblks, &diroffset); if (error) - goto error_return; + goto out_defer_cancel; xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_log_inode(tp, tdp, XFS_ILOG_CORE); error = xfs_bumplink(tp, sip); if (error) - goto error_return; + goto out_defer_cancel; + + /* + * If we have parent pointers, we now need to add the parent record to + * the attribute fork of the inode. If this is the initial parent + * attribute, we need to create it correctly, otherwise we can just add + * the parent to the inode. + */ + if (xfs_sb_version_hasparent(&mp->m_sb)) { + error = xfs_parent_add_deferred(tdp, tp, sip, target_name, + diroffset); + if (error) + goto out_defer_cancel; + } /* * If this is a synchronous mount, make sure that the @@ -1484,11 +1498,18 @@ xfs_link( if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) xfs_trans_set_sync(tp); - return xfs_trans_commit(tp); + error = xfs_trans_commit(tp); + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); + return error; - error_return: +out_defer_cancel: + xfs_defer_cancel(tp); +error_return: xfs_trans_cancel(tp); - std_return: + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); +std_return: return error; }