xfs
[Top] [All Lists]

[PATCH RFC 2/2] xfs: drop xa_lock around log force in xfs_buf_item push

To: xfs@xxxxxxxxxxx
Subject: [PATCH RFC 2/2] xfs: drop xa_lock around log force in xfs_buf_item push
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Tue, 29 Jan 2013 15:42:37 -0500
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1359492157-30521-1-git-send-email-bfoster@xxxxxxxxxx>
References: <1359492157-30521-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. We subsequently pull the
check and log force up into xfs_buf_item_push() where we can drop
and reacquire xa_lock appropriately.

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

diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 9c4c050..7b6e98a 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -469,8 +469,16 @@ xfs_buf_item_push(
 
        if (xfs_buf_ispinned(bp))
                return XFS_ITEM_PINNED;
-       if (!xfs_buf_trylock(bp))
+
+       if (!__xfs_buf_trylock(bp, false)) {
+               if (atomic_read(&bp->b_pin_count) &&
+                   (bp->b_flags & XBF_STALE)) {
+                       spin_unlock(&lip->li_ailp->xa_lock);
+                       xfs_log_force(bp->b_target->bt_mount, 0);
+                       spin_lock(&lip->li_ailp->xa_lock);
+               }
                return XFS_ITEM_LOCKED;
+       }
 
        ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
 
-- 
1.7.7.6

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