Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d46be4a authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Felix Blyakher
Browse files

xfs: prevent lockdep false positive in xfs_iget_cache_miss



The inode can't be locked by anyone else as we just created it a few
lines above and it's not been added to any lookup data structure yet.

So use a trylock that must succeed to get around the lockdep warnings.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reported-by: default avatarAlexander Beregalov <a.beregalov@gmail.com>
Reviewed-by: default avatarEric Sandeen <sandeen@sandeen.net>
Reviewed-by: default avatarFelix Blyakher <felixb@sgi.com>
Signed-off-by: default avatarFelix Blyakher <felixb@sgi.com>
parent ff392c49
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -246,9 +246,6 @@ xfs_iget_cache_miss(
		goto out_destroy;
		goto out_destroy;
	}
	}


	if (lock_flags)
		xfs_ilock(ip, lock_flags);

	/*
	/*
	 * Preload the radix tree so we can insert safely under the
	 * Preload the radix tree so we can insert safely under the
	 * write spinlock. Note that we cannot sleep inside the preload
	 * write spinlock. Note that we cannot sleep inside the preload
@@ -256,7 +253,16 @@ xfs_iget_cache_miss(
	 */
	 */
	if (radix_tree_preload(GFP_KERNEL)) {
	if (radix_tree_preload(GFP_KERNEL)) {
		error = EAGAIN;
		error = EAGAIN;
		goto out_unlock;
		goto out_destroy;
	}

	/*
	 * Because the inode hasn't been added to the radix-tree yet it can't
	 * be found by another thread, so we can do the non-sleeping lock here.
	 */
	if (lock_flags) {
		if (!xfs_ilock_nowait(ip, lock_flags))
			BUG();
	}
	}


	mask = ~(((XFS_INODE_CLUSTER_SIZE(mp) >> mp->m_sb.sb_inodelog)) - 1);
	mask = ~(((XFS_INODE_CLUSTER_SIZE(mp) >> mp->m_sb.sb_inodelog)) - 1);
@@ -284,7 +290,6 @@ xfs_iget_cache_miss(
out_preload_end:
out_preload_end:
	write_unlock(&pag->pag_ici_lock);
	write_unlock(&pag->pag_ici_lock);
	radix_tree_preload_end();
	radix_tree_preload_end();
out_unlock:
	if (lock_flags)
	if (lock_flags)
		xfs_iunlock(ip, lock_flags);
		xfs_iunlock(ip, lock_flags);
out_destroy:
out_destroy: