Browse Source

[XFS] cleanup vnode useage in xfs_iget.c

Get rid of vnode useage in xfs_iget.c and pass Linux inode / xfs_inode
where apropinquate. And kill some useless helpers while we're at it.

SGI-PV: 971186
SGI-Modid: xfs-linux-melb:xfs-kern:29808a

Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>
Christoph Hellwig 17 years ago
parent
commit
10090be25c
4 changed files with 65 additions and 98 deletions
  1. 0 14
      fs/xfs/linux-2.6/xfs_vnode.c
  2. 0 6
      fs/xfs/linux-2.6/xfs_vnode.h
  3. 65 77
      fs/xfs/xfs_iget.c
  4. 0 1
      fs/xfs/xfs_inode.h

+ 0 - 14
fs/xfs/linux-2.6/xfs_vnode.c

@@ -82,20 +82,6 @@ vn_ioerror(
 		xfs_do_force_shutdown(ip->i_mount, SHUTDOWN_DEVICE_REQ, f, l);
 		xfs_do_force_shutdown(ip->i_mount, SHUTDOWN_DEVICE_REQ, f, l);
 }
 }
 
 
-bhv_vnode_t *
-vn_initialize(
-	struct inode	*inode)
-{
-	bhv_vnode_t	*vp = vn_from_inode(inode);
-
-	XFS_STATS_INC(vn_active);
-	XFS_STATS_INC(vn_alloc);
-
-	ASSERT(VN_CACHED(vp) == 0);
-
-	return vp;
-}
-
 /*
 /*
  * Revalidate the Linux inode from the XFS inode.
  * Revalidate the Linux inode from the XFS inode.
  * Note: i_size _not_ updated; we must hold the inode
  * Note: i_size _not_ updated; we must hold the inode

+ 0 - 6
fs/xfs/linux-2.6/xfs_vnode.h

@@ -187,7 +187,6 @@ typedef struct bhv_vattr {
 	(VN_ISREG(vp) && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)
 	(VN_ISREG(vp) && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)
 
 
 extern void	vn_init(void);
 extern void	vn_init(void);
-extern bhv_vnode_t	*vn_initialize(struct inode *);
 extern int	vn_revalidate(bhv_vnode_t *);
 extern int	vn_revalidate(bhv_vnode_t *);
 
 
 /*
 /*
@@ -236,11 +235,6 @@ static inline bhv_vnode_t *vn_grab(bhv_vnode_t *vp)
 /*
 /*
  * Dealing with bad inodes
  * Dealing with bad inodes
  */
  */
