mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +03:00
Fix race in dnode_check_slots_free()
Currently, dnode_check_slots_free() works by checking dn->dn_type in the dnode to determine if the dnode is reclaimable. However, there is a small window of time between dnode_free_sync() in the first call to dsl_dataset_sync() and when the useraccounting code is run when the type is set DMU_OT_NONE, but the dnode is not yet evictable, leading to crashes. This patch adds the ability for dnodes to track which txg they were last dirtied in and adds a check for this before performing the reclaim. This patch also corrects several instances when dn_dirty_link was treated as a list_node_t when it is technically a multilist_node_t. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Closes #7147 Closes #7388
This commit is contained in:
committed by
Brian Behlendorf
parent
10f88c5cd5
commit
edc1e713c2
@@ -1416,10 +1416,23 @@ dmu_objset_sync_dnodes(multilist_sublist_t *list, dmu_tx_t *tx)
|
||||
ASSERT3U(dn->dn_nlevels, <=, DN_MAX_LEVELS);
|
||||
multilist_sublist_remove(list, dn);
|
||||
|
||||
/*
|
||||
* If we are not doing useraccounting (os_synced_dnodes == NULL)
|
||||
* we are done with this dnode for this txg. Unset dn_dirty_txg
|
||||
* if later txgs aren't dirtying it so that future holders do
|
||||
* not get a stale value. Otherwise, we will do this in
|
||||
* userquota_updates_task() when processing has completely
|
||||
* finished for this txg.
|
||||
*/
|
||||
multilist_t *newlist = dn->dn_objset->os_synced_dnodes;
|
||||
if (newlist != NULL) {
|
||||
(void) dnode_add_ref(dn, newlist);
|
||||
multilist_insert(newlist, dn);
|
||||
} else {
|
||||
mutex_enter(&dn->dn_mtx);
|
||||
if (dn->dn_dirty_txg == tx->tx_txg)
|
||||
dn->dn_dirty_txg = 0;
|
||||
mutex_exit(&dn->dn_mtx);
|
||||
}
|
||||
|
||||
dnode_sync(dn, tx);
|
||||
@@ -1889,6 +1902,8 @@ userquota_updates_task(void *arg)
|
||||
dn->dn_id_flags |= DN_ID_CHKED_BONUS;
|
||||
}
|
||||
dn->dn_id_flags &= ~(DN_ID_NEW_EXIST);
|
||||
if (dn->dn_dirty_txg == spa_syncing_txg(os->os_spa))
|
||||
dn->dn_dirty_txg = 0;
|
||||
mutex_exit(&dn->dn_mtx);
|
||||
|
||||
multilist_sublist_remove(list, dn);
|
||||
|
||||
Reference in New Issue
Block a user