diff --git a/module/zfs/sa.c b/module/zfs/sa.c index 73afb5f00180..01ee45bb91e6 100644 --- a/module/zfs/sa.c +++ b/module/zfs/sa.c @@ -231,6 +231,9 @@ sa_cache_destructor(void *buf, void *unused) mutex_destroy(&hdl->sa_lock); } +static kmutex_t sa_id_lock; +static int sa_id = 0; + void sa_cache_init(void) { @@ -1017,8 +1020,12 @@ sa_setup(objset_t *os, uint64_t sa_obj, sa_attr_reg_t *reg_attrs, int count, mutex_init(&sa->sa_lock, NULL, MUTEX_NOLOCKDEP, NULL); sa->sa_master_obj = sa_obj; + mutex_enter(&sa_id_lock); + sa_id++; + mutex_exit(&sa_id_lock); + os->os_sa = sa; - mutex_enter(&sa->sa_lock); + mutex_enter_nested(&sa->sa_lock, sa_id); mutex_exit(&os->os_user_ptr_lock); avl_create(&sa->sa_layout_num_tree, layout_num_compare, sizeof (sa_lot_t), offsetof(sa_lot_t, lot_num_node));