zfsonlinux/zfs — pull request #2052 by behlendorf (2014-01-16 01:06:56+00:00)
Title: Annotate tasks which require KM_PUSHPAGE

When the txg_sync thread issues an I/O and blocks in zio_wait().
Then it is critical that all processes involved in handling that
I/O use KM_PUSHPAGE when performing allocations.

If they use KM_SLEEP then it is possible that during a low memory
condition direct reclaim will be invoked and it may attempt to
flush dirty data to the file system. This will result in the
thread attempting to assign a TX will block until the txg_sync
thread completes.

The end result is a deadlock with the txg_sync thread blocked on
the original I/O, and the taskq thread blocked on the txg_sync
thread.

To prevent developers from accidentally introducing this type
of deadlock. This patch passes the TQ_PUSHPAGE_THREAD flag when
dispatching a I/O to a taskq which the txg_sync thread is waiting
on. This causes the taskq thread to set the PF_NOFS flag in its
task struct while the zio_execute() function is being executed.
Thereby ensuring that any accidental misuse of the KM_SLEEP is
quickly causes and fixed.

Signed-off-by: Brian Behlendorf
Issue #1928