aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-03-05 21:46:05 -0500
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-04-17 21:40:25 -0400
commit979ebab11623894528d4d37b947533ea4e8649d1 (patch)
treeb7d2554818c1c0e8b2d5a7c581567be3c740247c /fs/xfs
parentbc4ac74a4e5bd7db02976eb1b681e1d11f81c9ce (diff)
[XFS] cleanup vnode use in xfs_create/mknod/mkdir
SGI-PV: 976035 SGI-Modid: xfs-linux-melb:xfs-kern:30546a 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.c21
-rw-r--r--fs/xfs/xfs_vnodeops.c25
-rw-r--r--fs/xfs/xfs_vnodeops.h4
3 files changed, 22 insertions, 28 deletions
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 346701183318..62899a1ec7f7 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -273,7 +273,7 @@ xfs_vn_mknod(
273 dev_t rdev) 273 dev_t rdev)
274{ 274{
275 struct inode *inode; 275 struct inode *inode;
276 bhv_vnode_t *vp = NULL, *dvp = vn_from_inode(dir); 276 struct xfs_inode *ip = NULL;
277 xfs_acl_t *default_acl = NULL; 277 xfs_acl_t *default_acl = NULL;
278 attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; 278 attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS;
279 int error; 279 int error;
@@ -285,11 +285,11 @@ xfs_vn_mknod(
285 if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)) 285 if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
286 return -EINVAL; 286 return -EINVAL;
287 287
288 if (test_default_acl && test_default_acl(dvp)) { 288 if (test_default_acl && test_default_acl(dir)) {
289 if (!_ACL_ALLOC(default_acl)) { 289 if (!_ACL_ALLOC(default_acl)) {
290 return -ENOMEM; 290 return -ENOMEM;
291 } 291 }
292 if (!_ACL_GET_DEFAULT(dvp, default_acl)) { 292 if (!_ACL_GET_DEFAULT(dir, default_acl)) {
293 _ACL_FREE(default_acl); 293 _ACL_FREE(default_acl);
294 default_acl = NULL; 294 default_acl = NULL;
295 } 295 }
@@ -305,10 +305,10 @@ xfs_vn_mknod(
305 case S_IFSOCK: 305 case S_IFSOCK:
306 rdev = sysv_encode_dev(rdev); 306 rdev = sysv_encode_dev(rdev);
307 case S_IFREG: 307 case S_IFREG:
308 error = xfs_create(XFS_I(dir), dentry, mode, rdev, &vp, NULL); 308 error = xfs_create(XFS_I(dir), dentry, mode, rdev, &ip, NULL);
309 break; 309 break;
310 case S_IFDIR: 310 case S_IFDIR:
311 error = xfs_mkdir(XFS_I(dir), dentry, mode, &vp, NULL); 311 error = xfs_mkdir(XFS_I(dir), dentry, mode, &ip, NULL);
312 break; 312 break;
313 default: 313 default:
314 error = EINVAL; 314 error = EINVAL;
@@ -318,19 +318,20 @@ xfs_vn_mknod(
318 if (unlikely(error)) 318 if (unlikely(error))
319 goto out_free_acl; 319 goto out_free_acl;
320 320
321 error = xfs_init_security(vp, dir); 321 inode = ip->i_vnode;
322
323 error = xfs_init_security(inode, dir);
322 if (unlikely(error)) 324 if (unlikely(error))
323 goto out_cleanup_inode; 325 goto out_cleanup_inode;
324 326
325 if (default_acl) { 327 if (default_acl) {
326 error = _ACL_INHERIT(vp, mode, default_acl); 328 error = _ACL_INHERIT(inode, mode, default_acl);
327 if (unlikely(error)) 329 if (unlikely(error))
328 goto out_cleanup_inode; 330 goto out_cleanup_inode;
329 xfs_iflags_set(XFS_I(vp), XFS_IMODIFIED); 331 xfs_iflags_set(ip, XFS_IMODIFIED);
330 _ACL_FREE(default_acl); 332 _ACL_FREE(default_acl);
331 } 333 }
332 334
333 inode = vn_to_inode(vp);
334 335
335 if (S_ISDIR(mode)) 336 if (S_ISDIR(mode))
336 xfs_validate_fields(inode); 337 xfs_validate_fields(inode);
@@ -339,7 +340,7 @@ xfs_vn_mknod(
339 return -error; 340 return -error;
340 341
341 out_cleanup_inode: 342 out_cleanup_inode:
342 xfs_cleanup_inode(dir, vp, dentry, mode); 343 xfs_cleanup_inode(dir, inode, dentry, mode);
343 out_free_acl: 344 out_free_acl:
344 if (default_acl) 345 if (default_acl)
345 _ACL_FREE(default_acl); 346 _ACL_FREE(default_acl);
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 7e124b55c26b..a42d7fe6a5e8 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -1791,14 +1791,12 @@ xfs_create(
1791 bhv_vname_t *dentry, 1791 bhv_vname_t *dentry,
1792 mode_t mode, 1792 mode_t mode,
1793 xfs_dev_t rdev, 1793 xfs_dev_t rdev,
1794 bhv_vnode_t **vpp, 1794 xfs_inode_t **ipp,
1795 cred_t *credp) 1795 cred_t *credp)
1796{ 1796{
1797 char *name = VNAME(dentry); 1797 char *name = VNAME(dentry);
1798 xfs_mount_t *mp = dp->i_mount; 1798 xfs_mount_t *mp = dp->i_mount;
1799 bhv_vnode_t *dir_vp = XFS_ITOV(dp);
1800 xfs_inode_t *ip; 1799 xfs_inode_t *ip;
1801 bhv_vnode_t *vp = NULL;
1802 xfs_trans_t *tp; 1800 xfs_trans_t *tp;
1803 int error; 1801 int error;
1804 xfs_bmap_free_t free_list; 1802 xfs_bmap_free_t free_list;
@@ -1812,7 +1810,7 @@ xfs_create(
1812 uint resblks; 1810 uint resblks;
1813 int namelen; 1811 int namelen;
1814 1812
1815 ASSERT(!*vpp); 1813 ASSERT(!*ipp);
1816 xfs_itrace_entry(dp); 1814 xfs_itrace_entry(dp);
1817 1815
1818 namelen = VNAMELEN(dentry); 1816 namelen = VNAMELEN(dentry);
@@ -1911,7 +1909,7 @@ xfs_create(
1911 * the transaction cancel unlocking dp so don't do it explicitly in the 1909 * the transaction cancel unlocking dp so don't do it explicitly in the
1912 * error path. 1910 * error path.
1913 */ 1911 */
1914 VN_HOLD(dir_vp); 1912 IHOLD(dp);
1915 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); 1913 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
1916 unlock_dp_on_error = B_FALSE; 1914 unlock_dp_on_error = B_FALSE;
1917 1915
@@ -1949,7 +1947,6 @@ xfs_create(
1949 * vnode to the caller, we bump the vnode ref count now. 1947 * vnode to the caller, we bump the vnode ref count now.
1950 */ 1948 */
1951 IHOLD(ip); 1949 IHOLD(ip);
1952 vp = XFS_ITOV(ip);
1953 1950
1954 error = xfs_bmap_finish(&tp, &free_list, &committed); 1951 error = xfs_bmap_finish(&tp, &free_list, &committed);
1955 if (error) { 1952 if (error) {
@@ -1967,16 +1964,16 @@ xfs_create(
1967 XFS_QM_DQRELE(mp, udqp); 1964 XFS_QM_DQRELE(mp, udqp);
1968 XFS_QM_DQRELE(mp, gdqp); 1965 XFS_QM_DQRELE(mp, gdqp);
1969 1966
1970 *vpp = vp; 1967 *ipp = ip;
1971 1968
1972 /* Fallthrough to std_return with error = 0 */ 1969 /* Fallthrough to std_return with error = 0 */
1973 1970
1974std_return: 1971std_return:
1975 if ((*vpp || (error != 0 && dm_event_sent != 0)) && 1972 if ((*ipp || (error != 0 && dm_event_sent != 0)) &&
1976 DM_EVENT_ENABLED(dp, DM_EVENT_POSTCREATE)) { 1973 DM_EVENT_ENABLED(dp, DM_EVENT_POSTCREATE)) {
1977 (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTCREATE, 1974 (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTCREATE,
1978 dp, DM_RIGHT_NULL, 1975 dp, DM_RIGHT_NULL,
1979 *vpp ? ip : NULL, 1976 *ipp ? ip : NULL,
1980 DM_RIGHT_NULL, name, NULL, 1977 DM_RIGHT_NULL, name, NULL,
1981 mode, error, 0); 1978 mode, error, 0);
1982 } 1979 }
@@ -2634,15 +2631,13 @@ xfs_mkdir(
2634 xfs_inode_t *dp, 2631 xfs_inode_t *dp,
2635 bhv_vname_t *dentry, 2632 bhv_vname_t *dentry,
2636 mode_t mode, 2633 mode_t mode,
2637 bhv_vnode_t **vpp, 2634 xfs_inode_t **ipp,
2638 cred_t *credp) 2635 cred_t *credp)
2639{ 2636{
2640 bhv_vnode_t *dir_vp = XFS_ITOV(dp);
2641 char *dir_name = VNAME(dentry); 2637 char *dir_name = VNAME(dentry);
2642 int dir_namelen = VNAMELEN(dentry); 2638 int dir_namelen = VNAMELEN(dentry);
2643 xfs_mount_t *mp = dp->i_mount; 2639 xfs_mount_t *mp = dp->i_mount;
2644 xfs_inode_t *cdp; /* inode of created dir */ 2640 xfs_inode_t *cdp; /* inode of created dir */
2645 bhv_vnode_t *cvp; /* vnode of created dir */
2646 xfs_trans_t *tp; 2641 xfs_trans_t *tp;
2647 int cancel_flags; 2642 int cancel_flags;
2648 int error; 2643 int error;
@@ -2749,7 +2744,7 @@ xfs_mkdir(
2749 * from here on will result in the transaction cancel 2744 * from here on will result in the transaction cancel
2750 * unlocking dp so don't do it explicitly in the error path. 2745 * unlocking dp so don't do it explicitly in the error path.
2751 */ 2746 */
2752 VN_HOLD(dir_vp); 2747 IHOLD(dp);
2753 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); 2748 xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
2754 unlock_dp_on_error = B_FALSE; 2749 unlock_dp_on_error = B_FALSE;
2755 2750
@@ -2780,11 +2775,9 @@ xfs_mkdir(
2780 if (error) 2775 if (error)
2781 goto error2; 2776 goto error2;
2782 2777
2783 cvp = XFS_ITOV(cdp);
2784
2785 created = B_TRUE; 2778 created = B_TRUE;
2786 2779
2787 *vpp = cvp; 2780 *ipp = cdp;
2788 IHOLD(cdp); 2781 IHOLD(cdp);
2789 2782
2790 /* 2783 /*
diff --git a/fs/xfs/xfs_vnodeops.h b/fs/xfs/xfs_vnodeops.h
index 85340bafd42d..0acef1231417 100644
--- a/fs/xfs/xfs_vnodeops.h
+++ b/fs/xfs/xfs_vnodeops.h
@@ -26,12 +26,12 @@ int xfs_inactive(struct xfs_inode *ip);
26int xfs_lookup(struct xfs_inode *dp, bhv_vname_t *dentry, 26int xfs_lookup(struct xfs_inode *dp, bhv_vname_t *dentry,
27 bhv_vnode_t **vpp); 27 bhv_vnode_t **vpp);
28int xfs_create(struct xfs_inode *dp, bhv_vname_t *dentry, mode_t mode, 28int xfs_create(struct xfs_inode *dp, bhv_vname_t *dentry, mode_t mode,
29 xfs_dev_t rdev, bhv_vnode_t **vpp, struct cred *credp); 29 xfs_dev_t rdev, struct xfs_inode **ipp, struct cred *credp);
30int xfs_remove(struct xfs_inode *dp, bhv_vname_t *dentry); 30int xfs_remove(struct xfs_inode *dp, bhv_vname_t *dentry);
31int xfs_link(struct xfs_inode *tdp, bhv_vnode_t *src_vp, 31int xfs_link(struct xfs_inode *tdp, bhv_vnode_t *src_vp,
32 bhv_vname_t *dentry); 32 bhv_vname_t *dentry);
33int xfs_mkdir(struct xfs_inode *dp, bhv_vname_t *dentry, 33int xfs_mkdir(struct xfs_inode *dp, bhv_vname_t *dentry,
34 mode_t mode, bhv_vnode_t **vpp, struct cred *credp); 34 mode_t mode, struct xfs_inode **ipp, struct cred *credp);
35int xfs_rmdir(struct xfs_inode *dp, bhv_vname_t *dentry); 35int xfs_rmdir(struct xfs_inode *dp, bhv_vname_t *dentry);
36int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize, 36int 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);