xfs
[Top] [All Lists]

[PATCH 08/11] xfs: xfs_iflush_cluster has range issues

To: xfs@xxxxxxxxxxx
Subject: [PATCH 08/11] xfs: xfs_iflush_cluster has range issues
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Wed, 13 Apr 2016 15:31:29 +1000
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1460525492-1170-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1460525492-1170-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

xfs_iflush_cluster() does a gang lookup on the radix tree, meaning
it can find inodes beyond the current cluster if there is sparse
cache population. gang lookups return results in ascending index
order, so stop trying to cluster inodes once the first inode outside
the cluster mask is detected.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx>
Reviewed-by: Christoph Hellwig <hch@xxxxxx>
Signed-off-by: Dave Chinner <david@xxxxxxxxxxxxx>
---
 fs/xfs/xfs_inode.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 8931375..26f22cb 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3194,11 +3194,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);
 
                /*
-- 
2.7.0

<Prev in Thread] Current Thread [Next in Thread>