[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>
This commit is contained in:
parent
a8b3acd57e
commit
43973964a3
@ -227,7 +227,7 @@ static inline bhv_vnode_t *vn_grab(bhv_vnode_t *vp)
|
|||||||
*/
|
*/
|
||||||
#define VNAME(dentry) ((char *) (dentry)->d_name.name)
|
#define VNAME(dentry) ((char *) (dentry)->d_name.name)
|
||||||
#define VNAMELEN(dentry) ((dentry)->d_name.len)
|
#define VNAMELEN(dentry) ((dentry)->d_name.len)
|
||||||
#define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode))
|
#define VNAME_TO_INODE(dentry) (XFS_I((dentry)->d_inode))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dealing with bad inodes
|
* Dealing with bad inodes
|
||||||
|
@ -93,7 +93,8 @@ xfs_lock_for_rename(
|
|||||||
xfs_inode_t **i_tab,/* array of inode returned, sorted */
|
xfs_inode_t **i_tab,/* array of inode returned, sorted */
|
||||||
int *num_inodes) /* number of inodes in array */
|
int *num_inodes) /* number of inodes in array */
|
||||||
{
|
{
|
||||||
xfs_inode_t *ip1, *ip2, *temp;
|
xfs_inode_t *ip1 = VNAME_TO_INODE(vname1);
|
||||||
|
xfs_inode_t *ip2, *temp;
|
||||||
xfs_ino_t inum1, inum2;
|
xfs_ino_t inum1, inum2;
|
||||||
int error;
|
int error;
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -109,16 +110,11 @@ xfs_lock_for_rename(
|
|||||||
* to see if we still have the right inodes, directories, etc.
|
* to see if we still have the right inodes, directories, etc.
|
||||||
*/
|
*/
|
||||||
lock_mode = xfs_ilock_map_shared(dp1);
|
lock_mode = xfs_ilock_map_shared(dp1);
|
||||||
error = xfs_get_dir_entry(vname1, &ip1);
|
IHOLD(ip1);
|
||||||
if (error) {
|
xfs_itrace_ref(ip1);
|
||||||
xfs_iunlock_map_shared(dp1, lock_mode);
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
inum1 = ip1->i_ino;
|
inum1 = ip1->i_ino;
|
||||||
|
|
||||||
ASSERT(ip1);
|
|
||||||
xfs_itrace_ref(ip1);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unlock dp1 and lock dp2 if they are different.
|
* Unlock dp1 and lock dp2 if they are different.
|
||||||
|
@ -40,28 +40,6 @@
|
|||||||
#include "xfs_itable.h"
|
#include "xfs_itable.h"
|
||||||
#include "xfs_utils.h"
|
#include "xfs_utils.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* xfs_get_dir_entry is used to get a reference to an inode given
|
|
||||||
* its parent directory inode and the name of the file. It does
|
|
||||||
* not lock the child inode, and it unlocks the directory before
|
|
||||||
* returning. The directory's generation number is returned for
|
|
||||||
* use by a later call to xfs_lock_dir_and_entry.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xfs_get_dir_entry(
|
|
||||||
bhv_vname_t *dentry,
|
|
||||||
xfs_inode_t **ipp)
|
|
||||||
{
|
|
||||||
bhv_vnode_t *vp;
|
|
||||||
|
|
||||||
vp = VNAME_TO_VNODE(dentry);
|
|
||||||
|
|
||||||
*ipp = xfs_vtoi(vp);
|
|
||||||
if (!*ipp)
|
|
||||||
return XFS_ERROR(ENOENT);
|
|
||||||
VN_HOLD(vp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
xfs_dir_lookup_int(
|
xfs_dir_lookup_int(
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#define IRELE(ip) VN_RELE(XFS_ITOV(ip))
|
#define IRELE(ip) VN_RELE(XFS_ITOV(ip))
|
||||||
#define IHOLD(ip) VN_HOLD(XFS_ITOV(ip))
|
#define IHOLD(ip) VN_HOLD(XFS_ITOV(ip))
|
||||||
|
|
||||||
extern int xfs_get_dir_entry (bhv_vname_t *, xfs_inode_t **);
|
|
||||||
extern int xfs_dir_lookup_int (xfs_inode_t *, uint, bhv_vname_t *, xfs_ino_t *,
|
extern int xfs_dir_lookup_int (xfs_inode_t *, uint, bhv_vname_t *, xfs_ino_t *,
|
||||||
xfs_inode_t **);
|
xfs_inode_t **);
|
||||||
extern int xfs_truncate_file (xfs_mount_t *, xfs_inode_t *);
|
extern int xfs_truncate_file (xfs_mount_t *, xfs_inode_t *);
|
||||||
|
@ -2270,41 +2270,30 @@ xfs_remove(
|
|||||||
bhv_vnode_t *dir_vp = XFS_ITOV(dp);
|
bhv_vnode_t *dir_vp = XFS_ITOV(dp);
|
||||||
char *name = VNAME(dentry);
|
char *name = VNAME(dentry);
|
||||||
xfs_mount_t *mp = dp->i_mount;
|
xfs_mount_t *mp = dp->i_mount;
|
||||||
xfs_inode_t *ip;
|
xfs_inode_t *ip = VNAME_TO_INODE(dentry);
|
||||||
|
int namelen = VNAMELEN(dentry);
|
||||||
xfs_trans_t *tp = NULL;
|
xfs_trans_t *tp = NULL;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
xfs_bmap_free_t free_list;
|
xfs_bmap_free_t free_list;
|
||||||
xfs_fsblock_t first_block;
|
xfs_fsblock_t first_block;
|
||||||
int cancel_flags;
|
int cancel_flags;
|
||||||
int committed;
|
int committed;
|
||||||
int dm_di_mode = 0;
|
|
||||||
int link_zero;
|
int link_zero;
|
||||||
uint resblks;
|
uint resblks;
|
||||||
int namelen;
|
|
||||||
|
|
||||||
xfs_itrace_entry(dp);
|
xfs_itrace_entry(dp);
|
||||||
|
|
||||||
if (XFS_FORCED_SHUTDOWN(mp))
|
if (XFS_FORCED_SHUTDOWN(mp))
|
||||||
return XFS_ERROR(EIO);
|
return XFS_ERROR(EIO);
|
||||||
|
|
||||||
namelen = VNAMELEN(dentry);
|
|
||||||
|
|
||||||
if (!xfs_get_dir_entry(dentry, &ip)) {
|
|
||||||
dm_di_mode = ip->i_d.di_mode;
|
|
||||||
IRELE(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
|
if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
|
||||||
error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dir_vp,
|
error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dir_vp,
|
||||||
DM_RIGHT_NULL, NULL, DM_RIGHT_NULL,
|
DM_RIGHT_NULL, NULL, DM_RIGHT_NULL,
|
||||||
name, NULL, dm_di_mode, 0, 0);
|
name, NULL, ip->i_d.di_mode, 0, 0);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* From this point on, return through std_return */
|
|
||||||
ip = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to get a reference to ip before we get our log
|
* We need to get a reference to ip before we get our log
|
||||||
* reservation. The reason for this is that we cannot call
|
* reservation. The reason for this is that we cannot call
|
||||||
@ -2317,13 +2306,7 @@ xfs_remove(
|
|||||||
* when we call xfs_iget. Instead we get an unlocked reference
|
* when we call xfs_iget. Instead we get an unlocked reference
|
||||||
* to the inode before getting our log reservation.
|
* to the inode before getting our log reservation.
|
||||||
*/
|
*/
|
||||||
error = xfs_get_dir_entry(dentry, &ip);
|
IHOLD(ip);
|
||||||
if (error) {
|
|
||||||
REMOVE_DEBUG_TRACE(__LINE__);
|
|
||||||
goto std_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dm_di_mode = ip->i_d.di_mode;
|
|
||||||
|
|
||||||
xfs_itrace_entry(ip);
|
xfs_itrace_entry(ip);
|
||||||
xfs_itrace_ref(ip);
|
xfs_itrace_ref(ip);
|
||||||
@ -2459,7 +2442,7 @@ xfs_remove(
|
|||||||
(void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
|
(void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
|
||||||
dir_vp, DM_RIGHT_NULL,
|
dir_vp, DM_RIGHT_NULL,
|
||||||
NULL, DM_RIGHT_NULL,
|
NULL, DM_RIGHT_NULL,
|
||||||
name, NULL, dm_di_mode, error, 0);
|
name, NULL, ip->i_d.di_mode, error, 0);
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@ -2868,14 +2851,13 @@ xfs_rmdir(
|
|||||||
char *name = VNAME(dentry);
|
char *name = VNAME(dentry);
|
||||||
int namelen = VNAMELEN(dentry);
|
int namelen = VNAMELEN(dentry);
|
||||||
xfs_mount_t *mp = dp->i_mount;
|
xfs_mount_t *mp = dp->i_mount;
|
||||||
xfs_inode_t *cdp; /* child directory */
|
xfs_inode_t *cdp = VNAME_TO_INODE(dentry);
|
||||||
xfs_trans_t *tp;
|
xfs_trans_t *tp;
|
||||||
int error;
|
int error;
|
||||||
xfs_bmap_free_t free_list;
|
xfs_bmap_free_t free_list;
|
||||||
xfs_fsblock_t first_block;
|
xfs_fsblock_t first_block;
|
||||||
int cancel_flags;
|
int cancel_flags;
|
||||||
int committed;
|
int committed;
|
||||||
int dm_di_mode = S_IFDIR;
|
|
||||||
int last_cdp_link;
|
int last_cdp_link;
|
||||||
uint resblks;
|
uint resblks;
|
||||||
|
|
||||||
@ -2884,24 +2866,15 @@ xfs_rmdir(
|
|||||||
if (XFS_FORCED_SHUTDOWN(mp))
|
if (XFS_FORCED_SHUTDOWN(mp))
|
||||||
return XFS_ERROR(EIO);
|
return XFS_ERROR(EIO);
|
||||||
|
|
||||||
if (!xfs_get_dir_entry(dentry, &cdp)) {
|
|
||||||
dm_di_mode = cdp->i_d.di_mode;
|
|
||||||
IRELE(cdp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
|
if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
|
||||||
error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE,
|
error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE,
|
||||||
dir_vp, DM_RIGHT_NULL,
|
dir_vp, DM_RIGHT_NULL,
|
||||||
NULL, DM_RIGHT_NULL,
|
NULL, DM_RIGHT_NULL,
|
||||||
name, NULL, dm_di_mode, 0, 0);
|
name, NULL, cdp->i_d.di_mode, 0, 0);
|
||||||
if (error)
|
if (error)
|
||||||
return XFS_ERROR(error);
|
return XFS_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return through std_return after this point. */
|
|
||||||
|
|
||||||
cdp = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to get a reference to cdp before we get our log
|
* We need to get a reference to cdp before we get our log
|
||||||
* reservation. The reason for this is that we cannot call
|
* reservation. The reason for this is that we cannot call
|
||||||
@ -2914,13 +2887,7 @@ xfs_rmdir(
|
|||||||
* when we call xfs_iget. Instead we get an unlocked reference
|
* when we call xfs_iget. Instead we get an unlocked reference
|
||||||
* to the inode before getting our log reservation.
|
* to the inode before getting our log reservation.
|
||||||
*/
|
*/
|
||||||
error = xfs_get_dir_entry(dentry, &cdp);
|
IHOLD(cdp);
|
||||||
if (error) {
|
|
||||||
REMOVE_DEBUG_TRACE(__LINE__);
|
|
||||||
goto std_return;
|
|
||||||
}
|
|
||||||
mp = dp->i_mount;
|
|
||||||
dm_di_mode = cdp->i_d.di_mode;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the dquots for the inodes.
|
* Get the dquots for the inodes.
|
||||||
@ -3077,7 +3044,7 @@ xfs_rmdir(
|
|||||||
(void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
|
(void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
|
||||||
dir_vp, DM_RIGHT_NULL,
|
dir_vp, DM_RIGHT_NULL,
|
||||||
NULL, DM_RIGHT_NULL,
|
NULL, DM_RIGHT_NULL,
|
||||||
name, NULL, dm_di_mode,
|
name, NULL, cdp->i_d.di_mode,
|
||||||
error, 0);
|
error, 0);
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
|
Loading…
Reference in New Issue
Block a user