aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h2
-rw-r--r--fs/xfs/xfs_rename.c12
-rw-r--r--fs/xfs/xfs_utils.c22
-rw-r--r--fs/xfs/xfs_utils.h1
-rw-r--r--fs/xfs/xfs_vnodeops.c51
5 files changed, 14 insertions, 74 deletions
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index f200e0244082..202231828283 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -227,7 +227,7 @@ static inline bhv_vnode_t *vn_grab(bhv_vnode_t *vp)
227 */ 227 */
228#define VNAME(dentry) ((char *) (dentry)->d_name.name) 228#define VNAME(dentry) ((char *) (dentry)->d_name.name)
229#define VNAMELEN(dentry) ((dentry)->d_name.len) 229#define VNAMELEN(dentry) ((dentry)->d_name.len)
230#define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode)) 230#define VNAME_TO_INODE(dentry) (XFS_I((dentry)->d_inode))
231 231
232/* 232/*
233 * Dealing with bad inodes 233 * Dealing with bad inodes
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c
index 1c6d40ed6816..fd1244cf50a7 100644
--- a/fs/xfs/xfs_rename.c
+++ b/fs/xfs/xfs_rename.c
@@ -93,7 +93,8 @@ xfs_lock_for_rename(
93 xfs_inode_t **i_tab,/* array of inode returned, sorted */ 93 xfs_inode_t **i_tab,/* array of inode returned, sorted */
94 int *num_inodes) /* number of inodes in array */ 94 int *num_inodes) /* number of inodes in array */
95{ 95{
96 xfs_inode_t *ip1, *ip2, *temp; 96 xfs_inode_t *ip1 = VNAME_TO_INODE(vname1);
97 xfs_inode_t *ip2, *temp;
97 xfs_ino_t inum1, inum2; 98 xfs_ino_t inum1, inum2;
98 int error; 99 int error;
99 int i, j; 100 int i, j;
@@ -109,16 +110,11 @@ xfs_lock_for_rename(
109 * to see if we still have the right inodes, directories, etc. 110 * to see if we still have the right inodes, directories, etc.
110 */ 111 */
111 lock_mode = xfs_ilock_map_shared(dp1); 112 lock_mode = xfs_ilock_map_shared(dp1);
112 error = xfs_get_dir_entry(vname1, &ip1); 113 IHOLD(ip1);
113 if (error) { 114 xfs_itrace_ref(ip1);
114 xfs_iunlock_map_shared(dp1, lock_mode);
115 return error;
116 }
117 115
118 inum1 = ip1->i_ino; 116 inum1 = ip1->i_ino;
119 117
120 ASSERT(ip1);
121 xfs_itrace_ref(ip1);
122 118
123 /* 119 /*
124 * Unlock dp1 and lock dp2 if they are different. 120 * Unlock dp1 and lock dp2 if they are different.
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c
index 18a85e746680..47c45ff4a067 100644
--- a/fs/xfs/xfs_utils.c
+++ b/fs/xfs/xfs_utils.c
@@ -40,28 +40,6 @@
40#include "xfs_itable.h" 40#include "xfs_itable.h"
41#include "xfs_utils.h" 41#include "xfs_utils.h"
42 42
43/*
44 * xfs_get_dir_entry is used to get a reference to an inode given
45 * its parent directory inode and the name of the file. It does
46 * not lock the child inode, and it unlocks the directory before
47 * returning. The directory's generation number is returned for
48 * use by a later call to xfs_lock_dir_and_entry.
49 */
50int
51xfs_get_dir_entry(
52 bhv_vname_t *dentry,
53 xfs_inode_t **ipp)
54{
55 bhv_vnode_t *vp;
56
57 vp = VNAME_TO_VNODE(dentry);
58
59 *ipp = xfs_vtoi(vp);
60 if (!*ipp)
61 return XFS_ERROR(ENOENT);
62 VN_HOLD(vp);
63 return 0;
64}
65 43
66int 44int
67xfs_dir_lookup_int( 45xfs_dir_lookup_int(
diff --git a/fs/xfs/xfs_utils.h b/fs/xfs/xfs_utils.h
index f857fcccb723..c4c4a6aa6549 100644
--- a/fs/xfs/xfs_utils.h
+++ b/fs/xfs/xfs_utils.h
@@ -21,7 +21,6 @@
21#define IRELE(ip) VN_RELE(XFS_ITOV(ip)) 21#define IRELE(ip) VN_RELE(XFS_ITOV(ip))
22#define IHOLD(ip) VN_HOLD(XFS_ITOV(ip)) 22#define IHOLD(ip) VN_HOLD(XFS_ITOV(ip))
23 23
24extern int xfs_get_dir_entry (bhv_vname_t *, xfs_inode_t **);
25extern int xfs_dir_lookup_int (xfs_inode_t *, uint, bhv_vname_t *, xfs_ino_t *, 24extern int xfs_dir_lookup_int (xfs_inode_t *, uint, bhv_vname_t *, xfs_ino_t *,
26 xfs_inode_t **); 25 xfs_inode_t **);
27extern int xfs_truncate_file (xfs_mount_t *, xfs_inode_t *); 26extern int xfs_truncate_file (xfs_mount_t *, xfs_inode_t *);
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 5390d124ad35..4765e7c4b75d 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -2270,41 +2270,30 @@ xfs_remove(
2270 bhv_vnode_t *dir_vp = XFS_ITOV(dp); 2270 bhv_vnode_t *dir_vp = XFS_ITOV(dp);
2271 char *name = VNAME(dentry); 2271 char *name = VNAME(dentry);
2272 xfs_mount_t *mp = dp->i_mount; 2272 xfs_mount_t *mp = dp->i_mount;
2273 xfs_inode_t *ip; 2273 xfs_inode_t *ip = VNAME_TO_INODE(dentry);
2274 int namelen = VNAMELEN(dentry);
2274 xfs_trans_t *tp = NULL; 2275 xfs_trans_t *tp = NULL;
2275 int error = 0; 2276 int error = 0;
2276 xfs_bmap_free_t free_list; 2277 xfs_bmap_free_t free_list;
2277 xfs_fsblock_t first_block; 2278 xfs_fsblock_t first_block;
2278 int cancel_flags; 2279 int cancel_flags;
2279 int committed; 2280 int committed;
2280 int dm_di_mode = 0;
2281 int link_zero; 2281 int link_zero;
2282 uint resblks; 2282 uint resblks;
2283 int namelen;
2284 2283
2285 xfs_itrace_entry(dp); 2284 xfs_itrace_entry(dp);
2286 2285
2287 if (XFS_FORCED_SHUTDOWN(mp)) 2286 if (XFS_FORCED_SHUTDOWN(mp))
2288 return XFS_ERROR(EIO); 2287 return XFS_ERROR(EIO);
2289 2288
2290 namelen = VNAMELEN(dentry);
2291
2292 if (!xfs_get_dir_entry(dentry, &ip)) {
2293 dm_di_mode = ip->i_d.di_mode;
2294 IRELE(ip);
2295 }
2296
2297 if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) { 2289 if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
2298 error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dir_vp, 2290 error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dir_vp,
2299 DM_RIGHT_NULL, NULL, DM_RIGHT_NULL, 2291 DM_RIGHT_NULL, NULL, DM_RIGHT_NULL,
2300 name, NULL, dm_di_mode, 0, 0); 2292 name, NULL, ip->i_d.di_mode, 0, 0);
2301 if (error) 2293 if (error)
2302 return error; 2294 return error;
2303 } 2295 }
2304 2296
2305 /* From this point on, return through std_return */
2306 ip = NULL;
2307
2308 /* 2297 /*
2309 * We need to get a reference to ip before we get our log 2298 * We need to get a reference to ip before we get our log
2310 * reservation. The reason for this is that we cannot call 2299 * reservation. The reason for this is that we cannot call
@@ -2317,13 +2306,7 @@ xfs_remove(
2317 * when we call xfs_iget. Instead we get an unlocked reference 2306 * when we call xfs_iget. Instead we get an unlocked reference
2318 * to the inode before getting our log reservation. 2307 * to the inode before getting our log reservation.
2319 */ 2308 */
2320 error = xfs_get_dir_entry(dentry, &ip); 2309 IHOLD(ip);
2321 if (error) {
2322 REMOVE_DEBUG_TRACE(__LINE__);
2323 goto std_return;
2324 }
2325
2326 dm_di_mode = ip->i_d.di_mode;
2327 2310
2328 xfs_itrace_entry(ip); 2311 xfs_itrace_entry(ip);
2329 xfs_itrace_ref(ip); 2312 xfs_itrace_ref(ip);
@@ -2459,7 +2442,7 @@ xfs_remove(
2459 (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE, 2442 (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
2460 dir_vp, DM_RIGHT_NULL, 2443 dir_vp, DM_RIGHT_NULL,
2461 NULL, DM_RIGHT_NULL, 2444 NULL, DM_RIGHT_NULL,
2462 name, NULL, dm_di_mode, error, 0); 2445 name, NULL, ip->i_d.di_mode, error, 0);
2463 } 2446 }
2464 return error; 2447 return error;
2465 2448
@@ -2868,14 +2851,13 @@ xfs_rmdir(
2868 char *name = VNAME(dentry); 2851 char *name = VNAME(dentry);
2869 int namelen = VNAMELEN(dentry); 2852 int namelen = VNAMELEN(dentry);
2870 xfs_mount_t *mp = dp->i_mount; 2853 xfs_mount_t *mp = dp->i_mount;
2871 xfs_inode_t *cdp; /* child directory */ 2854 xfs_inode_t *cdp = VNAME_TO_INODE(dentry);
2872 xfs_trans_t *tp; 2855 xfs_trans_t *tp;
2873 int error; 2856 int error;
2874 xfs_bmap_free_t free_list; 2857 xfs_bmap_free_t free_list;
2875 xfs_fsblock_t first_block; 2858 xfs_fsblock_t first_block;
2876 int cancel_flags; 2859 int cancel_flags;
2877 int committed; 2860 int committed;
2878 int dm_di_mode = S_IFDIR;
2879 int last_cdp_link; 2861 int last_cdp_link;
2880 uint resblks; 2862 uint resblks;
2881 2863
@@ -2884,24 +2866,15 @@ xfs_rmdir(
2884 if (XFS_FORCED_SHUTDOWN(mp)) 2866 if (XFS_FORCED_SHUTDOWN(mp))
2885 return XFS_ERROR(EIO); 2867 return XFS_ERROR(EIO);
2886 2868
2887 if (!xfs_get_dir_entry(dentry, &cdp)) {
2888 dm_di_mode = cdp->i_d.di_mode;
2889 IRELE(cdp);
2890 }
2891
2892 if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) { 2869 if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
2893 error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, 2870 error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE,
2894 dir_vp, DM_RIGHT_NULL, 2871 dir_vp, DM_RIGHT_NULL,
2895 NULL, DM_RIGHT_NULL, 2872 NULL, DM_RIGHT_NULL,
2896 name, NULL, dm_di_mode, 0, 0); 2873 name, NULL, cdp->i_d.di_mode, 0, 0);
2897 if (error) 2874 if (error)
2898 return XFS_ERROR(error); 2875 return XFS_ERROR(error);
2899 } 2876 }
2900 2877
2901 /* Return through std_return after this point. */
2902
2903 cdp = NULL;
2904
2905 /* 2878 /*
2906 * We need to get a reference to cdp before we get our log 2879 * We need to get a reference to cdp before we get our log
2907 * reservation. The reason for this is that we cannot call 2880 * reservation. The reason for this is that we cannot call
@@ -2914,13 +2887,7 @@ xfs_rmdir(
2914 * when we call xfs_iget. Instead we get an unlocked reference 2887 * when we call xfs_iget. Instead we get an unlocked reference
2915 * to the inode before getting our log reservation. 2888 * to the inode before getting our log reservation.
2916 */ 2889 */
2917 error = xfs_get_dir_entry(dentry, &cdp); 2890 IHOLD(cdp);
2918 if (error) {
2919 REMOVE_DEBUG_TRACE(__LINE__);
2920 goto std_return;
2921 }
2922 mp = dp->i_mount;
2923 dm_di_mode = cdp->i_d.di_mode;
2924 2891
2925 /* 2892 /*
2926 * Get the dquots for the inodes. 2893 * Get the dquots for the inodes.
@@ -3077,7 +3044,7 @@ xfs_rmdir(
3077 (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE, 3044 (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
3078 dir_vp, DM_RIGHT_NULL, 3045 dir_vp, DM_RIGHT_NULL,
3079 NULL, DM_RIGHT_NULL, 3046 NULL, DM_RIGHT_NULL,
3080 name, NULL, dm_di_mode, 3047 name, NULL, cdp->i_d.di_mode,
3081 error, 0); 3048 error, 0);
3082 } 3049 }
3083 return error; 3050 return error;