aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDavid Chinner <david@fromorbit.com>2008-10-30 02:15:03 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:15:03 -0400
commitbc60a99323b3ec628273b5fa998285c87d464ca6 (patch)
tree5084bb53b48d1b9ba3ceed8a3995296cc21840c5 /fs/xfs
parent2af75df7be7ca86965bf73766f827575d1c26fbd (diff)
[XFS] Use struct inodes instead of vnodes to kill vn_grab
With the sync code relocated to the linux-2.6 directory we can use struct inodes directly. If we do the same thing for the quota release code, we can remove vn_grab altogether. While here, convert the VN_BAD() checks to is_bad_inode() so we can remove vnodes entirely from this code. SGI-PV: 988140 SGI-Modid: xfs-linux-melb:xfs-kern:32304a Signed-off-by: David Chinner <david@fromorbit.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Christoph Hellwig <hch@infradead.org>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c53
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c6
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h5
-rw-r--r--fs/xfs/quota/xfs_qm_syscalls.c16
4 files changed, 37 insertions, 43 deletions
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index 59da3327a6b5..461c1dc35d37 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -131,10 +131,7 @@ xfs_sync_inodes_ag(
131 int flags, 131 int flags,
132 int *bypassed) 132 int *bypassed)
133{ 133{
134 xfs_inode_t *ip = NULL;
135 struct inode *vp = NULL;
136 xfs_perag_t *pag = &mp->m_perag[ag]; 134 xfs_perag_t *pag = &mp->m_perag[ag];
137 boolean_t vnode_refed = B_FALSE;
138 int nr_found; 135 int nr_found;
139 int first_index = 0; 136 int first_index = 0;
140 int error = 0; 137 int error = 0;
@@ -156,6 +153,10 @@ xfs_sync_inodes_ag(
156 } 153 }
157 154
158 do { 155 do {
156 struct inode *inode;
157 boolean_t inode_refed;
158 xfs_inode_t *ip = NULL;
159
159 /* 160 /*
160 * use a gang lookup to find the next inode in the tree 161 * use a gang lookup to find the next inode in the tree
161 * as the tree is sparse and a gang lookup walks to find 162 * as the tree is sparse and a gang lookup walks to find
@@ -177,14 +178,14 @@ xfs_sync_inodes_ag(
177 * skip inodes in reclaim. Let xfs_syncsub do that for 178 * skip inodes in reclaim. Let xfs_syncsub do that for
178 * us so we don't need to worry. 179 * us so we don't need to worry.
179 */ 180 */
180 vp = VFS_I(ip); 181 if (xfs_iflags_test(ip, (XFS_IRECLAIM|XFS_IRECLAIMABLE))) {
181 if (!vp) {
182 read_unlock(&pag->pag_ici_lock); 182 read_unlock(&pag->pag_ici_lock);
183 continue; 183 continue;
184 } 184 }
185 185
186 /* bad inodes are dealt with elsewhere */ 186 /* bad inodes are dealt with elsewhere */
187 if (VN_BAD(vp)) { 187 inode = VFS_I(ip);
188 if (is_bad_inode(inode)) {
188 read_unlock(&pag->pag_ici_lock); 189 read_unlock(&pag->pag_ici_lock);
189 continue; 190 continue;
190 } 191 }
@@ -196,30 +197,29 @@ xfs_sync_inodes_ag(
196 } 197 }
197 198
198 /* 199 /*
199 * The inode lock here actually coordinates with the almost 200 * If we can't get a reference on the VFS_I, the inode must be
200 * spurious inode lock in xfs_ireclaim() to prevent the vnode 201 * in reclaim. If we can get the inode lock without blocking,
201 * we handle here without a reference from being freed while we 202 * it is safe to flush the inode because we hold the tree lock
202 * reference it. If we lock the inode while it's on the mount 203 * and xfs_iextract will block right now. Hence if we lock the
203 * list here, then the spurious inode lock in xfs_ireclaim() 204 * inode while holding the tree lock, xfs_ireclaim() is
204 * after the inode is pulled from the mount list will sleep 205 * guaranteed to block on the inode lock we now hold and hence
205 * until we release it here. This keeps the vnode from being 206 * it is safe to reference the inode until we drop the inode
206 * freed while we reference it. 207 * locks completely.
207 */ 208 */
208 if (xfs_ilock_nowait(ip, lock_flags) == 0) { 209 inode_refed = B_FALSE;
209 vp = vn_grab(vp); 210 if (igrab(inode)) {
210 read_unlock(&pag->pag_ici_lock); 211 read_unlock(&pag->pag_ici_lock);
211 if (!vp)
212 continue;
213 xfs_ilock(ip, lock_flags); 212 xfs_ilock(ip, lock_flags);
214 213 inode_refed = B_TRUE;
215 ASSERT(vp == VFS_I(ip));
216 ASSERT(ip->i_mount == mp);
217
218 vnode_refed = B_TRUE;
219 } else { 214 } else {
220 /* safe to unlock here as we have a reference */ 215 if (!xfs_ilock_nowait(ip, lock_flags)) {
216 /* leave it to reclaim */
217 read_unlock(&pag->pag_ici_lock);
218 continue;
219 }
221 read_unlock(&pag->pag_ici_lock); 220 read_unlock(&pag->pag_ici_lock);
222 } 221 }
222
223 /* 223 /*
224 * If we have to flush data or wait for I/O completion 224 * If we have to flush data or wait for I/O completion
225 * we need to drop the ilock that we currently hold. 225 * we need to drop the ilock that we currently hold.
@@ -240,7 +240,7 @@ xfs_sync_inodes_ag(
240 xfs_ilock(ip, XFS_ILOCK_SHARED); 240 xfs_ilock(ip, XFS_ILOCK_SHARED);
241 } 241 }
242 242
243 if ((flags & SYNC_DELWRI) && VN_DIRTY(vp)) { 243 if ((flags & SYNC_DELWRI) && VN_DIRTY(inode)) {
244 xfs_iunlock(ip, XFS_ILOCK_SHARED); 244 xfs_iunlock(ip, XFS_ILOCK_SHARED);
245 error = xfs_flush_pages(ip, 0, -1, fflag, FI_NONE); 245 error = xfs_flush_pages(ip, 0, -1, fflag, FI_NONE);
246 if (flags & SYNC_IOWAIT) 246 if (flags & SYNC_IOWAIT)
@@ -268,9 +268,8 @@ xfs_sync_inodes_ag(
268 if (lock_flags) 268 if (lock_flags)
269 xfs_iunlock(ip, lock_flags); 269 xfs_iunlock(ip, lock_flags);
270 270
271 if (vnode_refed) { 271 if (inode_refed) {
272 IRELE(ip); 272 IRELE(ip);
273 vnode_refed = B_FALSE;
274 } 273 }
275 274
276 if (error) 275 if (error)
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index b52528bbbfff..dceb6dbaa2da 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -90,10 +90,10 @@ vn_ioerror(
90 */ 90 */
91static inline int xfs_icount(struct xfs_inode *ip) 91static inline int xfs_icount(struct xfs_inode *ip)
92{ 92{
93 struct inode *vp = VFS_I(ip); 93 struct inode *inode = VFS_I(ip);
94 94
95 if (vp) 95 if (!inode)
96 return vn_count(vp); 96 return atomic_read(&inode->i_count);
97 return -1; 97 return -1;
98} 98}
99 99
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 683ce16210ff..bf89e41c3b8d 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -80,11 +80,6 @@ do { \
80 iput(VFS_I(ip)); \ 80 iput(VFS_I(ip)); \
81} while (0) 81} while (0)
82 82
83static inline struct inode *vn_grab(struct inode *vp)
84{
85 return igrab(vp);
86}
87
88/* 83/*
89 * Dealing with bad inodes 84 * Dealing with bad inodes
90 */ 85 */
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
index 26152b9ccc6f..4254b074223b 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/quota/xfs_qm_syscalls.c
@@ -1031,13 +1031,13 @@ xfs_qm_dqrele_inodes_ag(
1031 uint flags) 1031 uint flags)
1032{ 1032{
1033 xfs_inode_t *ip = NULL; 1033 xfs_inode_t *ip = NULL;
1034 struct inode *vp = NULL;
1035 xfs_perag_t *pag = &mp->m_perag[ag]; 1034 xfs_perag_t *pag = &mp->m_perag[ag];
1036 int first_index = 0; 1035 int first_index = 0;
1037 int nr_found; 1036 int nr_found;
1038 1037
1039 do { 1038 do {
1040 boolean_t vnode_refd = B_FALSE; 1039 boolean_t inode_refed;
1040 struct inode *inode;
1041 1041
1042 /* 1042 /*
1043 * use a gang lookup to find the next inode in the tree 1043 * use a gang lookup to find the next inode in the tree
@@ -1057,19 +1057,19 @@ xfs_qm_dqrele_inodes_ag(
1057 first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1); 1057 first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1);
1058 1058
1059 /* skip quota inodes and those in reclaim */ 1059 /* skip quota inodes and those in reclaim */
1060 vp = VFS_I(ip); 1060 inode = VFS_I(ip);
1061 if (!vp || ip == XFS_QI_UQIP(mp) || ip == XFS_QI_GQIP(mp)) { 1061 if (!inode || ip == XFS_QI_UQIP(mp) || ip == XFS_QI_GQIP(mp)) {
1062 ASSERT(ip->i_udquot == NULL); 1062 ASSERT(ip->i_udquot == NULL);
1063 ASSERT(ip->i_gdquot == NULL); 1063 ASSERT(ip->i_gdquot == NULL);
1064 read_unlock(&pag->pag_ici_lock); 1064 read_unlock(&pag->pag_ici_lock);
1065 continue; 1065 continue;
1066 } 1066 }
1067 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) { 1067 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) {
1068 vp = vn_grab(vp); 1068 inode = igrab(inode);
1069 read_unlock(&pag->pag_ici_lock); 1069 read_unlock(&pag->pag_ici_lock);
1070 if (!vp) 1070 if (!inode)
1071 continue; 1071 continue;
1072 vnode_refd = B_TRUE; 1072 inode_refed = B_TRUE;
1073 xfs_ilock(ip, XFS_ILOCK_EXCL); 1073 xfs_ilock(ip, XFS_ILOCK_EXCL);
1074 } else { 1074 } else {
1075 read_unlock(&pag->pag_ici_lock); 1075 read_unlock(&pag->pag_ici_lock);
@@ -1084,7 +1084,7 @@ xfs_qm_dqrele_inodes_ag(
1084 ip->i_gdquot = NULL; 1084 ip->i_gdquot = NULL;
1085 } 1085 }
1086 xfs_iunlock(ip, XFS_ILOCK_EXCL); 1086 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1087 if (vnode_refd) 1087 if (inode_refed)
1088 IRELE(ip); 1088 IRELE(ip);
1089 } while (nr_found); 1089 } while (nr_found);
1090} 1090}