[XFS] cleanup vnode use in xfs_symlink and xfs_rename
SGI-PV: 976035 SGI-Modid: xfs-linux-melb:xfs-kern:30548a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
This commit is contained in:
parent
a3da789640
commit
3937be5ba8
4 changed files with 33 additions and 48 deletions
|
@ -437,29 +437,33 @@ xfs_vn_symlink(
|
|||
struct dentry *dentry,
|
||||
const char *symname)
|
||||
{
|
||||
struct inode *ip;
|
||||
bhv_vnode_t *cvp; /* used to lookup symlink to put in dentry */
|
||||
struct inode *inode;
|
||||
struct xfs_inode *cip = NULL;
|
||||
int error;
|
||||
mode_t mode;
|
||||
|
||||
cvp = NULL;
|
||||
|
||||
mode = S_IFLNK |
|
||||
(irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
|
||||
|
||||
error = xfs_symlink(XFS_I(dir), dentry, (char *)symname, mode,
|
||||
&cvp, NULL);
|
||||
if (likely(!error && cvp)) {
|
||||
error = xfs_init_security(cvp, dir);
|
||||
if (likely(!error)) {
|
||||
ip = vn_to_inode(cvp);
|
||||
d_instantiate(dentry, ip);
|
||||
&cip, NULL);
|
||||
if (unlikely(error))
|
||||
goto out;
|
||||
|
||||
inode = cip->i_vnode;
|
||||
|
||||
error = xfs_init_security(inode, dir);
|
||||
if (unlikely(error))
|
||||
goto out_cleanup_inode;
|
||||
|
||||
d_instantiate(dentry, inode);
|
||||
xfs_validate_fields(dir);
|
||||
xfs_validate_fields(ip);
|
||||
} else {
|
||||
xfs_cleanup_inode(dir, cvp, dentry, 0);
|
||||
}
|
||||
}
|
||||
xfs_validate_fields(inode);
|
||||
return 0;
|
||||
|
||||
out_cleanup_inode:
|
||||
xfs_cleanup_inode(dir, inode, dentry, 0);
|
||||
out:
|
||||
return -error;
|
||||
}
|
||||
|
||||
|
@ -487,12 +491,9 @@ xfs_vn_rename(
|
|||
struct dentry *ndentry)
|
||||
{
|
||||
struct inode *new_inode = ndentry->d_inode;
|
||||
bhv_vnode_t *tvp; /* target directory */
|
||||
int error;
|
||||
|
||||
tvp = vn_from_inode(ndir);
|
||||
|
||||
error = xfs_rename(XFS_I(odir), odentry, tvp, ndentry);
|
||||
error = xfs_rename(XFS_I(odir), odentry, XFS_I(ndir), ndentry);
|
||||
if (likely(!error)) {
|
||||
if (new_inode)
|
||||
xfs_validate_fields(new_inode);
|
||||
|
|
|
@ -219,12 +219,11 @@ int
|
|||
xfs_rename(
|
||||
xfs_inode_t *src_dp,
|
||||
bhv_vname_t *src_vname,
|
||||
bhv_vnode_t *target_dir_vp,
|
||||
xfs_inode_t *target_dp,
|
||||
bhv_vname_t *target_vname)
|
||||
{
|
||||
bhv_vnode_t *src_dir_vp = XFS_ITOV(src_dp);
|
||||
xfs_trans_t *tp;
|
||||
xfs_inode_t *target_dp, *src_ip, *target_ip;
|
||||
xfs_inode_t *src_ip, *target_ip;
|
||||
xfs_mount_t *mp = src_dp->i_mount;
|
||||
int new_parent; /* moving to a new dir */
|
||||
int src_is_directory; /* src_name is a directory */
|
||||
|
@ -244,16 +243,7 @@ xfs_rename(
|
|||
int target_namelen = VNAMELEN(target_vname);
|
||||
|
||||
xfs_itrace_entry(src_dp);
|
||||
xfs_itrace_entry(xfs_vtoi(target_dir_vp));
|
||||
|
||||
/*
|
||||
* Find the XFS behavior descriptor for the target directory
|
||||
* vnode since it was not handed to us.
|
||||
*/
|
||||
target_dp = xfs_vtoi(target_dir_vp);
|
||||
if (target_dp == NULL) {
|
||||
return XFS_ERROR(EXDEV);
|
||||
}
|
||||
xfs_itrace_entry(target_dp);
|
||||
|
||||
if (DM_EVENT_ENABLED(src_dp, DM_EVENT_RENAME) ||
|
||||
DM_EVENT_ENABLED(target_dp, DM_EVENT_RENAME)) {
|
||||
|
@ -360,10 +350,10 @@ xfs_rename(
|
|||
* them when they unlock the inodes. Also, we need to be careful
|
||||
* not to add an inode to the transaction more than once.
|
||||
*/
|
||||
VN_HOLD(src_dir_vp);
|
||||
IHOLD(src_dp);
|
||||
xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL);
|
||||
if (new_parent) {
|
||||
VN_HOLD(target_dir_vp);
|
||||
IHOLD(target_dp);
|
||||
xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL);
|
||||
}
|
||||
if ((src_ip != src_dp) && (src_ip != target_dp)) {
|
||||
|
|
|
@ -3059,10 +3059,9 @@ xfs_symlink(
|
|||
bhv_vname_t *dentry,
|
||||
char *target_path,
|
||||
mode_t mode,
|
||||
bhv_vnode_t **vpp,
|
||||
xfs_inode_t **ipp,
|
||||
cred_t *credp)
|
||||
{
|
||||
bhv_vnode_t *dir_vp = XFS_ITOV(dp);
|
||||
xfs_mount_t *mp = dp->i_mount;
|
||||
xfs_trans_t *tp;
|
||||
xfs_inode_t *ip;
|
||||
|
@ -3088,7 +3087,7 @@ xfs_symlink(
|
|||
char *link_name = VNAME(dentry);
|
||||
int link_namelen;
|
||||
|
||||
*vpp = NULL;
|
||||
*ipp = NULL;
|
||||
error = 0;
|
||||
ip = NULL;
|
||||
tp = NULL;
|
||||
|
@ -3227,7 +3226,7 @@ xfs_symlink(
|
|||
* transaction cancel unlocking dp so don't do it explicitly in the
|
||||
* error path.
|
||||
*/
|
||||
VN_HOLD(dir_vp);
|
||||
IHOLD(dp);
|
||||
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
|
||||
unlock_dp_on_error = B_FALSE;
|
||||
|
||||
|
@ -3343,13 +3342,8 @@ xfs_symlink(
|
|||
0, error, 0);
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
bhv_vnode_t *vp;
|
||||
|
||||
ASSERT(ip);
|
||||
vp = XFS_ITOV(ip);
|
||||
*vpp = vp;
|
||||
}
|
||||
if (!error)
|
||||
*ipp = ip;
|
||||
return error;
|
||||
|
||||
error2:
|
||||
|
|
|
@ -36,7 +36,7 @@ int xfs_rmdir(struct xfs_inode *dp, bhv_vname_t *dentry);
|
|||
int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize,
|
||||
xfs_off_t *offset, filldir_t filldir);
|
||||
int xfs_symlink(struct xfs_inode *dp, bhv_vname_t *dentry,
|
||||
char *target_path, mode_t mode, bhv_vnode_t **vpp,
|
||||
char *target_path, mode_t mode, struct xfs_inode **ipp,
|
||||
struct cred *credp);
|
||||
int xfs_inode_flush(struct xfs_inode *ip, int flags);
|
||||
int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state);
|
||||
|
@ -45,7 +45,7 @@ int xfs_change_file_space(struct xfs_inode *ip, int cmd,
|
|||
xfs_flock64_t *bf, xfs_off_t offset,
|
||||
struct cred *credp, int attr_flags);
|
||||
int xfs_rename(struct xfs_inode *src_dp, bhv_vname_t *src_vname,
|
||||
bhv_vnode_t *target_dir_vp, bhv_vname_t *target_vname);
|
||||
struct xfs_inode *target_dp, bhv_vname_t *target_vname);
|
||||
int xfs_attr_get(struct xfs_inode *ip, const char *name, char *value,
|
||||
int *valuelenp, int flags, cred_t *cred);
|
||||
int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value,
|
||||
|
|
Loading…
Reference in a new issue