]> granicus.if.org Git - zfs/commit
Fix deadlock in 'zfs rollback'
authorTom Caputi <tcaputi@datto.com>
Tue, 27 Aug 2019 16:55:51 +0000 (12:55 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 27 Aug 2019 16:55:51 +0000 (09:55 -0700)
commite7a2fa70c3b0d8c8cee2b484038bb5623c7c1ea9
treea216b26e20a92c1cd0635a19ab9a285ce5e6fda0
parent142f84dd19f20b47157bbbf45aaba489b6577c88
Fix deadlock in 'zfs rollback'

Currently, the 'zfs rollback' code can end up deadlocked due to
the way the kernel handles unreferenced inodes on a suspended fs.
Essentially, the zfs_resume_fs() code path may cause zfs to spawn
new threads as it reinstantiates the suspended fs's zil. When a
new thread is spawned, the kernel may attempt to free memory for
that thread by freeing some unreferenced inodes. If it happens to
select inodes that are a a part of the suspended fs a deadlock
will occur because freeing inodes requires holding the fs's
z_teardown_inactive_lock which is still held from the suspend.

This patch corrects this issue by adding an additional reference
to all inodes that are still present when a suspend is initiated.
This prevents them from being freed by the kernel for any reason.

Reviewed-by: Alek Pinchuk <apinchuk@datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #9203
include/sys/zfs_znode.h
module/zfs/zfs_vfsops.c
module/zfs/zfs_znode.c