if (err)
return (ERR_PTR(-err));
+ /*
+ * The dsl pool lock must be released prior to calling sget().
+ * It is possible sget() may block on the lock in grab_super()
+ * while deactivate_super() holds that same lock and waits for
+ * a txg sync. If the dsl_pool lock is held over over sget()
+ * this can prevent the pool sync and cause a deadlock.
+ */
+ dsl_pool_rele(dmu_objset_pool(os), FTAG);
s = zpl_sget(fs_type, zpl_test_super, set_anon_super, flags, os);
- dmu_objset_rele(os, FTAG);
+ dsl_dataset_rele(dmu_objset_ds(os), FTAG);
+
if (IS_ERR(s))
return (ERR_CAST(s));