330 mg->mg_activation_count = 0;
331
332 mg->mg_taskq = taskq_create("metaslab_group_tasksq", metaslab_load_pct,
333 minclsyspri, 10, INT_MAX, TASKQ_THREADS_CPU_PCT);
334
335 return (mg);
336 }
337
338 void
339 metaslab_group_destroy(metaslab_group_t *mg)
340 {
341 ASSERT(mg->mg_prev == NULL);
342 ASSERT(mg->mg_next == NULL);
343 /*
344 * We may have gone below zero with the activation count
345 * either because we never activated in the first place or
346 * because we're done, and possibly removing the vdev.
347 */
348 ASSERT(mg->mg_activation_count <= 0);
349
350 avl_destroy(&mg->mg_metaslab_tree);
351 mutex_destroy(&mg->mg_lock);
352 kmem_free(mg, sizeof (metaslab_group_t));
353 }
354
355 void
356 metaslab_group_activate(metaslab_group_t *mg)
357 {
358 metaslab_class_t *mc = mg->mg_class;
359 metaslab_group_t *mgprev, *mgnext;
360
361 ASSERT(spa_config_held(mc->mc_spa, SCL_ALLOC, RW_WRITER));
362
363 ASSERT(mc->mc_rotor != mg);
364 ASSERT(mg->mg_prev == NULL);
365 ASSERT(mg->mg_next == NULL);
366 ASSERT(mg->mg_activation_count <= 0);
367
368 if (++mg->mg_activation_count <= 0)
369 return;
|
330 mg->mg_activation_count = 0;
331
332 mg->mg_taskq = taskq_create("metaslab_group_tasksq", metaslab_load_pct,
333 minclsyspri, 10, INT_MAX, TASKQ_THREADS_CPU_PCT);
334
335 return (mg);
336 }
337
338 void
339 metaslab_group_destroy(metaslab_group_t *mg)
340 {
341 ASSERT(mg->mg_prev == NULL);
342 ASSERT(mg->mg_next == NULL);
343 /*
344 * We may have gone below zero with the activation count
345 * either because we never activated in the first place or
346 * because we're done, and possibly removing the vdev.
347 */
348 ASSERT(mg->mg_activation_count <= 0);
349
350 if (mg->mg_taskq) taskq_destroy(mg->mg_taskq);
351
352 avl_destroy(&mg->mg_metaslab_tree);
353 mutex_destroy(&mg->mg_lock);
354 kmem_free(mg, sizeof (metaslab_group_t));
355 }
356
357 void
358 metaslab_group_activate(metaslab_group_t *mg)
359 {
360 metaslab_class_t *mc = mg->mg_class;
361 metaslab_group_t *mgprev, *mgnext;
362
363 ASSERT(spa_config_held(mc->mc_spa, SCL_ALLOC, RW_WRITER));
364
365 ASSERT(mc->mc_rotor != mg);
366 ASSERT(mg->mg_prev == NULL);
367 ASSERT(mg->mg_next == NULL);
368 ASSERT(mg->mg_activation_count <= 0);
369
370 if (++mg->mg_activation_count <= 0)
371 return;
|