From: "Darrick J. Wong" djwong@kernel.org
mainline-inclusion from mainline-v5.13-rc4 commit 594ab00b760f1722b800c45d37adc21eecf42dc1 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/?i...
-------------------------------------------------
Soon we're going to be adding two new callers to the incore inode walk code: reclaim of incore inodes, and (later) inactivation of inodes. Both states operate on inodes that no longer have any VFS state, so we need to move the xfs_irele calls into the processing functions.
In other words, icwalk processing functions are responsible for cleaning up whatever state changes are made by the corresponding icwalk igrab function that picked the inode for processing.
Signed-off-by: Darrick J. Wong djwong@kernel.org Reviewed-by: Dave Chinner dchinner@redhat.com Signed-off-by: Lihong Kou koulihong@huawei.com Reviewed-by: Zhang Yi yi.zhang@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- fs/xfs/xfs_icache.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 33d5be8a7cb2..9041773e90a8 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -807,7 +807,7 @@ xfs_dqrele_igrab( }
/* Drop this inode's dquots. */ -static int +static void xfs_dqrele_inode( struct xfs_inode *ip, void *priv) @@ -831,7 +831,7 @@ xfs_dqrele_inode( ip->i_pdquot = NULL; } xfs_iunlock(ip, XFS_ILOCK_EXCL); - return 0; + xfs_irele(ip); }
/* @@ -857,7 +857,7 @@ xfs_dqrele_all_inodes( } #else # define xfs_dqrele_igrab(ip) (false) -# define xfs_dqrele_inode(ip, priv) (0) +# define xfs_dqrele_inode(ip, priv) ((void)0) #endif /* CONFIG_XFS_QUOTA */
/* @@ -1591,6 +1591,7 @@ xfs_blockgc_scan_inode( unlock: if (lockflags) xfs_iunlock(ip, lockflags); + xfs_irele(ip); return error; }
@@ -1697,8 +1698,7 @@ xfs_blockgc_free_quota(
/* * Decide if we want to grab this inode in anticipation of doing work towards - * the goal. If selected, the VFS must hold a reference to this inode, which - * will be released after processing. + * the goal. */ static inline bool xfs_icwalk_igrab( @@ -1715,24 +1715,26 @@ xfs_icwalk_igrab( } }
-/* Process an inode and release it. Return -EAGAIN to skip an inode. */ +/* + * Process an inode. Each processing function must handle any state changes + * made by the icwalk igrab function. Return -EAGAIN to skip an inode. + */ static inline int xfs_icwalk_process_inode( enum xfs_icwalk_goal goal, struct xfs_inode *ip, void *args) { - int error; + int error = 0;
switch (goal) { case XFS_ICWALK_DQRELE: - error = xfs_dqrele_inode(ip, args); + xfs_dqrele_inode(ip, args); break; case XFS_ICWALK_BLOCKGC: error = xfs_blockgc_scan_inode(ip, args); break; } - xfs_irele(ip); return error; }