提交 74717354 编写于 作者: D Darrick J. Wong 提交者: Zheng Zengkai

xfs: separate primary inode selection criteria in xfs_iget_cache_hit

mainline-inclusion
from mainline-v5.13-rc4
commit 77b4d286
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=77b4d2861e8381d00e4b9bd1be2a355dda99ff60

-------------------------------------------------

During review of the v6 deferred inode inactivation patchset[1], Dave
commented that _cache_hit should have a clear separation between inode
selection criteria and actions performed on a selected inode.  Move a
hunk to make this true, and compact the shrink cases in the function.

[1] https://lore.kernel.org/linux-xfs/162310469340.3465262.504398465311182657.stgit@locust/T/#mca6d958521cb88bbc1bfe1a30767203328d410b5Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
Reviewed-by: NBrian Foster <bfoster@redhat.com>
Signed-off-by: NLihong Kou <koulihong@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 ccc89aba
...@@ -506,13 +506,8 @@ xfs_iget_cache_hit( ...@@ -506,13 +506,8 @@ xfs_iget_cache_hit(
* will not match, so check for that, too. * will not match, so check for that, too.
*/ */
spin_lock(&ip->i_flags_lock); spin_lock(&ip->i_flags_lock);
if (ip->i_ino != ino) { if (ip->i_ino != ino)
trace_xfs_iget_skip(ip); goto out_skip;
XFS_STATS_INC(mp, xs_ig_frecycle);
error = -EAGAIN;
goto out_error;
}
/* /*
* If we are racing with another cache hit that is currently * If we are racing with another cache hit that is currently
...@@ -524,12 +519,8 @@ xfs_iget_cache_hit( ...@@ -524,12 +519,8 @@ xfs_iget_cache_hit(
* wait_on_inode to wait for these flags to be cleared * wait_on_inode to wait for these flags to be cleared
* instead of polling for it. * instead of polling for it.
*/ */
if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) { if (ip->i_flags & (XFS_INEW | XFS_IRECLAIM))
trace_xfs_iget_skip(ip); goto out_skip;
XFS_STATS_INC(mp, xs_ig_frecycle);
error = -EAGAIN;
goto out_error;
}
/* /*
* Check the inode free state is valid. This also detects lookup * Check the inode free state is valid. This also detects lookup
...@@ -539,23 +530,21 @@ xfs_iget_cache_hit( ...@@ -539,23 +530,21 @@ xfs_iget_cache_hit(
if (error) if (error)
goto out_error; goto out_error;
if (ip->i_flags & XFS_IRECLAIMABLE) { /* Skip inodes that have no vfs state. */
if (flags & XFS_IGET_INCORE) { if ((flags & XFS_IGET_INCORE) &&
error = -EAGAIN; (ip->i_flags & XFS_IRECLAIMABLE))
goto out_error; goto out_skip;
}
/* The inode fits the selection criteria; process it. */
if (ip->i_flags & XFS_IRECLAIMABLE) {
/* Drops i_flags_lock and RCU read lock. */ /* Drops i_flags_lock and RCU read lock. */
error = xfs_iget_recycle(pag, ip); error = xfs_iget_recycle(pag, ip);
if (error) if (error)
return error; return error;
} else { } else {
/* If the VFS inode is being torn down, pause and try again. */ /* If the VFS inode is being torn down, pause and try again. */
if (!igrab(inode)) { if (!igrab(inode))
trace_xfs_iget_skip(ip); goto out_skip;
error = -EAGAIN;
goto out_error;
}
/* We've got a live one. */ /* We've got a live one. */
spin_unlock(&ip->i_flags_lock); spin_unlock(&ip->i_flags_lock);
...@@ -572,6 +561,10 @@ xfs_iget_cache_hit( ...@@ -572,6 +561,10 @@ xfs_iget_cache_hit(
return 0; return 0;
out_skip:
trace_xfs_iget_skip(ip);
XFS_STATS_INC(mp, xs_ig_frecycle);
error = -EAGAIN;
out_error: out_error:
spin_unlock(&ip->i_flags_lock); spin_unlock(&ip->i_flags_lock);
rcu_read_unlock(); rcu_read_unlock();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册