aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2010-09-27 22:28:06 -0400
committerAlex Elder <aelder@sgi.com>2010-10-18 16:07:52 -0400
commite13de955ca67b0bd1cec9a2f9352a3053065bf7f (patch)
treeb3b132b1e13791f8766da9fab4bad336f87775cc /fs/xfs
parent65d0f20533c503b50bd5e7e86434512af7761eea (diff)
xfs: split out inode walk inode grabbing
When doing read side inode cache walks, the code to validate and grab an inode is common to all callers. Split it out of the execute callbacks in preparation for batching lookups. Similarly, split out the inode reference dropping from the execute callbacks into the main lookup look to be symmetric with the grab. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c79
-rw-r--r--fs/xfs/quota/xfs_qm_syscalls.c9
2 files changed, 34 insertions, 54 deletions
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index b5cdf0ef39ec..37fc2c0a4d25 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -39,6 +39,33 @@
39#include <linux/kthread.h> 39#include <linux/kthread.h>
40#include <linux/freezer.h> 40#include <linux/freezer.h>
41 41
42STATIC int
43xfs_inode_ag_walk_grab(
44 struct xfs_inode *ip)
45{
46 struct inode *inode = VFS_I(ip);
47
48 /* nothing to sync during shutdown */
49 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
50 return EFSCORRUPTED;
51
52 /* avoid new or reclaimable inodes. Leave for reclaim code to flush */
53 if (xfs_iflags_test(ip, XFS_INEW | XFS_IRECLAIMABLE | XFS_IRECLAIM))
54 return ENOENT;
55
56 /* If we can't grab the inode, it must on it's way to reclaim. */
57 if (!igrab(inode))
58 return ENOENT;
59
60 if (is_bad_inode(inode)) {
61 IRELE(ip);
62 return ENOENT;
63 }
64
65 /* inode is valid */
66 return 0;
67}
68
42 69
43STATIC int 70STATIC int
44xfs_inode_ag_walk( 71xfs_inode_ag_walk(
@@ -80,8 +107,14 @@ restart:
80 if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino)) 107 if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino))
81 done = 1; 108 done = 1;
82 109
83 /* execute releases pag->pag_ici_lock */ 110 if (xfs_inode_ag_walk_grab(ip)) {
111 read_unlock(&pag->pag_ici_lock);
112 continue;
113 }
114 read_unlock(&pag->pag_ici_lock);
115
84 error = execute(ip, pag, flags); 116 error = execute(ip, pag, flags);
117 IRELE(ip);
85 if (error == EAGAIN) { 118 if (error == EAGAIN) {
86 skipped++; 119 skipped++;
87 continue; 120 continue;
@@ -128,40 +161,6 @@ xfs_inode_ag_iterator(
128 return XFS_ERROR(last_error); 161 return XFS_ERROR(last_error);
129} 162}
130 163
131/* must be called with pag_ici_lock held and releases it */
132int
133xfs_sync_inode_valid(
134 struct xfs_inode *ip,
135 struct xfs_perag *pag)
136{
137 struct inode *inode = VFS_I(ip);
138 int error = EFSCORRUPTED;
139
140 /* nothing to sync during shutdown */
141 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
142 goto out_unlock;
143
144 /* avoid new or reclaimable inodes. Leave for reclaim code to flush */
145 error = ENOENT;
146 if (xfs_iflags_test(ip, XFS_INEW | XFS_IRECLAIMABLE | XFS_IRECLAIM))
147 goto out_unlock;
148
149 /* If we can't grab the inode, it must on it's way to reclaim. */
150 if (!igrab(inode))
151 goto out_unlock;
152
153 if (is_bad_inode(inode)) {
154 IRELE(ip);
155 goto out_unlock;
156 }
157
158 /* inode is valid */
159 error = 0;
160out_unlock:
161 read_unlock(&pag->pag_ici_lock);
162 return error;
163}
164
165STATIC int 164STATIC int
166xfs_sync_inode_data( 165xfs_sync_inode_data(
167 struct xfs_inode *ip, 166 struct xfs_inode *ip,
@@ -172,10 +171,6 @@ xfs_sync_inode_data(
172 struct address_space *mapping = inode->i_mapping; 171 struct address_space *mapping = inode->i_mapping;
173 int error = 0; 172 int error = 0;
174 173
175 error = xfs_sync_inode_valid(ip, pag);
176 if (error)
177 return error;
178
179 if (!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) 174 if (!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
180 goto out_wait; 175 goto out_wait;
181 176
@@ -192,7 +187,6 @@ xfs_sync_inode_data(
192 out_wait: 187 out_wait:
193 if (flags & SYNC_WAIT) 188 if (flags & SYNC_WAIT)
194 xfs_ioend_wait(ip); 189 xfs_ioend_wait(ip);
195 IRELE(ip);
196 return error; 190 return error;
197} 191}
198 192
@@ -204,10 +198,6 @@ xfs_sync_inode_attr(
204{ 198{
205 int error = 0; 199 int error = 0;
206 200
207 error = xfs_sync_inode_valid(ip, pag);
208 if (error)
209 return error;
210
211 xfs_ilock(ip, XFS_ILOCK_SHARED); 201 xfs_ilock(ip, XFS_ILOCK_SHARED);
212 if (xfs_inode_clean(ip)) 202 if (xfs_inode_clean(ip))
213 goto out_unlock; 203 goto out_unlock;
@@ -226,7 +216,6 @@ xfs_sync_inode_attr(
226 216
227 out_unlock: 217 out_unlock:
228 xfs_iunlock(ip, XFS_ILOCK_SHARED); 218 xfs_iunlock(ip, XFS_ILOCK_SHARED);
229 IRELE(ip);
230 return error; 219 return error;
231} 220}
232 221
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
index ac11fbef37fc..57847434fa51 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/quota/xfs_qm_syscalls.c
@@ -875,21 +875,14 @@ xfs_dqrele_inode(
875 struct xfs_perag *pag, 875 struct xfs_perag *pag,
876 int flags) 876 int flags)
877{ 877{
878 int error;
879
880 /* skip quota inodes */ 878 /* skip quota inodes */
881 if (ip == ip->i_mount->m_quotainfo->qi_uquotaip || 879 if (ip == ip->i_mount->m_quotainfo->qi_uquotaip ||
882 ip == ip->i_mount->m_quotainfo->qi_gquotaip) { 880 ip == ip->i_mount->m_quotainfo->qi_gquotaip) {
883 ASSERT(ip->i_udquot == NULL); 881 ASSERT(ip->i_udquot == NULL);
884 ASSERT(ip->i_gdquot == NULL); 882 ASSERT(ip->i_gdquot == NULL);
885 read_unlock(&pag->pag_ici_lock);
886 return 0; 883 return 0;
887 } 884 }
888 885
889 error = xfs_sync_inode_valid(ip, pag);
890 if (error)
891 return error;
892
893 xfs_ilock(ip, XFS_ILOCK_EXCL); 886 xfs_ilock(ip, XFS_ILOCK_EXCL);
894 if ((flags & XFS_UQUOTA_ACCT) && ip->i_udquot) { 887 if ((flags & XFS_UQUOTA_ACCT) && ip->i_udquot) {
895 xfs_qm_dqrele(ip->i_udquot); 888 xfs_qm_dqrele(ip->i_udquot);
@@ -900,8 +893,6 @@ xfs_dqrele_inode(
900 ip->i_gdquot = NULL; 893 ip->i_gdquot = NULL;
901 } 894 }
902 xfs_iunlock(ip, XFS_ILOCK_EXCL); 895 xfs_iunlock(ip, XFS_ILOCK_EXCL);
903
904 IRELE(ip);
905 return 0; 896 return 0;
906} 897}
907 898