All of lore.kernel.org
 help / color / mirror / Atom feed
From: Allison Henderson <allison.henderson@oracle.com>
To: linux-xfs@vger.kernel.org
Cc: Allison Henderson <allison.henderson@oracle.com>
Subject: [PATCH 16/17] Add parent pointers to rename
Date: Wed, 18 Oct 2017 15:55:32 -0700	[thread overview]
Message-ID: <1508367333-3237-17-git-send-email-allison.henderson@oracle.com> (raw)
In-Reply-To: <1508367333-3237-1-git-send-email-allison.henderson@oracle.com>

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
---
 fs/xfs/libxfs/xfs_dir2.c |  6 ++++--
 fs/xfs/xfs_inode.c       | 26 ++++++++++++++++++++------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 486f808..35667fd 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -324,10 +324,11 @@ xfs_dir_createname(
 	else
 		rval = xfs_dir2_node_addname(args);
 
+out_free:
 	/* return the location that this entry was place in the parent inode */
 	if (offset)
 		*offset = args->offset;
-out_free:
+
 	kmem_free(args);
 	return rval;
 }
@@ -496,9 +497,10 @@ xfs_dir_removename(
 		rval = xfs_dir2_leaf_removename(args);
 	else
 		rval = xfs_dir2_node_removename(args);
+out_free:
 	if (offset)
 		*offset = args->offset;
-out_free:
+
 	kmem_free(args);
 	return rval;
 }
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index a360c3d..98bd7c2 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2989,6 +2989,8 @@ xfs_rename(
 	bool			src_is_directory = S_ISDIR(VFS_I(src_ip)->i_mode);
 	int			spaceres;
 	int			error;
+	xfs_dir2_dataptr_t	new_diroffset;
+	xfs_dir2_dataptr_t	old_diroffset;
 
 	trace_xfs_rename(src_dp, target_dp, src_name, target_name);
 
@@ -3091,13 +3093,12 @@ xfs_rename(
 		 */
 		error = xfs_dir_createname(tp, target_dp, target_name,
 					   src_ip->i_ino, &first_block, &dfops,
-					   spaceres, NULL);
+					   spaceres, &new_diroffset);
 		if (error)
 			goto out_bmap_cancel;
 
 		xfs_trans_ichgtime(tp, target_dp,
 					XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
-
 		if (new_parent && src_is_directory) {
 			error = xfs_bumplink(tp, target_dp);
 			if (error)
@@ -3131,7 +3132,7 @@ xfs_rename(
 		 */
 		error = xfs_dir_replace(tp, target_dp, target_name,
 					src_ip->i_ino, &first_block, &dfops,
-					spaceres, NULL);
+					spaceres, &new_diroffset);
 		if (error)
 			goto out_bmap_cancel;
 
@@ -3166,7 +3167,7 @@ xfs_rename(
 		 */
 		error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot,
 					target_dp->i_ino, &first_block, &dfops,
-					spaceres, NULL);
+					spaceres, &new_diroffset);
 		ASSERT(error != -EEXIST);
 		if (error)
 			goto out_bmap_cancel;
@@ -3205,11 +3206,12 @@ xfs_rename(
 	 */
 	if (wip) {
 		error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino,
-					&first_block, &dfops, spaceres, NULL);
+					&first_block, &dfops, spaceres,
+					&old_diroffset);
 	} else
 		error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
 					   &first_block, &dfops, spaceres,
-					   NULL);
+					   &old_diroffset);
 	if (error)
 		goto out_bmap_cancel;
 
@@ -3239,6 +3241,18 @@ xfs_rename(
 		VFS_I(wip)->i_state &= ~I_LINKABLE;
 	}
 
+	if (new_parent && xfs_sb_version_hasparent(&mp->m_sb)) {
+		error = xfs_parent_add(tp, target_dp, src_ip, target_name,
+				       new_diroffset, &dfops, &first_block);
+		if (error)
+			goto out_bmap_cancel;
+
+		error = xfs_parent_remove(tp, src_dp, src_ip,
+					  old_diroffset, &dfops, &first_block);
+		if (error)
+			goto out_bmap_cancel;
+	}
+
 	xfs_trans_ichgtime(tp, src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
 	xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE);
 	if (new_parent)
