diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index e3b27982b3b2..6c746d79925e 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3207,11 +3207,20 @@ xfs_iflush_cluster( */ spin_lock(&iq->i_flags_lock); if (!iq->i_ino || - __xfs_iflags_test(iq, XFS_ISTALE) || - (XFS_INO_TO_AGINO(mp, iq->i_ino) & mask) != first_index) { + __xfs_iflags_test(iq, XFS_ISTALE)) { spin_unlock(&iq->i_flags_lock); continue; } + + /* + * Once we fall off the end of the cluster, no point checking + * any more inodes in the list because they will also all be + * outside the cluster. + */ + if ((XFS_INO_TO_AGINO(mp, iq->i_ino) & mask) != first_index) { + spin_unlock(&iq->i_flags_lock); + break; + } spin_unlock(&iq->i_flags_lock); /*