diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-03-05 21:46:19 -0500 |
---|---|---|
committer | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-04-17 21:40:45 -0400 |
commit | 3937be5ba836a204d3d1df96b518eecd6cdacbb9 (patch) | |
tree | 89c21be058d0b1b43718f49025600346524cd68e /fs/xfs | |
parent | a3da789640871c897901c5f766e33be78d56f35a (diff) |
[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>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_iops.c | 41 | ||||
-rw-r--r-- | fs/xfs/xfs_rename.c | 20 | ||||
-rw-r--r-- | fs/xfs/xfs_vnodeops.c | 16 | ||||
-rw-r--r-- | fs/xfs/xfs_vnodeops.h | 4 |
4 files changed, 33 insertions, 48 deletions
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 1df48209d60..215158cbac4 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
@@ -437,29 +437,33 @@ xfs_vn_symlink( | |||
437 | struct dentry *dentry, | 437 | struct dentry *dentry, |
438 | const char *symname) | 438 | const char *symname) |
439 | { | 439 | { |
440 | struct inode *ip; | 440 | struct inode *inode; |
441 | bhv_vnode_t *cvp; /* used to lookup symlink to put in dentry */ | 441 | struct xfs_inode *cip = NULL; |
442 | int error; | 442 | int error; |
443 | mode_t mode; | 443 | mode_t mode; |
444 | 444 | ||
445 | cvp = NULL; | ||
446 | |||
447 | mode = S_IFLNK | | 445 | mode = S_IFLNK | |
448 | (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO); | 446 | (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO); |
449 | 447 | ||
450 | error = xfs_symlink(XFS_I(dir), dentry, (char *)symname, mode, | 448 | error = xfs_symlink(XFS_I(dir), dentry, (char *)symname, mode, |
451 | &cvp, NULL); | 449 | &cip, NULL); |
452 | if (likely(!error && cvp)) { | 450 | if (unlikely(error)) |
453 | error = xfs_init_security(cvp, dir); | 451 | goto out; |
454 | if (likely(!error)) { | 452 | |
455 | ip = vn_to_inode(cvp); | 453 | inode = cip->i_vnode; |
456 | d_instantiate(dentry, ip); | 454 | |
457 | xfs_validate_fields(dir); | 455 | error = xfs_init_security(inode, dir); |
458 | xfs_validate_fields(ip); | 456 | if (unlikely(error)) |
459 | } else { | 457 | goto out_cleanup_inode; |
460 | xfs_cleanup_inode(dir, cvp, dentry, 0); | 458 | |
461 | } | 459 | d_instantiate(dentry, inode); |
462 | } | 460 | xfs_validate_fields(dir); |
461 | xfs_validate_fields(inode); | ||
462 | return 0; | ||
463 | |||
464 | out_cleanup_inode: | ||
465 | xfs_cleanup_inode(dir, inode, dentry, 0); | ||
466 | out: | ||
463 | return -error; | 467 | return -error; |
464 | } | 468 | } |
465 | 469 | ||
@@ -487,12 +491,9 @@ xfs_vn_rename( | |||
487 | struct dentry *ndentry) | 491 | struct dentry *ndentry) |
488 | { | 492 | { |
489 | struct inode *new_inode = ndentry->d_inode; | 493 | struct inode *new_inode = ndentry->d_inode; |
490 | bhv_vnode_t *tvp; /* target directory */ | ||
491 | int error; | 494 | int error; |
492 | 495 | ||
493 | tvp = vn_from_inode(ndir); | 496 | error = xfs_rename(XFS_I(odir), odentry, XFS_I(ndir), ndentry); |
494 | |||
495 | error = xfs_rename(XFS_I(odir), odentry, tvp, ndentry); | ||
496 | if (likely(!error)) { | 497 | if (likely(!error)) { |
497 | if (new_inode) | 498 | if (new_inode) |
498 | xfs_validate_fields(new_inode); | 499 | xfs_validate_fields(new_inode); |
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c index 6f80cfdfbd8..c4d0bac56a5 100644 --- a/fs/xfs/xfs_rename.c +++ b/fs/xfs/xfs_rename.c | |||
@@ -219,12 +219,11 @@ int | |||
219 | xfs_rename( | 219 | xfs_rename( |
220 | xfs_inode_t *src_dp, | 220 | xfs_inode_t *src_dp, |
221 | bhv_vname_t *src_vname, | 221 | bhv_vname_t *src_vname, |
222 | bhv_vnode_t *target_dir_vp, | 222 | xfs_inode_t *target_dp, |
223 | bhv_vname_t *target_vname) | 223 | bhv_vname_t *target_vname) |
224 | { | 224 | { |
225 | bhv_vnode_t *src_dir_vp = XFS_ITOV(src_dp); | ||
226 | xfs_trans_t *tp; | 225 | xfs_trans_t *tp; |
227 | xfs_inode_t *target_dp, *src_ip, *target_ip; | 226 | xfs_inode_t *src_ip, *target_ip; |
228 | xfs_mount_t *mp = src_dp->i_mount; | 227 | xfs_mount_t *mp = src_dp->i_mount; |
229 | int new_parent; /* moving to a new dir */ | 228 | int new_parent; /* moving to a new dir */ |
230 | int src_is_directory; /* src_name is a directory */ | 229 | int src_is_directory; /* src_name is a directory */ |
@@ -244,16 +243,7 @@ xfs_rename( | |||
244 | int target_namelen = VNAMELEN(target_vname); | 243 | int target_namelen = VNAMELEN(target_vname); |
245 | 244 | ||
246 | xfs_itrace_entry(src_dp); | 245 | xfs_itrace_entry(src_dp); |
247 | xfs_itrace_entry(xfs_vtoi(target_dir_vp)); | 246 | xfs_itrace_entry(target_dp); |
248 | |||
249 | /* | ||
250 | * Find the XFS behavior descriptor for the target directory | ||
251 | * vnode since it was not handed to us. | ||
252 | */ | ||
253 | target_dp = xfs_vtoi(target_dir_vp); | ||
254 | if (target_dp == NULL) { | ||
255 | return XFS_ERROR(EXDEV); | ||
256 | } | ||
257 | 247 | ||
258 | if (DM_EVENT_ENABLED(src_dp, DM_EVENT_RENAME) || | 248 | if (DM_EVENT_ENABLED(src_dp, DM_EVENT_RENAME) || |
259 | DM_EVENT_ENABLED(target_dp, DM_EVENT_RENAME)) { | 249 | DM_EVENT_ENABLED(target_dp, DM_EVENT_RENAME)) { |
@@ -360,10 +350,10 @@ xfs_rename( | |||
360 | * them when they unlock the inodes. Also, we need to be careful | 350 | * them when they unlock the inodes. Also, we need to be careful |
361 | * not to add an inode to the transaction more than once. | 351 | * not to add an inode to the transaction more than once. |
362 | */ | 352 | */ |
363 | VN_HOLD(src_dir_vp); | 353 | IHOLD(src_dp); |
364 | xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL); | 354 | xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL); |
365 | if (new_parent) { | 355 | if (new_parent) { |
366 | VN_HOLD(target_dir_vp); | 356 | IHOLD(target_dp); |
367 | xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL); | 357 | xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL); |
368 | } | 358 | } |
369 | if ((src_ip != src_dp) && (src_ip != target_dp)) { | 359 | if ((src_ip != src_dp) && (src_ip != target_dp)) { |
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 10d2d22eb03..fa694dc5d30 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -3059,10 +3059,9 @@ xfs_symlink( | |||
3059 | bhv_vname_t *dentry, | 3059 | bhv_vname_t *dentry, |
3060 | char *target_path, | 3060 | char *target_path, |
3061 | mode_t mode, | 3061 | mode_t mode, |
3062 | bhv_vnode_t **vpp, | 3062 | xfs_inode_t **ipp, |
3063 | cred_t *credp) | 3063 | cred_t *credp) |
3064 | { | 3064 | { |
3065 | bhv_vnode_t *dir_vp = XFS_ITOV(dp); | ||
3066 | xfs_mount_t *mp = dp->i_mount; | 3065 | xfs_mount_t *mp = dp->i_mount; |
3067 | xfs_trans_t *tp; | 3066 | xfs_trans_t *tp; |
3068 | xfs_inode_t *ip; | 3067 | xfs_inode_t *ip; |
@@ -3088,7 +3087,7 @@ xfs_symlink( | |||
3088 | char *link_name = VNAME(dentry); | 3087 | char *link_name = VNAME(dentry); |
3089 | int link_namelen; | 3088 | int link_namelen; |
3090 | 3089 | ||
3091 | *vpp = NULL; | 3090 | *ipp = NULL; |
3092 | error = 0; | 3091 | error = 0; |
3093 | ip = NULL; | 3092 | ip = NULL; |
3094 | tp = NULL; | 3093 | tp = NULL; |
@@ -3227,7 +3226,7 @@ xfs_symlink( | |||
3227 | * transaction cancel unlocking dp so don't do it explicitly in the | 3226 | * transaction cancel unlocking dp so don't do it explicitly in the |
3228 | * error path. | 3227 | * error path. |
3229 | */ | 3228 | */ |
3230 | VN_HOLD(dir_vp); | 3229 | IHOLD(dp); |
3231 | xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); | 3230 | xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); |
3232 | unlock_dp_on_error = B_FALSE; | 3231 | unlock_dp_on_error = B_FALSE; |
3233 | 3232 | ||
@@ -3343,13 +3342,8 @@ std_return: | |||
3343 | 0, error, 0); | 3342 | 0, error, 0); |
3344 | } | 3343 | } |
3345 | 3344 | ||
3346 | if (!error) { | 3345 | if (!error) |
3347 | bhv_vnode_t *vp; | 3346 | *ipp = ip; |
3348 | |||
3349 | ASSERT(ip); | ||
3350 | vp = XFS_ITOV(ip); | ||
3351 | *vpp = vp; | ||
3352 | } | ||
3353 | return error; | 3347 | return error; |
3354 | 3348 | ||
3355 | error2: | 3349 | error2: |
diff --git a/fs/xfs/xfs_vnodeops.h b/fs/xfs/xfs_vnodeops.h index 79c13f57a81..71e9b15276f 100644 --- a/fs/xfs/xfs_vnodeops.h +++ b/fs/xfs/xfs_vnodeops.h | |||
@@ -36,7 +36,7 @@ int xfs_rmdir(struct xfs_inode *dp, bhv_vname_t *dentry); | |||
36 | int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize, | 36 | int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize, |
37 | xfs_off_t *offset, filldir_t filldir); | 37 | xfs_off_t *offset, filldir_t filldir); |
38 | int xfs_symlink(struct xfs_inode *dp, bhv_vname_t *dentry, | 38 | int xfs_symlink(struct xfs_inode *dp, bhv_vname_t *dentry, |
39 | char *target_path, mode_t mode, bhv_vnode_t **vpp, | 39 | char *target_path, mode_t mode, struct xfs_inode **ipp, |
40 | struct cred *credp); | 40 | struct cred *credp); |
41 | int xfs_inode_flush(struct xfs_inode *ip, int flags); | 41 | int xfs_inode_flush(struct xfs_inode *ip, int flags); |
42 | int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state); | 42 | 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, | |||
45 | xfs_flock64_t *bf, xfs_off_t offset, | 45 | xfs_flock64_t *bf, xfs_off_t offset, |
46 | struct cred *credp, int attr_flags); | 46 | struct cred *credp, int attr_flags); |
47 | int xfs_rename(struct xfs_inode *src_dp, bhv_vname_t *src_vname, | 47 | int xfs_rename(struct xfs_inode *src_dp, bhv_vname_t *src_vname, |
48 | bhv_vnode_t *target_dir_vp, bhv_vname_t *target_vname); | 48 | struct xfs_inode *target_dp, bhv_vname_t *target_vname); |
49 | int xfs_attr_get(struct xfs_inode *ip, const char *name, char *value, | 49 | int xfs_attr_get(struct xfs_inode *ip, const char *name, char *value, |
50 | int *valuelenp, int flags, cred_t *cred); | 50 | int *valuelenp, int flags, cred_t *cred); |
51 | int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value, | 51 | int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value, |