Commit 43973964a386348af0a392266f008ba24170aa30

Authored by Christoph Hellwig
Committed by Lachlan McIlroy
1 parent a8b3acd57e

[XFS] kill xfs_get_dir_entry

Instead of of xfs_get_dir_entry use a macro to get the xfs_inode from the
dentry in the callers and grab the reference manually.

Only grab the reference once as it's fine to keep it over the dmapi calls.
(And even that reference is actually superflous in Linux but I'll leave
that for another patch)

SGI-PV: 976035
SGI-Modid: xfs-linux-melb:xfs-kern:30531a

Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>

Showing 5 changed files with 14 additions and 74 deletions Side-by-side Diff

fs/xfs/linux-2.6/xfs_vnode.h
... ... @@ -227,7 +227,7 @@
227 227 */
228 228 #define VNAME(dentry) ((char *) (dentry)->d_name.name)
229 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 233 * Dealing with bad inodes
... ... @@ -93,7 +93,8 @@
93 93 xfs_inode_t **i_tab,/* array of inode returned, sorted */
94 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 98 xfs_ino_t inum1, inum2;
98 99 int error;
99 100 int i, j;
100 101  
... ... @@ -109,16 +110,11 @@
109 110 * to see if we still have the right inodes, directories, etc.
110 111 */
111 112 lock_mode = xfs_ilock_map_shared(dp1);
112   - error = xfs_get_dir_entry(vname1, &ip1);
113   - if (error) {
114   - xfs_iunlock_map_shared(dp1, lock_mode);
115   - return error;
116   - }
  113 + IHOLD(ip1);
  114 + xfs_itrace_ref(ip1);
117 115  
118 116 inum1 = ip1->i_ino;
119 117  
120   - ASSERT(ip1);
121   - xfs_itrace_ref(ip1);
122 118  
123 119 /*
124 120 * Unlock dp1 and lock dp2 if they are different.
... ... @@ -40,28 +40,6 @@
40 40 #include "xfs_itable.h"
41 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   - */
50   -int
51   -xfs_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  
66 44 int
67 45 xfs_dir_lookup_int(
... ... @@ -21,7 +21,6 @@
21 21 #define IRELE(ip) VN_RELE(XFS_ITOV(ip))
22 22 #define IHOLD(ip) VN_HOLD(XFS_ITOV(ip))
23 23  
24   -extern int xfs_get_dir_entry (bhv_vname_t *, xfs_inode_t **);
25 24 extern int xfs_dir_lookup_int (xfs_inode_t *, uint, bhv_vname_t *, xfs_ino_t *,
26 25 xfs_inode_t **);
27 26 extern int xfs_truncate_file (xfs_mount_t *, xfs_inode_t *);
fs/xfs/xfs_vnodeops.c
... ... @@ -2270,41 +2270,30 @@
2270 2270 bhv_vnode_t *dir_vp = XFS_ITOV(dp);
2271 2271 char *name = VNAME(dentry);
2272 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 2275 xfs_trans_t *tp = NULL;
2275 2276 int error = 0;
2276 2277 xfs_bmap_free_t free_list;
2277 2278 xfs_fsblock_t first_block;
2278 2279 int cancel_flags;
2279 2280 int committed;
2280   - int dm_di_mode = 0;
2281 2281 int link_zero;
2282 2282 uint resblks;
2283   - int namelen;
2284 2283  
2285 2284 xfs_itrace_entry(dp);
2286 2285  
2287 2286 if (XFS_FORCED_SHUTDOWN(mp))
2288 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 2289 if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
2298 2290 error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dir_vp,
2299 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 2293 if (error)
2302 2294 return error;
2303 2295 }
2304 2296  
2305   - /* From this point on, return through std_return */
2306   - ip = NULL;
2307   -
2308 2297 /*
2309 2298 * We need to get a reference to ip before we get our log
2310 2299 * reservation. The reason for this is that we cannot call
2311 2300  
... ... @@ -2317,14 +2306,8 @@
2317 2306 * when we call xfs_iget. Instead we get an unlocked reference
2318 2307 * to the inode before getting our log reservation.
2319 2308 */
2320   - error = xfs_get_dir_entry(dentry, &ip);
2321   - if (error) {
2322   - REMOVE_DEBUG_TRACE(__LINE__);
2323   - goto std_return;
2324   - }
  2309 + IHOLD(ip);
2325 2310  
2326   - dm_di_mode = ip->i_d.di_mode;
2327   -
2328 2311 xfs_itrace_entry(ip);
2329 2312 xfs_itrace_ref(ip);
2330 2313  
... ... @@ -2459,7 +2442,7 @@
2459 2442 (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
2460 2443 dir_vp, DM_RIGHT_NULL,
2461 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 2447 return error;
2465 2448  
2466 2449  
... ... @@ -2868,14 +2851,13 @@
2868 2851 char *name = VNAME(dentry);
2869 2852 int namelen = VNAMELEN(dentry);
2870 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 2855 xfs_trans_t *tp;
2873 2856 int error;
2874 2857 xfs_bmap_free_t free_list;
2875 2858 xfs_fsblock_t first_block;
2876 2859 int cancel_flags;
2877 2860 int committed;
2878   - int dm_di_mode = S_IFDIR;
2879 2861 int last_cdp_link;
2880 2862 uint resblks;
2881 2863  
2882 2864  
2883 2865  
... ... @@ -2884,24 +2866,15 @@
2884 2866 if (XFS_FORCED_SHUTDOWN(mp))
2885 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 2869 if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
2893 2870 error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE,
2894 2871 dir_vp, DM_RIGHT_NULL,
2895 2872 NULL, DM_RIGHT_NULL,
2896   - name, NULL, dm_di_mode, 0, 0);
  2873 + name, NULL, cdp->i_d.di_mode, 0, 0);
2897 2874 if (error)
2898 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 2879 * We need to get a reference to cdp before we get our log
2907 2880 * reservation. The reason for this is that we cannot call
... ... @@ -2914,13 +2887,7 @@
2914 2887 * when we call xfs_iget. Instead we get an unlocked reference
2915 2888 * to the inode before getting our log reservation.
2916 2889 */
2917   - error = xfs_get_dir_entry(dentry, &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;
  2890 + IHOLD(cdp);
2924 2891  
2925 2892 /*
2926 2893 * Get the dquots for the inodes.
... ... @@ -3077,7 +3044,7 @@
3077 3044 (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
3078 3045 dir_vp, DM_RIGHT_NULL,
3079 3046 NULL, DM_RIGHT_NULL,
3080   - name, NULL, dm_di_mode,
  3047 + name, NULL, cdp->i_d.di_mode,
3081 3048 error, 0);
3082 3049 }
3083 3050 return error;