xfs
[Top] [All Lists]

[PATCH v2 2/2] xfs: disable log force in xfs_buf_item_push() to avoid xa

To: xfs@xxxxxxxxxxx
Subject: [PATCH v2 2/2] xfs: disable log force in xfs_buf_item_push() to avoid xa_lock recursion
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Wed, 6 Feb 2013 07:44:41 -0500
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1360154681-28246-1-git-send-email-bfoster@xxxxxxxxxx>
References: <1360154681-28246-1-git-send-email-bfoster@xxxxxxxxxx>
If the trylock fails and the buffer is pinned and stale, the
resulting xfs_log_force() can lead to lock recursion on the ailp
xa_lock. Call __xfs_buf_trylock() to attempt the buf lock with
xa_lock held, but to avoid the log force. If the trylock had raced
with the buffer being pinned, return XFS_ITEM_PINNED such that
xfsaild will pend up a log force on the next scan.

Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
---
 fs/xfs/xfs_buf_item.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 9c4c050..23a328e 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -469,8 +469,20 @@ xfs_buf_item_push(
 
        if (xfs_buf_ispinned(bp))
                return XFS_ITEM_PINNED;
-       if (!xfs_buf_trylock(bp))
+
+       if (!__xfs_buf_trylock(bp, false)) {
+               /*
+                * We disable the log force via trylock because the buffer can
+                * become pinned and stale after the trylock fails and the log
+                * force is unsafe with xa_lock held.
+                *
+                * Check the buffer state once more and return pinned such that
+                * xfsaild pends up the log force when it drops xa_lock.
+                */
+               if (xfs_buf_ispinned(bp))
+                       return XFS_ITEM_PINNED;
                return XFS_ITEM_LOCKED;
+       }
 
        ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
 
-- 
1.7.7.6

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