aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_iget.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2011-06-22 21:34:59 -0400
committerAlex Elder <aelder@sgi.com>2011-06-23 23:13:31 -0400
commit778e24bb6dd8682318bb496d4bfdc32b501a6420 (patch)
treef245e607bb2e999d046d777a6abd84c422c86f41 /fs/xfs/xfs_iget.c
parenta27a263bae072a499acc77b632238a6dacccf888 (diff)
xfs: reset inode per-lifetime state when recycling it
XFS inodes has several per-lifetime state fields that determine the behaviour of the inode. These state fields are not all reset when an inode is reused from the reclaimable state. This can lead to unexpected behaviour of the new inode such as speculative preallocation not being truncated away in the expected manner for local files until the inode is subsequently truncated, freed or cycles out of the cache. It can also lead to an inode being considered to be a filestream inode or having been truncated when that is not the case. Rework the reinitialisation of the inode when it is recycled to ensure that it is pristine before it is reused. While there, also fix the resetting of state flags in the recycling error paths so the inode does not become unreclaimable. Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_iget.c')
-rw-r--r--fs/xfs/xfs_iget.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index cb9b6d1469f7..3631783b2b53 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -253,16 +253,21 @@ xfs_iget_cache_hit(
253 rcu_read_lock(); 253 rcu_read_lock();
254 spin_lock(&ip->i_flags_lock); 254 spin_lock(&ip->i_flags_lock);
255 255
256 ip->i_flags &= ~XFS_INEW; 256 ip->i_flags &= ~(XFS_INEW | XFS_IRECLAIM);
257 ip->i_flags |= XFS_IRECLAIMABLE; 257 ASSERT(ip->i_flags & XFS_IRECLAIMABLE);
258 __xfs_inode_set_reclaim_tag(pag, ip);
259 trace_xfs_iget_reclaim_fail(ip); 258 trace_xfs_iget_reclaim_fail(ip);
260 goto out_error; 259 goto out_error;
261 } 260 }
262 261
263 spin_lock(&pag->pag_ici_lock); 262 spin_lock(&pag->pag_ici_lock);
264 spin_lock(&ip->i_flags_lock); 263 spin_lock(&ip->i_flags_lock);
265 ip->i_flags &= ~(XFS_IRECLAIMABLE | XFS_IRECLAIM); 264
265 /*
266 * Clear the per-lifetime state in the inode as we are now
267 * effectively a new inode and need to return to the initial
268 * state before reuse occurs.
269 */
270 ip->i_flags &= ~XFS_IRECLAIM_RESET_FLAGS;
266 ip->i_flags |= XFS_INEW; 271 ip->i_flags |= XFS_INEW;
267 __xfs_inode_clear_reclaim_tag(mp, pag, ip); 272 __xfs_inode_clear_reclaim_tag(mp, pag, ip);
268 inode->i_state = I_NEW; 273 inode->i_state = I_NEW;