]> git.karo-electronics.de Git - linux-beck.git/commitdiff
xfs: recheck buffer pinned status after push trylock failure
authorBrian Foster <bfoster@redhat.com>
Mon, 11 Feb 2013 15:08:21 +0000 (10:08 -0500)
committerBen Myers <bpm@sgi.com>
Thu, 14 Feb 2013 23:23:42 +0000 (17:23 -0600)
The buffer pinned check and trylock sequence in xfs_buf_item_push()
can race with an active transaction on marking the buffer pinned.
This can result in the buffer becoming pinned and stale after the
initial check and the trylock failure, but before the check in
xfs_buf_trylock() that issues a log force. If the log force is
issued from this context, a spinlock recursion occurs on xa_lock.

Prepare xfs_buf_item_push() to handle the race by detecting a
pinned buffer after the trylock failure so xfsaild issues a log
force from a safe context. This, along with various previous fixes,
renders the log force in xfs_buf_trylock() redundant.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
fs/xfs/xfs_buf_item.c

index 9c4c050e4270d8f68c6313c11f1d3644cd8b6dbd..cf263476d6b43591c5786045857f6e4625bde4ce 100644 (file)
@@ -469,8 +469,18 @@ xfs_buf_item_push(
 
        if (xfs_buf_ispinned(bp))
                return XFS_ITEM_PINNED;
-       if (!xfs_buf_trylock(bp))
+       if (!xfs_buf_trylock(bp)) {
+               /*
+                * If we have just raced with a buffer being pinned and it has
+                * been marked stale, we could end up stalling until someone else
+                * issues a log force to unpin the stale buffer. Check for the
+                * race condition here so xfsaild recognizes the buffer is pinned
+                * and queues a log force to move it along.
+                */
+               if (xfs_buf_ispinned(bp))
+                       return XFS_ITEM_PINNED;
                return XFS_ITEM_LOCKED;
+       }
 
        ASSERT(!(bip->bli_flags & XFS_BLI_STALE));