-static inline void vn_mark_bad(bhv_vnode_t *vp)
-{
-	make_bad_inode(vn_to_inode(vp));
-}
-
 static inline int VN_BAD(bhv_vnode_t *vp)
 static inline int VN_BAD(bhv_vnode_t *vp)
 {
 {
 	return is_bad_inode(vn_to_inode(vp));
 	return is_bad_inode(vn_to_inode(vp));

+ 65 - 77
fs/xfs/xfs_iget.c

@@ -65,7 +65,7 @@
  */
  */
 STATIC int
 STATIC int
 xfs_iget_core(
 xfs_iget_core(
-	bhv_vnode_t	*vp,
+	struct inode	*inode,
 	xfs_mount_t	*mp,
 	xfs_mount_t	*mp,
 	xfs_trans_t	*tp,
 	xfs_trans_t	*tp,
 	xfs_ino_t	ino,
 	xfs_ino_t	ino,
@@ -74,9 +74,9 @@ xfs_iget_core(
 	xfs_inode_t	**ipp,
 	xfs_inode_t	**ipp,
 	xfs_daddr_t	bno)
 	xfs_daddr_t	bno)
 {
 {
+	struct inode	*old_inode;
 	xfs_inode_t	*ip;
 	xfs_inode_t	*ip;
 	xfs_inode_t	*iq;
 	xfs_inode_t	*iq;
-	bhv_vnode_t	*inode_vp;
 	int		error;
 	int		error;
 	xfs_icluster_t	*icl, *new_icl = NULL;
 	xfs_icluster_t	*icl, *new_icl = NULL;
 	unsigned long	first_index, mask;
 	unsigned long	first_index, mask;
@@ -111,8 +111,8 @@ again:
 			goto again;
 			goto again;
 		}
 		}
 
 
-		inode_vp = XFS_ITOV_NULL(ip);
-		if (inode_vp == NULL) {
+		old_inode = ip->i_vnode;
+		if (old_inode == NULL) {
 			/*
 			/*
 			 * If IRECLAIM is set this inode is
 			 * If IRECLAIM is set this inode is
 			 * on its way out of the system,
 			 * on its way out of the system,
@@ -170,13 +170,11 @@ again:
 
 
 			goto finish_inode;
 			goto finish_inode;
 
 
-		} else if (vp != inode_vp) {
-			struct inode *inode = vn_to_inode(inode_vp);
-
+		} else if (inode != old_inode) {
 			/* The inode is being torn down, pause and
 			/* The inode is being torn down, pause and
 			 * try again.
 			 * try again.
 			 */
 			 */
-			if (inode->i_state & (I_FREEING | I_CLEAR)) {
+			if (old_inode->i_state & (I_FREEING | I_CLEAR)) {
 				read_unlock(&pag->pag_ici_lock);
 				read_unlock(&pag->pag_ici_lock);
 				delay(1);
 				delay(1);
 				XFS_STATS_INC(xs_ig_frecycle);
 				XFS_STATS_INC(xs_ig_frecycle);
@@ -189,7 +187,7 @@ again:
 */
 */
 			cmn_err(CE_PANIC,
 			cmn_err(CE_PANIC,
 		"xfs_iget_core: ambiguous vns: vp/0x%p, invp/0x%p",
 		"xfs_iget_core: ambiguous vns: vp/0x%p, invp/0x%p",
-					inode_vp, vp);
+					old_inode, inode);
 		}
 		}
 
 
 		/*
 		/*
@@ -231,7 +229,14 @@ finish_inode:
 
 
 	xfs_itrace_exit_tag(ip, "xfs_iget.alloc");
 	xfs_itrace_exit_tag(ip, "xfs_iget.alloc");
 
 
-	xfs_inode_lock_init(ip, vp);
+
+	mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
+		     "xfsino", ip->i_ino);
+	mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino);
+	init_waitqueue_head(&ip->i_ipin_wait);
+	atomic_set(&ip->i_pincount, 0);
+	initnsema(&ip->i_flock, 1, "xfsfino");
+
 	if (lock_flags)
 	if (lock_flags)
 		xfs_ilock(ip, lock_flags);
 		xfs_ilock(ip, lock_flags);
 
 
@@ -334,7 +339,7 @@ finish_inode:
 	 * If we have a real type for an on-disk inode, we can set ops(&unlock)
 	 * If we have a real type for an on-disk inode, we can set ops(&unlock)
 	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.
 	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.
 	 */
 	 */
-	xfs_initialize_vnode(mp, vp, ip);
+	xfs_initialize_vnode(mp, inode, ip);
 	return 0;
 	return 0;
 }
 }
 
 
@@ -354,69 +359,58 @@ xfs_iget(
 	xfs_daddr_t	bno)
 	xfs_daddr_t	bno)
 {
 {
 	struct inode	*inode;
 	struct inode	*inode;
-	bhv_vnode_t	*vp = NULL;
+	xfs_inode_t	*ip;
 	int		error;
 	int		error;
 
 
 	XFS_STATS_INC(xs_ig_attempts);
 	XFS_STATS_INC(xs_ig_attempts);
 
 
 retry:
 retry:
 	inode = iget_locked(mp->m_super, ino);
 	inode = iget_locked(mp->m_super, ino);
-	if (inode) {
-		xfs_inode_t	*ip;
-
-		vp = vn_from_inode(inode);
-		if (inode->i_state & I_NEW) {
-			vn_initialize(inode);
-			error = xfs_iget_core(vp, mp, tp, ino, flags,
-					lock_flags, ipp, bno);
-			if (error) {
-				vn_mark_bad(vp);
-				if (inode->i_state & I_NEW)
-					unlock_new_inode(inode);
-				iput(inode);
-			}
-		} else {
-			/*
-			 * If the inode is not fully constructed due to
-			 * filehandle mismatches wait for the inode to go
-			 * away and try again.
-			 *
-			 * iget_locked will call __wait_on_freeing_inode
-			 * to wait for the inode to go away.
-			 */
-			if (is_bad_inode(inode) ||
-			    ((ip = xfs_vtoi(vp)) == NULL)) {
-				iput(inode);
-				delay(1);
-				goto retry;
-			}
-
-			if (lock_flags != 0)
-				xfs_ilock(ip, lock_flags);
-			XFS_STATS_INC(xs_ig_found);
-			*ipp = ip;
-			error = 0;
+	if (!inode)
+		/* If we got no inode we are out of memory */
+		return ENOMEM;
+
+	if (inode->i_state & I_NEW) {
+		XFS_STATS_INC(vn_active);
+		XFS_STATS_INC(vn_alloc);
+
+		error = xfs_iget_core(inode, mp, tp, ino, flags,
+				lock_flags, ipp, bno);
+		if (error) {
+			make_bad_inode(inode);
+			if (inode->i_state & I_NEW)
+				unlock_new_inode(inode);
+			iput(inode);
 		}
 		}
-	} else
-		error = ENOMEM;	/* If we got no inode we are out of memory */
+		return error;
+	}
 
 
-	return error;
-}
+	/*
+	 * If the inode is not fully constructed due to
+	 * filehandle mismatches wait for the inode to go
+	 * away and try again.
+	 *
+	 * iget_locked will call __wait_on_freeing_inode
+	 * to wait for the inode to go away.
+	 */
+	if (is_bad_inode(inode)) {
+		iput(inode);
+		delay(1);
+		goto retry;
+	}
 
 
-/*
- * Do the setup for the various locks within the incore inode.
- */
-void
-xfs_inode_lock_init(
-	xfs_inode_t	*ip,
-	bhv_vnode_t	*vp)
-{
-	mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
-		     "xfsino", ip->i_ino);
-	mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino);
-	init_waitqueue_head(&ip->i_ipin_wait);
-	atomic_set(&ip->i_pincount, 0);
-	initnsema(&ip->i_flock, 1, "xfsfino");
+	ip = XFS_I(inode);
+	if (!ip) {
+		iput(inode);
+		delay(1);
+		goto retry;
+	}
+
+	if (lock_flags != 0)
+		xfs_ilock(ip, lock_flags);
+	XFS_STATS_INC(xs_ig_found);
+	*ipp = ip;
+	return 0;
 }
 }
 
 
 /*
 /*
@@ -456,11 +450,9 @@ void
 xfs_iput(xfs_inode_t	*ip,
 xfs_iput(xfs_inode_t	*ip,
 	 uint		lock_flags)
 	 uint		lock_flags)
 {
 {
-	bhv_vnode_t	*vp = XFS_ITOV(ip);
-
 	xfs_itrace_entry(ip);
 	xfs_itrace_entry(ip);
 	xfs_iunlock(ip, lock_flags);
 	xfs_iunlock(ip, lock_flags);
-	VN_RELE(vp);
+	IRELE(ip);
 }
 }
 
 
 /*
 /*
@@ -470,20 +462,19 @@ void
 xfs_iput_new(xfs_inode_t	*ip,
 xfs_iput_new(xfs_inode_t	*ip,
 	     uint		lock_flags)
 	     uint		lock_flags)
 {
 {
-	bhv_vnode_t	*vp = XFS_ITOV(ip);
-	struct inode	*inode = vn_to_inode(vp);
+	struct inode	*inode = ip->i_vnode;
 
 
 	xfs_itrace_entry(ip);
 	xfs_itrace_entry(ip);
 
 
 	if ((ip->i_d.di_mode == 0)) {
 	if ((ip->i_d.di_mode == 0)) {
 		ASSERT(!xfs_iflags_test(ip, XFS_IRECLAIMABLE));
 		ASSERT(!xfs_iflags_test(ip, XFS_IRECLAIMABLE));
-		vn_mark_bad(vp);
+		make_bad_inode(inode);
 	}
 	}
 	if (inode->i_state & I_NEW)
 	if (inode->i_state & I_NEW)
 		unlock_new_inode(inode);
 		unlock_new_inode(inode);
 	if (lock_flags)
 	if (lock_flags)
 		xfs_iunlock(ip, lock_flags);
 		xfs_iunlock(ip, lock_flags);
-	VN_RELE(vp);
+	IRELE(ip);
 }
 }
 
 
 
 
@@ -496,8 +487,6 @@ xfs_iput_new(xfs_inode_t	*ip,
 void
 void
 xfs_ireclaim(xfs_inode_t *ip)
 xfs_ireclaim(xfs_inode_t *ip)
 {
 {
-	bhv_vnode_t	*vp;
-
 	/*
 	/*
 	 * Remove from old hash list and mount list.
 	 * Remove from old hash list and mount list.
 	 */
 	 */
