[Top] [All Lists]

[PATCH 1/2] xfs: clear inode per-lifetime state when recycling it

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/2] xfs: clear inode per-lifetime state when recycling it
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Tue, 31 May 2011 14:20:58 +1000
In-reply-to: <1306815659-23346-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1306815659-23346-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

XFs inodes have several per-lifetime state flags that determine heaviour of the
inode. These state flags are not reset when an inode is reallocated and reused
from the reclaimable state.

This can lead to specualtive 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.

Clear the state flags when the inode is recycled to avoid these problems.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
 fs/xfs/xfs_iget.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index cb9b6d1..36467f1 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -262,7 +262,17 @@ xfs_iget_cache_hit(
-               ip->i_flags &= ~(XFS_IRECLAIMABLE | XFS_IRECLAIM);
+               /*
+                * Clear the relcaim and per-lifetime state flags as we are now
+                * effectively a new inode and so we need to reset to the
+                * initial state.
+                *
+                * XXX(dgc): should the XFS_ISTALE flag only be cleared here?
+                */
+               ip->i_flags &= ~(XFS_IRECLAIMABLE | XFS_IRECLAIM |
+                                XFS_IDIRTY_RELEASE | XFS_ITRUNCATED |
+                                XFS_IFILESTREAM);
                ip->i_flags |= XFS_INEW;
                __xfs_inode_clear_reclaim_tag(mp, pag, ip);
                inode->i_state = I_NEW;

<Prev in Thread] Current Thread [Next in Thread>