From: Mark Tinguely <tinguely@sgi.com>
To: xfs@oss.sgi.com
Subject: [RFC 10/17] xfs: (parent ptr) add parent pointer support to xfs_remove
Date: Wed, 15 Jan 2014 16:00:22 -0600 [thread overview]
Message-ID: <20140116000852.025916405@sgi.com> (raw)
In-Reply-To: 20140115220012.624438534@sgi.com
[-- Attachment #1: 10-pptr-add-to_xfs_remove.patch --]
[-- Type: text/plain, Size: 3685 bytes --]
Remove the parent inode / offset entry when removing the
link. The entry could be in the inode core or an extended
attribute.
---
fs/xfs/xfs_attr.c | 16 ++++++++++------
fs/xfs/xfs_inode.c | 36 ++++++++++++++++++++++++++++++++----
2 files changed, 42 insertions(+), 10 deletions(-)
Index: b/fs/xfs/xfs_attr.c
===================================================================
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -466,7 +466,7 @@ xfs_attr_set(
* Generic handler routine to remove a name from an attribute list.
* Transitions attribute list from Btree to shortform as necessary.
*/
-STATIC int
+int
xfs_attr_remove_int(xfs_inode_t *dp, struct xfs_name *name, int flags)
{
xfs_da_args_t args;
@@ -594,16 +594,20 @@ xfs_attr_remove(
int flags)
{
int error;
- struct xfs_name xname;
+ struct xfs_name xname, *xnamep;
XFS_STATS_INC(xs_attr_remove);
if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return (EIO);
- error = xfs_attr_name_to_xname(&xname, name);
- if (error)
- return error;
+ if ((flags & ATTR_PARENT) == 0) {
+ xnamep = &xname;
+ error = xfs_attr_name_to_xname(xnamep, name);
+ if (error)
+ return error;
+ } else
+ xnamep = (struct xfs_name *) name;
xfs_ilock(dp, XFS_ILOCK_SHARED);
if (!xfs_inode_hasattr(dp)) {
@@ -612,7 +616,7 @@ xfs_attr_remove(
}
xfs_iunlock(dp, XFS_ILOCK_SHARED);
- return xfs_attr_remove_int(dp, &xname, flags);
+ return xfs_attr_remove_int(dp, xnamep, flags);
}
Index: b/fs/xfs/xfs_inode.c
===================================================================
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2493,6 +2493,7 @@ xfs_remove(
int link_zero;
uint resblks;
uint log_count;
+ uint offset;
trace_xfs_remove(dp, name);
@@ -2585,13 +2586,24 @@ xfs_remove(
link_zero = (ip->i_d.di_nlink == 0);
xfs_bmap_init(&free_list, &first_block);
- error = xfs_dir_removename(tp, dp, name, ip->i_ino,
- &first_block, &free_list, resblks, NULL);
+ error = xfs_dir_removename(tp, dp, name, ip->i_ino, &first_block,
+ &free_list, resblks, &offset);
if (error) {
ASSERT(error != ENOENT);
goto out_bmap_cancel;
}
+ if (xfs_sb_version_hasparent(&mp->m_sb) &&
+ atomic_read(&VFS_I(ip)->i_count) > 1 && !link_zero &&
+ ip->i_d.di_parent == cpu_to_be64(dp->i_ino) &&
+ ip->i_d.di_poffset == cpu_to_be32(offset)) {
+ /* Remove the incore parent information */
+ ip->i_d.di_parent = NULLFSINO;
+ ip->i_d.di_poffset = 0;
+ xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
+ offset = 0;
+ }
+
/*
* If this is a synchronous mount, make sure that the
* remove transaction goes to disk before returning to
@@ -2608,6 +2620,22 @@ xfs_remove(
if (error)
goto std_return;
+ if (xfs_sb_version_hasparent(&mp->m_sb) &&
+ atomic_read(&VFS_I(ip)->i_count) > 1 && !link_zero && offset) {
+ struct xfs_pattr p_entry;
+ struct xfs_name p_name;
+
+ xfs_parent_pname(dp->i_ino, offset, &p_entry, &p_name);
+ error = xfs_attr_remove(ip, (char *) &p_name, ATTR_PARENT);
+ if (error) {
+ xfs_notice(mp,
+ "%s: attr %llx/%x failed inode %llx %d\n",
+ __func__, dp->i_ino, offset,
+ ip->i_ino, error);
+ if (error == ENOATTR)
+ error = 0;
+ }
+ }
/*
* If we are using filestreams, kill the stream association.
* If the file is still open it may get a new one but that
@@ -2617,7 +2645,7 @@ xfs_remove(
if (!is_dir && link_zero && xfs_inode_is_filestream(ip))
xfs_filestream_deassociate(ip);
- return 0;
+ return error;
out_bmap_cancel:
xfs_bmap_cancel(&free_list);
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-01-16 0:30 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-15 22:00 [RFC 00/17] RFC parent inode pointers Mark Tinguely
2014-01-15 22:00 ` [RFC 01/17] xfs: (parent ptr) get offset when adding directory name Mark Tinguely
2014-01-15 22:00 ` [RFC 02/17] xfs: (parent ptr) get offset when removing " Mark Tinguely
2014-01-15 22:00 ` [RFC 03/17] xfs: (parent ptr) get offset when replacing a " Mark Tinguely
2014-01-15 22:00 ` [RFC 04/17] xfs: (parent ptr) add parent pointer support to xfs_sb.h Mark Tinguely
2014-01-15 22:00 ` [RFC 05/17] xfs: (parent ptr) add parent pointer support to attribute code Mark Tinguely
2014-01-15 22:00 ` [RFC 06/17] xfs: (parent ptr) add parent pointer support to inode v5 Mark Tinguely
2014-01-15 22:00 ` [RFC 07/17] xfs: (parent ptr) add parent pointer support to xfs_create Mark Tinguely
2014-01-15 22:00 ` [RFC 08/17] xfs: (parent ptr) add parent pointer support to xfs_symlink Mark Tinguely
2014-01-15 22:00 ` [RFC 09/17] xfs: (parent ptr) add parent pointer support to xfs_link Mark Tinguely
2014-01-15 22:00 ` Mark Tinguely [this message]
2014-01-15 22:00 ` [RFC 11/17] xfs: (parent ptr) add parent pointer support to xfs_rename Mark Tinguely
2014-01-15 22:00 ` [RFC 12/17] xfs: (parent ptr) add parent pointer support for user space Mark Tinguely
2014-01-15 22:00 ` [RFC 13/17] xfsprogs: add parent pointer support into Linux 3.10 inode 3 Mark Tinguely
2014-01-15 22:00 ` [RFC 14/17] xfsprogs: add parent pointer values to headers and fix repair Mark Tinguely
2014-01-15 22:00 ` [RFC 15/17] xfsprogs: add basic parent pointer support to xfs_db Mark Tinguely
2014-01-15 22:00 ` [RFC 16/17] xfsprogs: add parent pointer support to xfs_io Mark Tinguely
2014-01-15 22:00 ` [RFC 17/17] xfsprogs: add parent GEOM information Mark Tinguely
2014-01-16 5:56 ` [RFC 00/17] RFC parent inode pointers Dave Chinner
2014-01-17 21:25 ` Mark Tinguely
2014-01-18 3:12 ` Dave Chinner
2014-01-27 19:41 ` Mark Tinguely
2014-01-28 3:00 ` Dave Chinner
2014-01-28 22:02 ` Geoffrey Wehrman
2014-02-04 0:09 ` Dave Chinner
2014-02-04 5:37 ` Geoffrey Wehrman
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=20140116000852.025916405@sgi.com \
--to=tinguely@sgi.com \
--cc=xfs@oss.sgi.com \
/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.