From: Darrick J. Wong <djwong@xxxxxxxxxx> Use the nlink hooks to keep our tempfile's parent pointers up to date. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- libxfs/xfs_parent.c | 25 +++++++++++++++++++++++++ libxfs/xfs_parent.h | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/libxfs/xfs_parent.c b/libxfs/xfs_parent.c index 3ce30860..a7c5974c 100644 --- a/libxfs/xfs_parent.c +++ b/libxfs/xfs_parent.c @@ -364,3 +364,28 @@ xfs_parent_set( return xfs_attr_set(&scr->args); } + +/* + * Remove the parent pointer (@rec -> @name) from @ip immediately. Caller must + * not have a transaction or hold the ILOCK. The update will not use logged + * xattrs. This is for specialized repair functions only. The scratchpad need + * not be initialized. + */ +int +xfs_parent_unset( + struct xfs_inode *ip, + const struct xfs_parent_name_irec *pptr, + struct xfs_parent_scratch *scr) +{ + xfs_parent_irec_to_disk(&scr->rec, NULL, NULL, pptr); + + memset(&scr->args, 0, sizeof(struct xfs_da_args)); + scr->args.attr_filter = XFS_ATTR_PARENT; + scr->args.dp = ip; + scr->args.geo = ip->i_mount->m_attr_geo; + scr->args.name = (const unsigned char *)&scr->rec; + scr->args.namelen = sizeof(struct xfs_parent_name_rec); + scr->args.whichfork = XFS_ATTR_FORK; + + return xfs_attr_set(&scr->args); +} diff --git a/libxfs/xfs_parent.h b/libxfs/xfs_parent.h index effbccdf..a7fc621b 100644 --- a/libxfs/xfs_parent.h +++ b/libxfs/xfs_parent.h @@ -117,4 +117,8 @@ int xfs_parent_set(struct xfs_inode *ip, const struct xfs_parent_name_irec *pptr, struct xfs_parent_scratch *scratch); +int xfs_parent_unset(struct xfs_inode *ip, + const struct xfs_parent_name_irec *rec, + struct xfs_parent_scratch *scratch); + #endif /* __XFS_PARENT_H__ */