From: NeilBrown <neilb@suse.de>
Subject: XFS: force log before waiting for a pinned buffer
Patch-mainline: never
References: bnc#649473

If a buffer is pinned as well as locked, it will not get unlocked until the
next log-flush.
When _xfs_buf_find finds a locked buffer and needs to get the lock itself,
it should therefore force a log flush immedately to avoid having to wait
for up to 30 seconds.

Acked-by: NeilBrown <neilb@suse.de>
Signed-off-by: Neil Brown <neilb@suse.de>

---
 fs/xfs/linux-2.6/xfs_buf.c |    4 ++++
 1 file changed, 4 insertions(+)

--- linux-2.6.32-SLE11-SP1.orig/fs/xfs/linux-2.6/xfs_buf.c
+++ linux-2.6.32-SLE11-SP1/fs/xfs/linux-2.6/xfs_buf.c
@@ -548,6 +549,9 @@ found:
 	if (down_trylock(&bp->b_sema)) {
 		if (!(flags & XBF_TRYLOCK)) {
 			/* wait for buffer ownership */
+			if (XFS_BUF_ISPINNED(bp))
+				xfs_log_force(bp->b_mount,
+					      0, XFS_LOG_FORCE);
 			XB_TRACE(bp, "get_lock", 0);
 			xfs_buf_lock(bp);
 			XFS_STATS_INC(xb_get_locked_waited);
