xfs: drop IDONTCACHE on inodes when we mark them sick
authorDarrick J. Wong <djwong@kernel.org>
Mon, 7 Jun 2021 16:34:50 +0000 (09:34 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 8 Jun 2021 16:30:20 +0000 (09:30 -0700)
When we decide to mark an inode sick, clear the DONTCACHE flag so that
the incore inode will be kept around until memory pressure forces it out
of memory.  This increases the chances that the sick status will be
caught by someone compiling a health report later on.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
fs/xfs/xfs_health.c

index 5de3195f6cb2503e590048d388441df2ebc8e2cd..eb10eacabc8fdb613d7a8aa4172b9def1e06f797 100644 (file)
@@ -229,6 +229,15 @@ xfs_inode_mark_sick(
        ip->i_sick |= mask;
        ip->i_checked |= mask;
        spin_unlock(&ip->i_flags_lock);
+
+       /*
+        * Keep this inode around so we don't lose the sickness report.  Scrub
+        * grabs inodes with DONTCACHE assuming that most inode are ok, which
+        * is not the case here.
+        */
+       spin_lock(&VFS_I(ip)->i_lock);
+       VFS_I(ip)->i_state &= ~I_DONTCACHE;
+       spin_unlock(&VFS_I(ip)->i_lock);
 }
 
 /* Mark parts of an inode healed. */