[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:
Родитель
a3da789640
Коммит
3937be5ba8
|
@ -437,29 +437,33 @@ xfs_vn_symlink(
|
||||||
struct dentry *dentry,
|
struct dentry *dentry,
|
||||||
const char *symname)
|
const char *symname)
|
||||||
{
|
{
|
||||||
struct inode *ip;
|
struct inode *inode;
|
||||||
bhv_vnode_t *cvp; /* used to lookup symlink to put in dentry */
|
struct xfs_inode *cip = NULL;
|
||||||
int error;
|
int error;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
|
|
||||||
cvp = NULL;
|
|
||||||
|
|
||||||
mode = S_IFLNK |
|
mode = S_IFLNK |
|
||||||
(irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
|
(irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
|
||||||
|
|
||||||
error = xfs_symlink(XFS_I(dir), dentry, (char *)symname, mode,
|
error = xfs_symlink(XFS_I(dir), dentry, (char *)symname, mode,
|
||||||
&cvp, NULL);
|
&cip, NULL);
|
||||||
if (likely(!error && cvp)) {
|
if (unlikely(error))
|
||||||
error = xfs_init_security(cvp, dir);
|
goto out;
|
||||||
if (likely(!error)) {
|
|
||||||
ip = vn_to_inode(cvp);
|
inode = cip->i_vnode;
|
||||||
d_instantiate(dentry, ip);
|
|
||||||
|
error = xfs_init_security(inode, dir);
|
||||||
|
if (unlikely(error))
|
||||||
|
goto out_cleanup_inode;
|
||||||
|
|
||||||
|
d_instantiate(dentry, inode);
|
||||||
xfs_validate_fields(dir);
|
xfs_validate_fields(dir);
|
||||||
xfs_validate_fields(ip);
|
xfs_validate_fields(inode);
|
||||||
} else {
|
return 0;
|
||||||
xfs_cleanup_inode(dir, cvp, dentry, 0);
|
|
||||||
}
|
out_cleanup_inode:
|
||||||
}
|
xfs_cleanup_inode(dir, inode, dentry, 0);
|
||||||
|
out:
|
||||||
return -error;
|
return -error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,12 +491,9 @@ xfs_vn_rename(
|
||||||
struct dentry *ndentry)
|
struct dentry *ndentry)
|
||||||
{
|
{
|
||||||
struct inode *new_inode = ndentry->d_inode;
|
struct inode *new_inode = ndentry->d_inode;
|
||||||
bhv_vnode_t *tvp; /* target directory */
|
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
tvp = vn_from_inode(ndir);
|
error = xfs_rename(XFS_I(odir), odentry, XFS_I(ndir), ndentry);
|
||||||
|
|
||||||
error = xfs_rename(XFS_I(odir), odentry, tvp, ndentry);
|
|
||||||
if (likely(!error)) {
|
if (likely(!error)) {
|
||||||
if (new_inode)
|
if (new_inode)
|
||||||
xfs_validate_fields(new_inode);
|
xfs_validate_fields(new_inode);
|
||||||
|
|
|
@ -219,12 +219,11 @@ int
|
||||||
xfs_rename(
|
xfs_rename(
|
||||||
xfs_inode_t *src_dp,
|
xfs_inode_t *src_dp,
|
||||||
bhv_vname_t *src_vname,
|
bhv_vname_t *src_vname,
|
||||||
bhv_vnode_t *target_dir_vp,
|
xfs_inode_t *target_dp,
|
||||||
bhv_vname_t *target_vname)
|
bhv_vname_t *target_vname)
|
||||||
{
|
{
|
||||||
bhv_vnode_t *src_dir_vp = XFS_ITOV(src_dp);
|
|
||||||
xfs_trans_t *tp;
|
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;
|
xfs_mount_t *mp = src_dp->i_mount;
|
||||||
int new_parent; /* moving to a new dir */
|
int new_parent; /* moving to a new dir */
|
||||||
int src_is_directory; /* src_name is a directory */
|
int src_is_directory; /* src_name is a directory */
|
||||||
|
@ -244,16 +243,7 @@ xfs_rename(
|
||||||
int target_namelen = VNAMELEN(target_vname);
|
int target_namelen = VNAMELEN(target_vname);
|
||||||
|
|
||||||
xfs_itrace_entry(src_dp);
|
xfs_itrace_entry(src_dp);
|
||||||
xfs_itrace_entry(xfs_vtoi(target_dir_vp));
|
xfs_itrace_entry(target_dp);
|
||||||
|
|
||||||
/*
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DM_EVENT_ENABLED(src_dp, DM_EVENT_RENAME) ||
|
if (DM_EVENT_ENABLED(src_dp, DM_EVENT_RENAME) ||
|
||||||
DM_EVENT_ENABLED(target_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
|
* them when they unlock the inodes. Also, we need to be careful
|
||||||
* not to add an inode to the transaction more than once.
|
* 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);
|
xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL);
|
||||||
if (new_parent) {
|
if (new_parent) {
|
||||||
VN_HOLD(target_dir_vp);
|
IHOLD(target_dp);
|
||||||
xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL);
|
xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL);
|
||||||
}
|
}
|
||||||
if ((src_ip != src_dp) && (src_ip != target_dp)) {
|
if ((src_ip != src_dp) && (src_ip != target_dp)) {
|
||||||
|
|
|
@ -3059,10 +3059,9 @@ xfs_symlink(
|
||||||
bhv_vname_t *dentry,
|
bhv_vname_t *dentry,
|
||||||
char *target_path,
|
char *target_path,
|
||||||
mode_t mode,
|
mode_t mode,
|
||||||
bhv_vnode_t **vpp,
|
xfs_inode_t **ipp,
|
||||||
cred_t *credp)
|
cred_t *credp)
|
||||||
{
|
{
|
||||||
bhv_vnode_t *dir_vp = XFS_ITOV(dp);
|
|
||||||
xfs_mount_t *mp = dp->i_mount;
|
xfs_mount_t *mp = dp->i_mount;
|
||||||
xfs_trans_t *tp;
|
xfs_trans_t *tp;
|
||||||
xfs_inode_t *ip;
|
xfs_inode_t *ip;
|
||||||
|
@ -3088,7 +3087,7 @@ xfs_symlink(
|
||||||
char *link_name = VNAME(dentry);
|
char *link_name = VNAME(dentry);
|
||||||
int link_namelen;
|
int link_namelen;
|
||||||
|
|
||||||
*vpp = NULL;
|
*ipp = NULL;
|
||||||
error = 0;
|
error = 0;
|
||||||
ip = NULL;
|
ip = NULL;
|
||||||
tp = NULL;
|
tp = NULL;
|
||||||
|
@ -3227,7 +3226,7 @@ xfs_symlink(
|
||||||
* transaction cancel unlocking dp so don't do it explicitly in the
|
* transaction cancel unlocking dp so don't do it explicitly in the
|
||||||
* error path.
|
* error path.
|
||||||
*/
|
*/
|
||||||
VN_HOLD(dir_vp);
|
IHOLD(dp);
|
||||||
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
|
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
|
||||||
unlock_dp_on_error = B_FALSE;
|
unlock_dp_on_error = B_FALSE;
|
||||||
|
|
||||||
|
@ -3343,13 +3342,8 @@ std_return:
|
||||||
0, error, 0);
|
0, error, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error) {
|
if (!error)
|
||||||
bhv_vnode_t *vp;
|
*ipp = ip;
|
||||||
|
|
||||||
ASSERT(ip);
|
|
||||||
vp = XFS_ITOV(ip);
|
|
||||||
*vpp = vp;
|
|
||||||
}
|
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
error2:
|
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,
|
int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize,
|
||||||
xfs_off_t *offset, filldir_t filldir);
|
xfs_off_t *offset, filldir_t filldir);
|
||||||
int xfs_symlink(struct xfs_inode *dp, bhv_vname_t *dentry,
|
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);
|
struct cred *credp);
|
||||||
int xfs_inode_flush(struct xfs_inode *ip, int flags);
|
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);
|
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,
|
xfs_flock64_t *bf, xfs_off_t offset,
|
||||||
struct cred *credp, int attr_flags);
|
struct cred *credp, int attr_flags);
|
||||||
int xfs_rename(struct xfs_inode *src_dp, bhv_vname_t *src_vname,
|
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 xfs_attr_get(struct xfs_inode *ip, const char *name, char *value,
|
||||||
int *valuelenp, int flags, cred_t *cred);
|
int *valuelenp, int flags, cred_t *cred);
|
||||||
int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value,
|
int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче