Skip to content

Commit dcfa98b

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: move some code out of xfs_iget_recycle
Having a function drop locks, reacquire them and release them again seems to confuse the clang lock analysis even more than it confuses humans. Keep the humans and machines sanity by moving a chunk of code into the caller to simplify the lock tracking. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 1cfe379 commit dcfa98b

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

fs/xfs/xfs_icache.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -358,28 +358,14 @@ xfs_reinit_inode(
358358
static int
359359
xfs_iget_recycle(
360360
struct xfs_perag *pag,
361-
struct xfs_inode *ip) __releases(&ip->i_flags_lock)
361+
struct xfs_inode *ip)
362362
{
363363
struct xfs_mount *mp = ip->i_mount;
364364
struct inode *inode = VFS_I(ip);
365365
int error;
366366

367367
trace_xfs_iget_recycle(ip);
368368

369-
if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL))
370-
return -EAGAIN;
371-
372-
/*
373-
* We need to make it look like the inode is being reclaimed to prevent
374-
* the actual reclaim workers from stomping over us while we recycle
375-
* the inode. We can't clear the radix tree tag yet as it requires
376-
* pag_ici_lock to be held exclusive.
377-
*/
378-
ip->i_flags |= XFS_IRECLAIM;
379-
380-
spin_unlock(&ip->i_flags_lock);
381-
rcu_read_unlock();
382-
383369
ASSERT(!rwsem_is_locked(&inode->i_rwsem));
384370
error = xfs_reinit_inode(mp, inode);
385371
xfs_iunlock(ip, XFS_ILOCK_EXCL);
@@ -576,10 +562,19 @@ xfs_iget_cache_hit(
576562

577563
/* The inode fits the selection criteria; process it. */
578564
if (ip->i_flags & XFS_IRECLAIMABLE) {
579-
/* Drops i_flags_lock and RCU read lock. */
580-
error = xfs_iget_recycle(pag, ip);
581-
if (error == -EAGAIN)
565+
/*
566+
* We need to make it look like the inode is being reclaimed to
567+
* prevent the actual reclaim workers from stomping over us
568+
* while we recycle the inode. We can't clear the radix tree
569+
* tag yet as it requires pag_ici_lock to be held exclusive.
570+
*/
571+
if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL))
582572
goto out_skip;
573+
ip->i_flags |= XFS_IRECLAIM;
574+
spin_unlock(&ip->i_flags_lock);
575+
rcu_read_unlock();
576+
577+
error = xfs_iget_recycle(pag, ip);
583578
if (error)
584579
return error;
585580
} else {

0 commit comments

Comments
 (0)