xfs
[Top] [All Lists]

[RFC PATCH v2 3/3] xfs: fix xfsaild hang due to lost wake ups

To: xfs@xxxxxxxxxxx
Subject: [RFC PATCH v2 3/3] xfs: fix xfsaild hang due to lost wake ups
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Mon, 21 May 2012 14:49:29 -0400
Cc: Brian Foster <bfoster@xxxxxxxxxx>
In-reply-to: <1337626169-21730-1-git-send-email-bfoster@xxxxxxxxxx>
References: <1337626169-21730-1-git-send-email-bfoster@xxxxxxxxxx>
Running xfstests 273 in a loop reproduces an XFS lockup due to
xfsaild entering idle mode indefinitely. The following
high-level sequence of events leads to the hang:

- xfsaild is running with a cached target lsn
- xfs_ail_push() is invoked, updates ailp->xa_target_lsn and
  invokes wake_up_process(). wake_up_process() returns 0
  because xfsaild is already running.
- xfsaild enters idle mode having met its current target.

Once in the described state, xfs_ail_push() is invoked many
more times with the already set threshold_lsn, but these calls
do not lead to wake_up_process() calls because no further
invocations result in moving the threshold_lsn forward. Add a
flag to xfs_ail to capture whether an issued wake actually
succeeds. If not, continue issuing wakes until we know one has
been successful for the current target.

Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
---
 fs/xfs/xfs_trans_ail.c  |    4 ++--
 fs/xfs/xfs_trans_priv.h |    1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 8bc8aa2..e886785 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -583,7 +583,7 @@ xfs_ail_push(
 
        lip = xfs_ail_min(ailp);
        if (!lip || XFS_FORCED_SHUTDOWN(ailp->xa_mount) ||
-           XFS_LSN_CMP(threshold_lsn, ailp->xa_target) <= 0)
+           ((XFS_LSN_CMP(threshold_lsn, ailp->xa_target) <= 0) && 
!ailp->xa_pending_wake))
                return;
 
        /*
@@ -594,7 +594,7 @@ xfs_ail_push(
        xfs_trans_ail_copy_lsn(ailp, &ailp->xa_target, &threshold_lsn);
        smp_wmb();
 
-       wake_up_process(ailp->xa_task);
+       ailp->xa_pending_wake = !wake_up_process(ailp->xa_task);
 }
 
 /*
diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h
index 8ab2ced..62bb4a9 100644
--- a/fs/xfs/xfs_trans_priv.h
+++ b/fs/xfs/xfs_trans_priv.h
@@ -71,6 +71,7 @@ struct xfs_ail {
        spinlock_t              xa_lock;
        xfs_lsn_t               xa_last_pushed_lsn;
        int                     xa_log_flush;
+       int                     xa_pending_wake;
 };
 
 /*
-- 
1.7.7.6

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