@@ -526,9 +515,8 @@ xfs_ireclaim(xfs_inode_t *ip)
 	/*
 	/*
 	 * Pull our behavior descriptor from the vnode chain.
 	 * Pull our behavior descriptor from the vnode chain.
 	 */
 	 */
-	vp = XFS_ITOV_NULL(ip);
-	if (vp) {
-		vn_to_inode(vp)->i_private = NULL;
+	if (ip->i_vnode) {
+		ip->i_vnode->i_private = NULL;
 		ip->i_vnode = NULL;
 		ip->i_vnode = NULL;
 	}
 	}
 
 

+ 0 - 1
fs/xfs/xfs_inode.h

@@ -468,7 +468,6 @@ void		xfs_ihash_init(struct xfs_mount *);
 void		xfs_ihash_free(struct xfs_mount *);
 void		xfs_ihash_free(struct xfs_mount *);
 xfs_inode_t	*xfs_inode_incore(struct xfs_mount *, xfs_ino_t,
 xfs_inode_t	*xfs_inode_incore(struct xfs_mount *, xfs_ino_t,
 				  struct xfs_trans *);
 				  struct xfs_trans *);
-void            xfs_inode_lock_init(xfs_inode_t *, bhv_vnode_t *);
 int		xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
 int		xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
 			 uint, uint, xfs_inode_t **, xfs_daddr_t);
 			 uint, uint, xfs_inode_t **, xfs_daddr_t);
 void		xfs_iput(xfs_inode_t *, uint);
 void		xfs_iput(xfs_inode_t *, uint);