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
@@ -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 |
ip->i_flags |= XFS_INEW;
__xfs_inode_clear_reclaim_tag(mp, pag, ip);
inode->i_state = I_NEW;