-- 
2.7.4


  parent reply	other threads:[~2017-10-18 23:00 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18 22:55 [PATCH 00/17] Parent Pointers V3 Allison Henderson
2017-10-18 22:55 ` [PATCH 01/17] Add helper functions xfs_attr_set_args and xfs_attr_remove_args Allison Henderson
2017-10-19 20:03   ` Darrick J. Wong
2017-10-21  1:14     ` Allison Henderson
2017-10-18 22:55 ` [PATCH 02/17] Set up infastructure for deferred attribute operations Allison Henderson
2017-10-19 19:02   ` Darrick J. Wong
2017-10-21  1:08     ` Allison Henderson
2017-10-18 22:55 ` [PATCH 03/17] Add xfs_attr_set_defered and xfs_attr_remove_defered Allison Henderson
2017-10-19 19:13   ` Darrick J. Wong
2017-10-21  1:08     ` Allison Henderson
2017-10-18 22:55 ` [PATCH 04/17] Remove all strlen calls in all xfs_attr_* functions for attr names Allison Henderson
2017-10-19 19:15   ` Darrick J. Wong
2017-10-21  1:10     ` Allison Henderson
2017-10-18 22:55 ` [PATCH 05/17] xfs: get directory offset when adding directory name Allison Henderson
2017-10-18 22:55 ` [PATCH 06/17] xfs: get directory offset when removing " Allison Henderson
2017-10-19 19:17   ` Darrick J. Wong
2017-10-21  1:11     ` Allison Henderson
2017-10-18 22:55 ` [PATCH 07/17] xfs: get directory offset when replacing a " Allison Henderson
2017-10-18 22:55 ` [PATCH 08/17] xfs: add parent pointer support to attribute code Allison Henderson
2017-10-18 22:55 ` [PATCH 09/17] xfs: define parent pointer xattr format Allison Henderson
2017-10-18 22:55 ` [PATCH 10/17] :xfs: extent transaction reservations for parent attributes Allison Henderson
2017-10-19 18:24   ` Darrick J. Wong
     [not found]     ` <8680e0c1-ada8-06e3-e397-61a5076030be@oracle.com>
2017-10-20 23:45       ` Darrick J. Wong
2017-10-21  0:12         ` Allison Henderson
2017-10-21  1:07     ` Allison Henderson
2017-10-18 22:55 ` [PATCH 11/17] Add the extra space requirements for parent pointer attributes when calculating the minimum log size during mkfs Allison Henderson
2017-10-19 18:13   ` Darrick J. Wong
2017-10-21  1:07     ` Allison Henderson
2017-10-18 22:55 ` [PATCH 12/17] xfs: parent pointer attribute creation Allison Henderson
2017-10-19 19:36   ` Darrick J. Wong
     [not found]     ` <9185d3e8-4b41-b2d8-294b-934f7d3409f0@oracle.com>
2017-10-21  0:03       ` Darrick J. Wong
2017-10-21  1:11     ` Allison Henderson
2017-10-18 22:55 ` [PATCH 13/17] xfs: add parent attributes to link Allison Henderson
2017-10-19 19:40   ` Darrick J. Wong
2017-10-21  1:12     ` Allison Henderson
2017-10-18 22:55 ` [PATCH 14/17] xfs: remove parent pointers in unlink Allison Henderson
2017-10-19 19:43   ` Darrick J. Wong
2017-10-21  1:12     ` Allison Henderson
2017-10-18 22:55 ` [PATCH 15/17] xfs_bmap_add_attrfork(): re-add error handling from set_attrforkoff() call Allison Henderson
2017-10-19 19:43   ` Darrick J. Wong
2017-10-21  1:13     ` Allison Henderson
2017-10-18 22:55 ` Allison Henderson [this message]
2017-10-18 22:55 ` [PATCH 17/17] Add the parent pointer support to the superblock version 5 Allison Henderson
2017-10-19  3:57   ` Amir Goldstein
2017-10-19 20:06     ` Darrick J. Wong
2017-10-20  3:18       ` Amir Goldstein
2017-10-19 19:45   ` Darrick J. Wong
2017-10-21  1:13     ` Allison Henderson
2017-10-19  4:11 ` [PATCH 00/17] Parent Pointers V3 Amir Goldstein
2017-10-20  3:22   ` Amir Goldstein
2017-10-21  1:06     ` Allison Henderson
2017-10-20 22:41   ` Dave Chinner
2017-10-21  7:34     ` Amir Goldstein
2017-10-22 23:27       ` Dave Chinner
2017-10-23  4:30         ` Amir Goldstein
2017-10-23  5:32           ` Dave Chinner
2017-10-23  6:48             ` Amir Goldstein
2017-10-23  8:40               ` Dave Chinner
2017-10-23  9:06                 ` Amir Goldstein
2017-10-23 17:14                   ` Darrick J. Wong
2017-10-23 19:20                     ` Amir Goldstein
  -- strict thread matches above, loose matches on Subject: below --
2017-10-06 22:05 [PATCH 00/17] Parent Pointers V2 Allison Henderson
2017-10-06 22:05 ` [PATCH 16/17] Add parent pointers to rename Allison Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1508367333-3237-17-git-send-email-allison.henderson@oracle.com \
    --to=allison.henderson@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.