[PATCH -stable] JFS: Fix race waking up jfsIO kernel thread

From: Dave Kleikamp
Date: Tue May 15 2007 - 23:53:55 EST


This patch fixes a deadlock that has been reported by three different
users on recent kernels. The problem exists on mainline kernels since
2.6.18. It is included in linux-2.6.22-rc1.

JFS: Fix race waking up jfsIO kernel thread

It's possible for a journal I/O request to be added to the log_redrive
queue and the jfsIO thread to be awakened after the thread releases
log_redrive_lock but before it sets its state to TASK_INTERRUPTIBLE.

The jfsIO thread should set the state before giving up the spinlock, so
the waking thread will really wake it.

Signed-off-by: Dave Kleikamp <shaggy@xxxxxxxxxxxxxxxxxx>

diff -Nurp linux-2.6.21.1/fs/jfs/jfs_logmgr.c linux/fs/jfs/jfs_logmgr.c
--- linux-2.6.21.1/fs/jfs/jfs_logmgr.c 2007-04-27 16:49:26.000000000 -0500
+++ linux/fs/jfs/jfs_logmgr.c 2007-05-15 22:39:31.000000000 -0500
@@ -2354,12 +2354,13 @@ int jfsIOWait(void *arg)
lbmStartIO(bp);
spin_lock_irq(&log_redrive_lock);
}
- spin_unlock_irq(&log_redrive_lock);

if (freezing(current)) {
+ spin_unlock_irq(&log_redrive_lock);
refrigerator();
} else {
set_current_state(TASK_INTERRUPTIBLE);
+ spin_unlock_irq(&log_redrive_lock);
schedule();
current->state = TASK_RUNNING;
}

--
David Kleikamp
IBM Linux Technology Center

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/