Print this page
patch zone
*** 574,584 ****
static struct zsd_entry *
zsd_find(list_t *l, zone_key_t key)
{
struct zsd_entry *zsd;
! for (zsd = list_head(l); zsd != NULL; zsd = list_next(l, zsd)) {
if (zsd->zsd_key == key) {
return (zsd);
}
}
return (NULL);
--- 574,584 ----
static struct zsd_entry *
zsd_find(list_t *l, zone_key_t key)
{
struct zsd_entry *zsd;
! list_for_each(l, zsd) {
if (zsd->zsd_key == key) {
return (zsd);
}
}
return (NULL);
*** 591,601 ****
static struct zsd_entry *
zsd_find_mru(list_t *l, zone_key_t key)
{
struct zsd_entry *zsd;
! for (zsd = list_head(l); zsd != NULL; zsd = list_next(l, zsd)) {
if (zsd->zsd_key == key) {
/*
* Move to head of list to keep list in MRU order.
*/
if (zsd != list_head(l)) {
--- 591,601 ----
static struct zsd_entry *
zsd_find_mru(list_t *l, zone_key_t key)
{
struct zsd_entry *zsd;
! list_for_each(l, zsd) {
if (zsd->zsd_key == key) {
/*
* Move to head of list to keep list in MRU order.
*/
if (zsd != list_head(l)) {
*** 636,647 ****
/*
* Insert for all existing zones and mark them as needing
* a create callback.
*/
mutex_enter(&zonehash_lock); /* stop the world */
! for (zone = list_head(&zone_active); zone != NULL;
! zone = list_next(&zone_active, zone)) {
zone_status_t status;
mutex_enter(&zone->zone_lock);
/* Skip zones that are on the way down or not yet up */
--- 636,646 ----
/*
* Insert for all existing zones and mark them as needing
* a create callback.
*/
mutex_enter(&zonehash_lock); /* stop the world */
! list_for_each(&zone_active, zone) {
zone_status_t status;
mutex_enter(&zone->zone_lock);
/* Skip zones that are on the way down or not yet up */
*** 713,724 ****
}
list_remove(&zsd_registered_keys, zsdp);
mutex_exit(&zsd_key_lock);
mutex_enter(&zonehash_lock);
! for (zone = list_head(&zone_active); zone != NULL;
! zone = list_next(&zone_active, zone)) {
struct zsd_entry *del;
mutex_enter(&zone->zone_lock);
del = zsd_find_mru(&zone->zone_zsd, key);
if (del == NULL) {
--- 712,722 ----
}
list_remove(&zsd_registered_keys, zsdp);
mutex_exit(&zsd_key_lock);
mutex_enter(&zonehash_lock);
! list_for_each(&zone_active, zone) {
struct zsd_entry *del;
mutex_enter(&zone->zone_lock);
del = zsd_find_mru(&zone->zone_zsd, key);
if (del == NULL) {
*** 752,763 ****
zsd_apply_all_zones(zsd_apply_shutdown, key);
zsd_apply_all_zones(zsd_apply_destroy, key);
/* Now we can free up the zsdp structures in each zone */
mutex_enter(&zonehash_lock);
! for (zone = list_head(&zone_active); zone != NULL;
! zone = list_next(&zone_active, zone)) {
struct zsd_entry *del;
mutex_enter(&zone->zone_lock);
del = zsd_find(&zone->zone_zsd, key);
if (del != NULL) {
--- 750,760 ----
zsd_apply_all_zones(zsd_apply_shutdown, key);
zsd_apply_all_zones(zsd_apply_destroy, key);
/* Now we can free up the zsdp structures in each zone */
mutex_enter(&zonehash_lock);
! list_for_each(&zone_active, zone) {
struct zsd_entry *del;
mutex_enter(&zone->zone_lock);
del = zsd_find(&zone->zone_zsd, key);
if (del != NULL) {
*** 829,840 ****
ASSERT(MUTEX_HELD(&zonehash_lock));
ASSERT(list_head(&zone->zone_zsd) == NULL);
mutex_enter(&zone->zone_lock);
mutex_enter(&zsd_key_lock);
! for (zsdp = list_head(&zsd_registered_keys); zsdp != NULL;
! zsdp = list_next(&zsd_registered_keys, zsdp)) {
/*
* Since this zone is ZONE_IS_UNCONFIGURED, zone_key_create
* should not have added anything to it.
*/
ASSERT(zsd_find(&zone->zone_zsd, zsdp->zsd_key) == NULL);
--- 826,836 ----
ASSERT(MUTEX_HELD(&zonehash_lock));
ASSERT(list_head(&zone->zone_zsd) == NULL);
mutex_enter(&zone->zone_lock);
mutex_enter(&zsd_key_lock);
! list_for_each(&zsd_registered_keys, zsdp) {
/*
* Since this zone is ZONE_IS_UNCONFIGURED, zone_key_create
* should not have added anything to it.
*/
ASSERT(zsd_find(&zone->zone_zsd, zsdp->zsd_key) == NULL);
*** 874,885 ****
* in zone_zsd. The global list can change independently of this
* as keys are registered and unregistered and we don't register new
* callbacks for a zone that is in the process of going away.
*/
mutex_enter(&zone->zone_lock);
! for (t = list_head(&zone->zone_zsd); t != NULL;
! t = list_next(&zone->zone_zsd, t)) {
zone_key_t key = t->zsd_key;
/* Skip if no callbacks registered */
if (ct == ZSD_SHUTDOWN) {
--- 870,880 ----
* in zone_zsd. The global list can change independently of this
* as keys are registered and unregistered and we don't register new
* callbacks for a zone that is in the process of going away.
*/
mutex_enter(&zone->zone_lock);
! list_for_each(&zone->zone_zsd, t) {
zone_key_t key = t->zsd_key;
/* Skip if no callbacks registered */
if (ct == ZSD_SHUTDOWN) {
*** 917,928 ****
/*
* Free all the zsd_entry's we had on this zone.
*/
mutex_enter(&zone->zone_lock);
! for (t = list_head(&zone->zone_zsd); t != NULL; t = next) {
! next = list_next(&zone->zone_zsd, t);
list_remove(&zone->zone_zsd, t);
ASSERT(!(t->zsd_flags & ZSD_ALL_INPROGRESS));
kmem_free(t, sizeof (*t));
}
list_destroy(&zone->zone_zsd);
--- 912,922 ----
/*
* Free all the zsd_entry's we had on this zone.
*/
mutex_enter(&zone->zone_lock);
! list_for_each_safe(&zone->zone_zsd, t, next) {
list_remove(&zone->zone_zsd, t);
ASSERT(!(t->zsd_flags & ZSD_ALL_INPROGRESS));
kmem_free(t, sizeof (*t));
}
list_destroy(&zone->zone_zsd);
*** 1299,1310 ****
static void
zone_free_datasets(zone_t *zone)
{
zone_dataset_t *t, *next;
! for (t = list_head(&zone->zone_datasets); t != NULL; t = next) {
! next = list_next(&zone->zone_datasets, t);
list_remove(&zone->zone_datasets, t);
kmem_free(t->zd_dataset, strlen(t->zd_dataset) + 1);
kmem_free(t, sizeof (*t));
}
list_destroy(&zone->zone_datasets);
--- 1293,1303 ----
static void
zone_free_datasets(zone_t *zone)
{
zone_dataset_t *t, *next;
! list_for_each_safe(&zone->zone_datasets, t, next) {
list_remove(&zone->zone_datasets, t);
kmem_free(t->zd_dataset, strlen(t->zd_dataset) + 1);
kmem_free(t, sizeof (*t));
}
list_destroy(&zone->zone_datasets);
*** 3037,3048 ****
zone_hold(global_zone);
return (global_zone);
}
ASSERT(*path == '/');
mutex_enter(&zonehash_lock);
! for (zone = list_head(&zone_active); zone != NULL;
! zone = list_next(&zone_active, zone)) {
if (ZONE_PATH_VISIBLE(path, zone))
zret = zone;
}
ASSERT(zret != NULL);
status = zone_status_get(zret);
--- 3030,3040 ----
zone_hold(global_zone);
return (global_zone);
}
ASSERT(*path == '/');
mutex_enter(&zonehash_lock);
! list_for_each(&zone_active, zone) {
if (ZONE_PATH_VISIBLE(path, zone))
zret = zone;
}
ASSERT(zret != NULL);
status = zone_status_get(zret);
*** 3256,3267 ****
zone_t *zone;
int ret = 0;
zone_status_t status;
mutex_enter(&zonehash_lock);
! for (zone = list_head(&zone_active); zone != NULL;
! zone = list_next(&zone_active, zone)) {
/*
* Skip zones that shouldn't be externally visible.
*/
status = zone_status_get(zone);
if (status < ZONE_IS_READY || status > ZONE_IS_DOWN)
--- 3248,3258 ----
zone_t *zone;
int ret = 0;
zone_status_t status;
mutex_enter(&zonehash_lock);
! list_for_each(&zone_active, zone) {
/*
* Skip zones that shouldn't be externally visible.
*/
status = zone_status_get(zone);
if (status < ZONE_IS_READY || status > ZONE_IS_DOWN)
*** 4048,4059 ****
*/
if ((rootpathlen <= 3) && (rootpath[0] == '/') &&
(rootpath[1] == '/') && (rootpath[2] == '\0'))
return (B_TRUE);
! for (zone = list_head(&zone_active); zone != NULL;
! zone = list_next(&zone_active, zone)) {
if (zone == global_zone)
continue;
len = strlen(zone->zone_rootpath);
if (strncmp(rootpath, zone->zone_rootpath,
MIN(rootpathlen, len)) == 0)
--- 4039,4049 ----
*/
if ((rootpathlen <= 3) && (rootpath[0] == '/') &&
(rootpath[1] == '/') && (rootpath[2] == '\0'))
return (B_TRUE);
! list_for_each(&zone_active, zone) {
if (zone == global_zone)
continue;
len = strlen(zone->zone_rootpath);
if (strncmp(rootpath, zone->zone_rootpath,
MIN(rootpathlen, len)) == 0)
*** 5730,5741 ****
* restarted init (or other zone-penetrating process) its
* predecessor's contracts.
*/
if (ctp->conp_ninherited != 0) {
contract_t *next;
! for (next = list_head(&ctp->conp_inherited); next;
! next = list_next(&ctp->conp_inherited, next)) {
if (contract_getzuniqid(next) != zone->zone_uniqid) {
mutex_exit(&pp->p_lock);
mutex_exit(&ct->ct_lock);
mutex_exit(&zonehash_lock);
err = EINVAL;
--- 5720,5730 ----
* restarted init (or other zone-penetrating process) its
* predecessor's contracts.
*/
if (ctp->conp_ninherited != 0) {
contract_t *next;
! list_for_each(&ctp->conp_inherited, next) {
if (contract_getzuniqid(next) != zone->zone_uniqid) {
mutex_exit(&pp->p_lock);
mutex_exit(&ct->ct_lock);
mutex_exit(&zonehash_lock);
err = EINVAL;
*** 6089,6101 ****
domi_nzones = 0;
if (real_nzones > 0) {
zoneids = kmem_alloc(real_nzones *
sizeof (zoneid_t), KM_SLEEP);
mybslab = label2bslabel(myzone->zone_slabel);
! for (zone = list_head(&zone_active);
! zone != NULL;
! zone = list_next(&zone_active, zone)) {
if (zone->zone_id == GLOBAL_ZONEID)
continue;
if (zone != myzone &&
(zone->zone_flags & ZF_IS_SCRATCH))
continue;
--- 6078,6088 ----
domi_nzones = 0;
if (real_nzones > 0) {
zoneids = kmem_alloc(real_nzones *
sizeof (zoneid_t), KM_SLEEP);
mybslab = label2bslabel(myzone->zone_slabel);
! list_for_each(&zone_active, zone) {
if (zone->zone_id == GLOBAL_ZONEID)
continue;
if (zone != myzone &&
(zone->zone_flags & ZF_IS_SCRATCH))
continue;
*** 6118,6129 ****
real_nzones = zonecount;
domi_nzones = 0;
if (real_nzones > 0) {
zoneids = kmem_alloc(real_nzones * sizeof (zoneid_t),
KM_SLEEP);
! for (zone = list_head(&zone_active); zone != NULL;
! zone = list_next(&zone_active, zone))
zoneids[domi_nzones++] = zone->zone_id;
ASSERT(domi_nzones == real_nzones);
}
mutex_exit(&zonehash_lock);
}
--- 6105,6115 ----
real_nzones = zonecount;
domi_nzones = 0;
if (real_nzones > 0) {
zoneids = kmem_alloc(real_nzones * sizeof (zoneid_t),
KM_SLEEP);
! list_for_each(&zone_active, zone)
zoneids[domi_nzones++] = zone->zone_id;
ASSERT(domi_nzones == real_nzones);
}
mutex_exit(&zonehash_lock);
}
*** 6584,6595 ****
* state during initialization, readying, or booting) or produce races.
* We'll let threads continue to initialize and ready new zones: they'll
* fail to boot the new zones when they see that the global zone is
* shutting down.
*/
! for (current_zonep = list_head(&zone_active); current_zonep != NULL;
! current_zonep = list_next(&zone_active, current_zonep)) {
if (zone_status_get(current_zonep) == ZONE_IS_RUNNING)
zone_status_set(current_zonep, ZONE_IS_SHUTTING_DOWN);
}
mutex_exit(&zone_status_lock);
mutex_exit(&zonehash_lock);
--- 6570,6580 ----
* state during initialization, readying, or booting) or produce races.
* We'll let threads continue to initialize and ready new zones: they'll
* fail to boot the new zones when they see that the global zone is
* shutting down.
*/
! list_for_each(&zone_active, cpurrent_zonep) {
if (zone_status_get(current_zonep) == ZONE_IS_RUNNING)
zone_status_set(current_zonep, ZONE_IS_SHUTTING_DOWN);
}
mutex_exit(&zone_status_lock);
mutex_exit(&zonehash_lock);
*** 6615,6627 ****
/*
* Walk the list once, looking for datasets which match exactly, or
* specify a dataset underneath an exported dataset. If found, return
* true and note that it is writable.
*/
! for (zd = list_head(&zone->zone_datasets); zd != NULL;
! zd = list_next(&zone->zone_datasets, zd)) {
!
len = strlen(zd->zd_dataset);
if (strlen(dataset) >= len &&
bcmp(dataset, zd->zd_dataset, len) == 0 &&
(dataset[len] == '\0' || dataset[len] == '/' ||
dataset[len] == '@')) {
--- 6600,6610 ----
/*
* Walk the list once, looking for datasets which match exactly, or
* specify a dataset underneath an exported dataset. If found, return
* true and note that it is writable.
*/
! list_for_each(&zone->zone_datasets, zd) {
len = strlen(zd->zd_dataset);
if (strlen(dataset) >= len &&
bcmp(dataset, zd->zd_dataset, len) == 0 &&
(dataset[len] == '\0' || dataset[len] == '/' ||
dataset[len] == '@')) {
*** 6636,6648 ****
* of exported datasets. These should be visible, but read-only.
*
* Note that we also have to support forms such as 'pool/dataset/', with
* a trailing slash.
*/
! for (zd = list_head(&zone->zone_datasets); zd != NULL;
! zd = list_next(&zone->zone_datasets, zd)) {
!
len = strlen(dataset);
if (dataset[len - 1] == '/')
len--; /* Ignore trailing slash */
if (len < strlen(zd->zd_dataset) &&
bcmp(dataset, zd->zd_dataset, len) == 0 &&
--- 6619,6629 ----
* of exported datasets. These should be visible, but read-only.
*
* Note that we also have to support forms such as 'pool/dataset/', with
* a trailing slash.
*/
! list_for_each(&zone->zone_dataset, zd) {
len = strlen(dataset);
if (dataset[len - 1] == '/')
len--; /* Ignore trailing slash */
if (len < strlen(zd->zd_dataset) &&
bcmp(dataset, zd->zd_dataset, len) == 0 &&
*** 6743,6754 ****
ASSERT(treat_abs);
path_offset = 1;
}
mutex_enter(&zonehash_lock);
! for (zone = list_head(&zone_active); zone != NULL;
! zone = list_next(&zone_active, zone)) {
char *c;
size_t pathlen;
char *rootpath_start;
if (zone == global_zone) /* skip global zone */
--- 6724,6734 ----
ASSERT(treat_abs);
path_offset = 1;
}
mutex_enter(&zonehash_lock);
! list_for_each(&zone_active, zone) {
char *c;
size_t pathlen;
char *rootpath_start;
if (zone == global_zone) /* skip global zone */
*** 6780,6791 ****
zone_find_dl(zone_t *zone, datalink_id_t linkid)
{
zone_dl_t *zdl;
ASSERT(mutex_owned(&zone->zone_lock));
! for (zdl = list_head(&zone->zone_dl_list); zdl != NULL;
! zdl = list_next(&zone->zone_dl_list, zdl)) {
if (zdl->zdl_id == linkid)
break;
}
return (zdl);
}
--- 6760,6770 ----
zone_find_dl(zone_t *zone, datalink_id_t linkid)
{
zone_dl_t *zdl;
ASSERT(mutex_owned(&zone->zone_lock));
! list_for_each(&zone->zone_dl_list, zdl) {
if (zdl->zdl_id == linkid)
break;
}
return (zdl);
}
*** 6814,6825 ****
if ((thiszone = zone_find_by_id(zoneid)) == NULL)
return (set_errno(ENXIO));
/* Verify that the datalink ID doesn't already belong to a zone. */
mutex_enter(&zonehash_lock);
! for (zone = list_head(&zone_active); zone != NULL;
! zone = list_next(&zone_active, zone)) {
if (zone_dl_exists(zone, linkid)) {
mutex_exit(&zonehash_lock);
zone_rele(thiszone);
return (set_errno((zone == thiszone) ? EEXIST : EPERM));
}
--- 6793,6803 ----
if ((thiszone = zone_find_by_id(zoneid)) == NULL)
return (set_errno(ENXIO));
/* Verify that the datalink ID doesn't already belong to a zone. */
mutex_enter(&zonehash_lock);
! list_for_each(&zone_active, zone) {
if (zone_dl_exists(zone, linkid)) {
mutex_exit(&zonehash_lock);
zone_rele(thiszone);
return (set_errno((zone == thiszone) ? EEXIST : EPERM));
}
*** 6879,6890 ****
}
return (err);
}
mutex_enter(&zonehash_lock);
! for (zone = list_head(&zone_active); zone != NULL;
! zone = list_next(&zone_active, zone)) {
if (zone_dl_exists(zone, linkid)) {
*zoneidp = zone->zone_id;
err = 0;
break;
}
--- 6857,6867 ----
}
return (err);
}
mutex_enter(&zonehash_lock);
! list_for_each(&zone_active, zone) {
if (zone_dl_exists(zone, linkid)) {
*zoneidp = zone->zone_id;
err = 0;
break;
}
*** 6915,6926 ****
if ((zone = zone_find_by_id(zoneid)) == NULL)
return (set_errno(ENXIO));
num = 0;
mutex_enter(&zone->zone_lock);
! for (zdl = list_head(&zone->zone_dl_list); zdl != NULL;
! zdl = list_next(&zone->zone_dl_list, zdl)) {
/*
* If the list is bigger than what the caller supplied, just
* count, don't do copyout.
*/
if (++num > dlcount)
--- 6892,6902 ----
if ((zone = zone_find_by_id(zoneid)) == NULL)
return (set_errno(ENXIO));
num = 0;
mutex_enter(&zone->zone_lock);
! list_for_each(&zone->zone_dl_list, zdl) {
/*
* If the list is bigger than what the caller supplied, just
* count, don't do copyout.
*/
if (++num > dlcount)
*** 6990,7001 ****
/*
* We first build an array of linkid's so that we can walk these and
* execute the callback with the zone_lock dropped.
*/
mutex_enter(&zone->zone_lock);
! for (zdl = list_head(&zone->zone_dl_list); zdl != NULL;
! zdl = list_next(&zone->zone_dl_list, zdl)) {
idcount++;
}
if (idcount == 0) {
mutex_exit(&zone->zone_lock);
--- 6966,6976 ----
/*
* We first build an array of linkid's so that we can walk these and
* execute the callback with the zone_lock dropped.
*/
mutex_enter(&zone->zone_lock);
! list_for_each(&zone->zone_dl_lists, zdl) {
idcount++;
}
if (idcount == 0) {
mutex_exit(&zone->zone_lock);
*** 7008,7020 ****
mutex_exit(&zone->zone_lock);
zone_rele(zone);
return (ENOMEM);
}
! for (i = 0, zdl = list_head(&zone->zone_dl_list); zdl != NULL;
! i++, zdl = list_next(&zone->zone_dl_list, zdl)) {
idarray[i] = zdl->zdl_id;
}
mutex_exit(&zone->zone_lock);
for (i = 0; i < idcount && ret == 0; i++) {
--- 6983,6996 ----
mutex_exit(&zone->zone_lock);
zone_rele(zone);
return (ENOMEM);
}
! i = 0;
! list_for_each(&zone->zone_dl_list, zdl) {
idarray[i] = zdl->zdl_id;
+ i++;
}
mutex_exit(&zone->zone_lock);
for (i = 0; i < idcount && ret == 0; i++) {