[XFS] replace vn_get usage by ihold
SGI-PV: 938306 SGI-Modid: xfs-linux:xfs-kern:194627a Signed-off-by: Christoph Hellwig <hch@sgi.com> Signed-off-by: Nathan Scott <nathans@sgi.com>
This commit is contained in:
parent
bb3f724e12
commit
cdb626878f
@ -162,30 +162,6 @@ vn_initialize(
|
||||
return vp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a reference on a vnode.
|
||||
*/
|
||||
vnode_t *
|
||||
vn_get(
|
||||
struct vnode *vp,
|
||||
vmap_t *vmap)
|
||||
{
|
||||
struct inode *inode;
|
||||
|
||||
XFS_STATS_INC(vn_get);
|
||||
inode = LINVFS_GET_IP(vp);
|
||||
if (inode->i_state & I_FREEING)
|
||||
return NULL;
|
||||
|
||||
inode = ilookup(vmap->v_vfsp->vfs_super, vmap->v_ino);
|
||||
if (!inode) /* Inode not present */
|
||||
return NULL;
|
||||
|
||||
vn_trace_exit(vp, "vn_get", (inst_t *)__return_address);
|
||||
|
||||
return vp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Revalidate the Linux inode from the vattr.
|
||||
* Note: i_size _not_ updated; we must hold the inode
|
||||
|
@ -504,20 +504,6 @@ extern void vn_init(void);
|
||||
extern int vn_wait(struct vnode *);
|
||||
extern vnode_t *vn_initialize(struct inode *);
|
||||
|
||||
/*
|
||||
* Acquiring and invalidating vnodes:
|
||||
*
|
||||
* if (vn_get(vp, version, 0))
|
||||
* ...;
|
||||
* vn_purge(vp, version);
|
||||
*
|
||||
* vn_get and vn_purge must be called with vmap_t arguments, sampled
|
||||
* while a lock that the vnode's VOP_RECLAIM function acquires is
|
||||
* held, to ensure that the vnode sampled with the lock held isn't
|
||||
* recycled (VOP_RECLAIMed) or deallocated between the release of the lock
|
||||
* and the subsequent vn_get or vn_purge.
|
||||
*/
|
||||
|
||||
/*
|
||||
* vnode_map structures _must_ match vn_epoch and vnode structure sizes.
|
||||
*/
|
||||
@ -532,7 +518,6 @@ typedef struct vnode_map {
|
||||
(vmap).v_ino = (vp)->v_inode.i_ino; }
|
||||
|
||||
extern void vn_purge(struct vnode *, vmap_t *);
|
||||
extern vnode_t *vn_get(struct vnode *, vmap_t *);
|
||||
extern int vn_revalidate(struct vnode *);
|
||||
extern void vn_revalidate_core(struct vnode *, vattr_t *);
|
||||
extern void vn_remove(struct vnode *);
|
||||
@ -560,6 +545,12 @@ extern void vn_rele(struct vnode *);
|
||||
#define VN_RELE(vp) (iput(LINVFS_GET_IP(vp)))
|
||||
#endif
|
||||
|
||||
static inline struct vnode *vn_grab(struct vnode *vp)
|
||||
{
|
||||
struct inode *inode = igrab(LINVFS_GET_IP(vp));
|
||||
return inode ? LINVFS_GET_VP(inode) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Vname handling macros.
|
||||
*/
|
||||
|
@ -1053,7 +1053,6 @@ xfs_qm_dqrele_all_inodes(
|
||||
struct xfs_mount *mp,
|
||||
uint flags)
|
||||
{
|
||||
vmap_t vmap;
|
||||
xfs_inode_t *ip, *topino;
|
||||
uint ireclaims;
|
||||
vnode_t *vp;
|
||||
@ -1061,8 +1060,8 @@ xfs_qm_dqrele_all_inodes(
|
||||
|
||||
ASSERT(mp->m_quotainfo);
|
||||
|
||||
again:
|
||||
XFS_MOUNT_ILOCK(mp);
|
||||
again:
|
||||
ip = mp->m_inodes;
|
||||
if (ip == NULL) {
|
||||
XFS_MOUNT_IUNLOCK(mp);
|
||||
@ -1090,18 +1089,14 @@ again:
|
||||
}
|
||||
vnode_refd = B_FALSE;
|
||||
if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) {
|
||||
/*
|
||||
* Sample vp mapping while holding the mplock, lest
|
||||
* we come across a non-existent vnode.
|
||||
*/
|
||||
VMAP(vp, vmap);
|
||||
ireclaims = mp->m_ireclaims;
|
||||
topino = mp->m_inodes;
|
||||
XFS_MOUNT_IUNLOCK(mp);
|
||||
|
||||
/* XXX restart limit ? */
|
||||
if ( ! (vp = vn_get(vp, &vmap)))
|
||||
vp = vn_grab(vp);
|
||||
if (!vp)
|
||||
goto again;
|
||||
|
||||
XFS_MOUNT_IUNLOCK(mp);
|
||||
/* XXX restart limit ? */
|
||||
xfs_ilock(ip, XFS_ILOCK_EXCL);
|
||||
vnode_refd = B_TRUE;
|
||||
} else {
|
||||
@ -1137,7 +1132,6 @@ again:
|
||||
*/
|
||||
if (topino != mp->m_inodes || mp->m_ireclaims != ireclaims) {
|
||||
/* XXX use a sentinel */
|
||||
XFS_MOUNT_IUNLOCK(mp);
|
||||
goto again;
|
||||
}
|
||||
ip = ip->i_mnext;
|
||||
|
@ -906,7 +906,6 @@ xfs_sync_inodes(
|
||||
xfs_inode_t *ip_next;
|
||||
xfs_buf_t *bp;
|
||||
vnode_t *vp = NULL;
|
||||
vmap_t vmap;
|
||||
int error;
|
||||
int last_error;
|
||||
uint64_t fflag;
|
||||
@ -1101,48 +1100,21 @@ xfs_sync_inodes(
|
||||
* lock in xfs_ireclaim() after the inode is pulled from
|
||||
* the mount list will sleep until we release it here.
|
||||
* This keeps the vnode from being freed while we reference
|
||||
* it. It is also cheaper and simpler than actually doing
|
||||
* a vn_get() for every inode we touch here.
|
||||
* it.
|
||||
*/
|
||||
if (xfs_ilock_nowait(ip, lock_flags) == 0) {
|
||||
|
||||
if ((flags & SYNC_BDFLUSH) || (vp == NULL)) {
|
||||
ip = ip->i_mnext;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* We need to unlock the inode list lock in order
|
||||
* to lock the inode. Insert a marker record into
|
||||
* the inode list to remember our position, dropping
|
||||
* the lock is now done inside the IPOINTER_INSERT
|
||||
* macro.
|
||||
*
|
||||
* We also use the inode list lock to protect us
|
||||
* in taking a snapshot of the vnode version number
|
||||
* for use in calling vn_get().
|
||||
*/
|
||||
VMAP(vp, vmap);
|
||||
IPOINTER_INSERT(ip, mp);
|
||||
|
||||
vp = vn_get(vp, &vmap);
|
||||
vp = vn_grab(vp);
|
||||
if (vp == NULL) {
|
||||
/*
|
||||
* The vnode was reclaimed once we let go
|
||||
* of the inode list lock. Skip to the
|
||||
* next list entry. Remove the marker.
|
||||
*/
|
||||
|
||||
XFS_MOUNT_ILOCK(mp);
|
||||
|
||||
mount_locked = B_TRUE;
|
||||
vnode_refed = B_FALSE;
|
||||
|
||||
IPOINTER_REMOVE(ip, mp);
|
||||
|
||||
ip = ip->i_mnext;
|
||||
continue;
|
||||
}
|
||||
|
||||
IPOINTER_INSERT(ip, mp);
|
||||
xfs_ilock(ip, lock_flags);
|
||||
|
||||
ASSERT(vp == XFS_ITOV(ip));
|
||||
|
Loading…
Reference in New Issue
Block a user