Disable direct reclaim in taskq worker threads on Linux 3.9+

Illumos does not have direct reclaim and code run inside taskq worker
threads is not designed to deal with it. Allowing direct reclaim inside
a worker thread can therefore deadlock. We set PF_MEMALLOC_NOIO through
memalloc_noio_save() to indicate to the kernel's reclaim code that we
are inside a context where memory allocations cannot be allowed to block
on filesystem activity.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue zfsonlinux/zfs#1274
Issue zfsonlinux/zfs#2390
Closes #474
This commit is contained in:
Richard Yao 2015-09-07 12:35:21 -04:00 committed by Brian Behlendorf
parent 4fa4cab972
commit d4bf6d8429

View File

@ -817,6 +817,10 @@ taskq_thread(void *args)
tq = tqt->tqt_tq; tq = tqt->tqt_tq;
current->flags |= PF_NOFREEZE; current->flags |= PF_NOFREEZE;
#if defined(PF_MEMALLOC_NOIO)
(void) memalloc_noio_save();
#endif
sigfillset(&blocked); sigfillset(&blocked);
sigprocmask(SIG_BLOCK, &blocked, NULL); sigprocmask(SIG_BLOCK, &blocked, NULL);
flush_signals(current); flush_signals(current);