dn_struct_rwlock can not be held in dmu_tx_try_assign()
authorMatthew Ahrens <mahrens@delphix.com>
Sat, 22 Jun 2019 23:48:54 +0000 (16:48 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Sat, 22 Jun 2019 23:48:54 +0000 (16:48 -0700)
commitcb9e5b7e84654a8c7dba0f9a0d1227f3c8fa1012
tree27a4c56bed02bf6590a083d1a676ad8620564609
parentca4e5a785f844eaace4bf80cb70a3a02f1b587f6
dn_struct_rwlock can not be held in dmu_tx_try_assign()

The thread calling dmu_tx_try_assign() can't hold the dn_struct_rwlock
while assigning the tx, because this can lead to deadlock. Specifically,
if this dnode is already assigned to an earlier txg, this thread may
need to wait for that txg to sync (the ERESTART case below).  The other
thread that has assigned this dnode to an earlier txg prevents this txg
from syncing until its tx can complete (calling dmu_tx_commit()), but it
may need to acquire the dn_struct_rwlock to do so (e.g. via
dmu_buf_hold*()).

This commit adds an assertion to dmu_tx_try_assign() to ensure that this
deadlock is not inadvertently introduced.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8929
module/zfs/dmu_tx.c