From: Allison Henderson <allison.henderson@oracle.com>
To: linux-xfs@vger.kernel.org
Cc: Allison Henderson <allison.henderson@oracle.com>
Subject: [PATCH v3 15/17] Add parent pointers to rename
Date: Fri, 17 Nov 2017 11:21:43 -0700 [thread overview]
Message-ID: <1510942905-12897-16-git-send-email-allison.henderson@oracle.com> (raw)
In-Reply-To: <1510942905-12897-1-git-send-email-allison.henderson@oracle.com>
This patch removes the old parent pointer attribute during the
rename operation, and re-adds the updated parent pointer
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 25b370b..ed25203 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 a289a40..da5c761 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2984,6 +2984,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);
@@ -3086,13 +3088,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)
@@ -3126,7 +3127,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;
@@ -3161,7 +3162,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;
@@ -3200,11 +3201,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;
@@ -3234,6 +3236,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
next prev parent reply other threads:[~2017-11-17 18:24 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 18:21 [PATCH v3 00/17] Parent Pointers v4 Allison Henderson
2017-11-17 18:21 ` [PATCH v3 01/17] Add helper functions xfs_attr_set_args and xfs_attr_remove_args Allison Henderson
2017-11-28 19:54 ` Darrick J. Wong
2017-11-29 1:02 ` Dave Chinner
2017-11-29 18:52 ` Allison Henderson
2017-11-29 22:34 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 02/17] Set up infastructure for deferred attribute operations Allison Henderson
2017-11-28 19:45 ` Darrick J. Wong
2017-11-29 1:19 ` Dave Chinner
2017-11-29 18:52 ` Allison Henderson
2017-11-29 18:51 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 03/17] Add xfs_attr_set_defered and xfs_attr_remove_defered Allison Henderson
2017-11-28 19:19 ` Darrick J. Wong
2017-11-29 18:50 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 04/17] Remove all strlen calls in all xfs_attr_* functions for attr names Allison Henderson
2017-11-28 19:10 ` Darrick J. Wong
2017-11-29 18:50 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 05/17] xfs: get directory offset when adding directory name Allison Henderson
2017-11-28 19:07 ` Darrick J. Wong
2017-11-29 18:50 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 06/17] xfs: get directory offset when removing " Allison Henderson
2017-11-28 19:05 ` Darrick J. Wong
2017-11-29 18:49 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 07/17] xfs: get directory offset when replacing a " Allison Henderson
2017-11-28 19:04 ` Darrick J. Wong
2017-11-29 18:49 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 08/17] xfs: add parent pointer support to attribute code Allison Henderson
2017-11-28 19:01 ` Darrick J. Wong
2017-11-29 18:48 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 09/17] xfs: define parent pointer xattr format Allison Henderson
2017-11-28 18:59 ` Darrick J. Wong
2017-11-29 18:48 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 10/17] xfs: extent transaction reservations for parent attributes Allison Henderson
2017-11-28 18:58 ` Darrick J. Wong
2017-11-29 18:48 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 11/17] Add the extra space requirements for parent pointer attributes when calculating the minimum log size during mkfs Allison Henderson
2017-11-28 18:51 ` Darrick J. Wong
2017-11-29 18:47 ` Allison Henderson
2017-11-29 20:18 ` Darrick J. Wong
2017-11-17 18:21 ` [PATCH v3 12/17] xfs: parent pointer attribute creation Allison Henderson
2017-11-28 18:49 ` Darrick J. Wong
2017-11-28 18:54 ` Darrick J. Wong
2017-11-29 18:46 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 13/17] xfs: add parent attributes to link Allison Henderson
2017-11-28 18:37 ` Darrick J. Wong
2017-11-29 18:45 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 14/17] xfs: remove parent pointers in unlink Allison Henderson
2017-11-28 18:24 ` Darrick J. Wong
2017-11-29 18:44 ` Allison Henderson
2017-11-17 18:21 ` Allison Henderson [this message]
2017-11-28 18:20 ` [PATCH v3 15/17] Add parent pointers to rename Darrick J. Wong
2017-11-29 18:43 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 16/17] Add the parent pointer support to the superblock version 5 Allison Henderson
2017-11-28 18:08 ` Darrick J. Wong
2017-11-29 18:41 ` Allison Henderson
2017-11-17 18:21 ` [PATCH v3 17/17] Add parent pointer ioctl Allison Henderson
2017-11-22 19:54 ` Allison Henderson
2017-11-22 21:07 ` Dave Chinner
2017-11-22 22:49 ` Allison Henderson
2017-11-22 21:13 ` Darrick J. Wong
2017-11-22 22:49 ` Allison Henderson
2017-11-28 20:35 ` Darrick J. Wong
2017-11-29 18:52 ` Allison Henderson
2017-11-29 21:37 ` Dave Chinner
2017-11-29 22:48 ` Allison Henderson
2017-11-30 0:02 ` Dave Chinner
2017-11-30 1:52 ` Allison Henderson
2017-11-30 21:11 ` Darrick J. Wong
2017-12-01 2:58 ` Dave Chinner
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=1510942905-12897-16-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).