aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@sgi.com>2005-09-02 02:24:19 -0400
committerNathan Scott <nathans@sgi.com>2005-09-02 02:24:19 -0400
commitcdb626878f6f5e37d678d30c9cacf5726b88a656 (patch)
tree2c9ff3f0ce5831bc34820ffbaffa8681fa1e0271
parentbb3f724e12eb9c62c92ff6f14a856bc58ba35f5e (diff)
[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>
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c24
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h21
-rw-r--r--fs/xfs/quota/xfs_qm_syscalls.c16
-rw-r--r--fs/xfs/xfs_vfsops.c36
4 files changed, 15 insertions, 82 deletions
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index 250cad54e892..353276bda344 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -163,30 +163,6 @@ vn_initialize(
163} 163}
164 164
165/* 165/*
166 * Get a reference on a vnode.
167 */
168vnode_t *
169vn_get(
170 struct vnode *vp,
171 vmap_t *vmap)
172{
173 struct inode *inode;
174
175 XFS_STATS_INC(vn_get);
176 inode = LINVFS_GET_IP(vp);
177 if (inode->i_state & I_FREEING)
178 return NULL;
179
180 inode = ilookup(vmap->v_vfsp->vfs_super, vmap->v_ino);
181 if (!inode) /* Inode not present */
182 return NULL;
183
184 vn_trace_exit(vp, "vn_get", (inst_t *)__return_address);
185
186 return vp;
187}
188
189/*
190 * Revalidate the Linux inode from the vattr. 166 * Revalidate the Linux inode from the vattr.
191 * Note: i_size _not_ updated; we must hold the inode 167 * Note: i_size _not_ updated; we must hold the inode
192 * semaphore when doing that - callers responsibility. 168 * semaphore when doing that - callers responsibility.
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 56d85d85fb05..6cb0a01df25d 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -505,20 +505,6 @@ extern int vn_wait(struct vnode *);
505extern vnode_t *vn_initialize(struct inode *); 505extern vnode_t *vn_initialize(struct inode *);
506 506
507/* 507/*
508 * Acquiring and invalidating vnodes:
509 *
510 * if (vn_get(vp, version, 0))
511 * ...;
512 * vn_purge(vp, version);
513 *
514 * vn_get and vn_purge must be called with vmap_t arguments, sampled
515 * while a lock that the vnode's VOP_RECLAIM function acquires is
516 * held, to ensure that the vnode sampled with the lock held isn't
517 * recycled (VOP_RECLAIMed) or deallocated between the release of the lock
518 * and the subsequent vn_get or vn_purge.
519 */
520
521/*
522 * vnode_map structures _must_ match vn_epoch and vnode structure sizes. 508 * vnode_map structures _must_ match vn_epoch and vnode structure sizes.
523 */ 509 */
524typedef struct vnode_map { 510typedef struct vnode_map {
@@ -532,7 +518,6 @@ typedef struct vnode_map {
532 (vmap).v_ino = (vp)->v_inode.i_ino; } 518 (vmap).v_ino = (vp)->v_inode.i_ino; }
533 519
534extern void vn_purge(struct vnode *, vmap_t *); 520extern void vn_purge(struct vnode *, vmap_t *);
535extern vnode_t *vn_get(struct vnode *, vmap_t *);
536extern int vn_revalidate(struct vnode *); 521extern int vn_revalidate(struct vnode *);
537extern void vn_revalidate_core(struct vnode *, vattr_t *); 522extern void vn_revalidate_core(struct vnode *, vattr_t *);
538extern void vn_remove(struct vnode *); 523extern void vn_remove(struct vnode *);
@@ -560,6 +545,12 @@ extern void vn_rele(struct vnode *);
560#define VN_RELE(vp) (iput(LINVFS_GET_IP(vp))) 545#define VN_RELE(vp) (iput(LINVFS_GET_IP(vp)))
561#endif 546#endif
562 547
548static inline struct vnode *vn_grab(struct vnode *vp)
549{
550 struct inode *inode = igrab(LINVFS_GET_IP(vp));
551 return inode ? LINVFS_GET_VP(inode) : NULL;
552}
553
563/* 554/*
564 * Vname handling macros. 555 * Vname handling macros.
565 */ 556 */
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
index 68e98962dbef..15e02e8a9d4f 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/quota/xfs_qm_syscalls.c
@@ -1053,7 +1053,6 @@ xfs_qm_dqrele_all_inodes(
1053 struct xfs_mount *mp, 1053 struct xfs_mount *mp,
1054 uint flags) 1054 uint flags)
1055{ 1055{
1056 vmap_t vmap;
1057 xfs_inode_t *ip, *topino; 1056 xfs_inode_t *ip, *topino;
1058 uint ireclaims; 1057 uint ireclaims;
1059 vnode_t *vp; 1058 vnode_t *vp;
@@ -1061,8 +1060,8 @@ xfs_qm_dqrele_all_inodes(
1061 1060
1062 ASSERT(mp->m_quotainfo); 1061 ASSERT(mp->m_quotainfo);
1063 1062
1064again:
1065 XFS_MOUNT_ILOCK(mp); 1063 XFS_MOUNT_ILOCK(mp);
1064again:
1066 ip = mp->m_inodes; 1065 ip = mp->m_inodes;
1067 if (ip == NULL) { 1066 if (ip == NULL) {
1068 XFS_MOUNT_IUNLOCK(mp); 1067 XFS_MOUNT_IUNLOCK(mp);
@@ -1090,18 +1089,14 @@ again:
1090 } 1089 }
1091 vnode_refd = B_FALSE; 1090 vnode_refd = B_FALSE;
1092 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) { 1091 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) {
1093 /*
1094 * Sample vp mapping while holding the mplock, lest
1095 * we come across a non-existent vnode.
1096 */
1097 VMAP(vp, vmap);
1098 ireclaims = mp->m_ireclaims; 1092 ireclaims = mp->m_ireclaims;
1099 topino = mp->m_inodes; 1093 topino = mp->m_inodes;
1100 XFS_MOUNT_IUNLOCK(mp); 1094 vp = vn_grab(vp);
1095 if (!vp)
1096 goto again;
1101 1097
1098 XFS_MOUNT_IUNLOCK(mp);
1102 /* XXX restart limit ? */ 1099 /* XXX restart limit ? */
1103 if ( ! (vp = vn_get(vp, &vmap)))
1104 goto again;
1105 xfs_ilock(ip, XFS_ILOCK_EXCL); 1100 xfs_ilock(ip, XFS_ILOCK_EXCL);
1106 vnode_refd = B_TRUE; 1101 vnode_refd = B_TRUE;
1107 } else { 1102 } else {
@@ -1137,7 +1132,6 @@ again:
1137 */ 1132 */
1138 if (topino != mp->m_inodes || mp->m_ireclaims != ireclaims) { 1133 if (topino != mp->m_inodes || mp->m_ireclaims != ireclaims) {
1139 /* XXX use a sentinel */ 1134 /* XXX use a sentinel */
1140 XFS_MOUNT_IUNLOCK(mp);
1141 goto again; 1135 goto again;
1142 } 1136 }
1143 ip = ip->i_mnext; 1137 ip = ip->i_mnext;
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index 42bcc0215203..b8ce6cad2b71 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -906,7 +906,6 @@ xfs_sync_inodes(
906 xfs_inode_t *ip_next; 906 xfs_inode_t *ip_next;
907 xfs_buf_t *bp; 907 xfs_buf_t *bp;
908 vnode_t *vp = NULL; 908 vnode_t *vp = NULL;
909 vmap_t vmap;
910 int error; 909 int error;
911 int last_error; 910 int last_error;
912 uint64_t fflag; 911 uint64_t fflag;
@@ -1101,48 +1100,21 @@ xfs_sync_inodes(
1101 * lock in xfs_ireclaim() after the inode is pulled from 1100 * lock in xfs_ireclaim() after the inode is pulled from
1102 * the mount list will sleep until we release it here. 1101 * the mount list will sleep until we release it here.
1103 * This keeps the vnode from being freed while we reference 1102 * This keeps the vnode from being freed while we reference
1104 * it. It is also cheaper and simpler than actually doing 1103 * it.
1105 * a vn_get() for every inode we touch here.
1106 */ 1104 */
1107 if (xfs_ilock_nowait(ip, lock_flags) == 0) { 1105 if (xfs_ilock_nowait(ip, lock_flags) == 0) {
1108
1109 if ((flags & SYNC_BDFLUSH) || (vp == NULL)) { 1106 if ((flags & SYNC_BDFLUSH) || (vp == NULL)) {
1110 ip = ip->i_mnext; 1107 ip = ip->i_mnext;
1111 continue; 1108 continue;
1112 } 1109 }
1113 1110
1114 /* 1111 vp = vn_grab(vp);
1115 * We need to unlock the inode list lock in order
1116 * to lock the inode. Insert a marker record into
1117 * the inode list to remember our position, dropping
1118 * the lock is now done inside the IPOINTER_INSERT
1119 * macro.
1120 *
1121 * We also use the inode list lock to protect us
1122 * in taking a snapshot of the vnode version number
1123 * for use in calling vn_get().
1124 */
1125 VMAP(vp, vmap);
1126 IPOINTER_INSERT(ip, mp);
1127
1128 vp = vn_get(vp, &vmap);
1129 if (vp == NULL) { 1112 if (vp == NULL) {
1130 /* 1113 ip = ip->i_mnext;
1131 * The vnode was reclaimed once we let go
1132 * of the inode list lock. Skip to the
1133 * next list entry. Remove the marker.
1134 */
1135
1136 XFS_MOUNT_ILOCK(mp);
1137
1138 mount_locked = B_TRUE;
1139 vnode_refed = B_FALSE;
1140
1141 IPOINTER_REMOVE(ip, mp);
1142
1143 continue; 1114 continue;
1144 } 1115 }
1145 1116
1117 IPOINTER_INSERT(ip, mp);
1146 xfs_ilock(ip, lock_flags); 1118 xfs_ilock(ip, lock_flags);
1147 1119
1148 ASSERT(vp == XFS_ITOV(ip)); 1120 ASSERT(vp == XFS_ITOV(ip));