1895 kstat_named_setstr(&zmp->zm_zonename, zone->zone_name);
1896 kstat_named_init(&zmp->zm_pgpgin, "pgpgin", KSTAT_DATA_UINT64);
1897 kstat_named_init(&zmp->zm_anonpgin, "anonpgin", KSTAT_DATA_UINT64);
1898 kstat_named_init(&zmp->zm_execpgin, "execpgin", KSTAT_DATA_UINT64);
1899 kstat_named_init(&zmp->zm_fspgin, "fspgin", KSTAT_DATA_UINT64);
1900 kstat_named_init(&zmp->zm_anon_alloc_fail, "anon_alloc_fail",
1901 KSTAT_DATA_UINT64);
1902
1903 ksp->ks_update = zone_mcap_kstat_update;
1904 ksp->ks_private = zone;
1905
1906 kstat_install(ksp);
1907 return (ksp);
1908 }
1909
1910 static int
1911 zone_misc_kstat_update(kstat_t *ksp, int rw)
1912 {
1913 zone_t *zone = ksp->ks_private;
1914 zone_misc_kstat_t *zmp = ksp->ks_data;
1915 hrtime_t tmp;
1916
1917 if (rw == KSTAT_WRITE)
1918 return (EACCES);
1919
1920 tmp = zone->zone_utime;
1921 scalehrtime(&tmp);
1922 zmp->zm_utime.value.ui64 = tmp;
1923 tmp = zone->zone_stime;
1924 scalehrtime(&tmp);
1925 zmp->zm_stime.value.ui64 = tmp;
1926 tmp = zone->zone_wtime;
1927 scalehrtime(&tmp);
1928 zmp->zm_wtime.value.ui64 = tmp;
1929
1930 zmp->zm_avenrun1.value.ui32 = zone->zone_avenrun[0];
1931 zmp->zm_avenrun5.value.ui32 = zone->zone_avenrun[1];
1932 zmp->zm_avenrun15.value.ui32 = zone->zone_avenrun[2];
1933
1934 zmp->zm_ffcap.value.ui32 = zone->zone_ffcap;
1935 zmp->zm_ffnoproc.value.ui32 = zone->zone_ffnoproc;
1936 zmp->zm_ffnomem.value.ui32 = zone->zone_ffnomem;
1937 zmp->zm_ffmisc.value.ui32 = zone->zone_ffmisc;
1938
1939 zmp->zm_nested_intp.value.ui32 = zone->zone_nested_intp;
1940
1941 zmp->zm_init_pid.value.ui32 = zone->zone_proc_initpid;
1942 zmp->zm_boot_time.value.ui64 = (uint64_t)zone->zone_boot_time;
1943
1944 return (0);
1945 }
1946
1947 static kstat_t *
1948 zone_misc_kstat_create(zone_t *zone)
1949 {
2080 zone0.zone_name = GLOBAL_ZONENAME;
2081 zone0.zone_nodename = utsname.nodename;
2082 zone0.zone_domain = srpc_domain;
2083 zone0.zone_hostid = HW_INVALID_HOSTID;
2084 zone0.zone_fs_allowed = NULL;
2085 psecflags_default(&zone0.zone_secflags);
2086 zone0.zone_ref = 1;
2087 zone0.zone_id = GLOBAL_ZONEID;
2088 zone0.zone_status = ZONE_IS_RUNNING;
2089 zone0.zone_rootpath = "/";
2090 zone0.zone_rootpathlen = 2;
2091 zone0.zone_psetid = ZONE_PS_INVAL;
2092 zone0.zone_ncpus = 0;
2093 zone0.zone_ncpus_online = 0;
2094 zone0.zone_proc_initpid = 1;
2095 zone0.zone_initname = initname;
2096 zone0.zone_lockedmem_kstat = NULL;
2097 zone0.zone_swapresv_kstat = NULL;
2098 zone0.zone_nprocs_kstat = NULL;
2099
2100 zone0.zone_stime = 0;
2101 zone0.zone_utime = 0;
2102 zone0.zone_wtime = 0;
2103
2104 list_create(&zone0.zone_ref_list, sizeof (zone_ref_t),
2105 offsetof(zone_ref_t, zref_linkage));
2106 list_create(&zone0.zone_zsd, sizeof (struct zsd_entry),
2107 offsetof(struct zsd_entry, zsd_linkage));
2108 list_insert_head(&zone_active, &zone0);
2109
2110 /*
2111 * The root filesystem is not mounted yet, so zone_rootvp cannot be set
2112 * to anything meaningful. It is assigned to be 'rootdir' in
2113 * vfs_mountroot().
2114 */
2115 zone0.zone_rootvp = NULL;
2116 zone0.zone_vfslist = NULL;
2117 zone0.zone_bootargs = initargs;
2118 zone0.zone_privset = kmem_alloc(sizeof (priv_set_t), KM_SLEEP);
2119 /*
2120 * The global zone has all privileges
2121 */
2122 priv_fillset(zone0.zone_privset);
2123 /*
2287 */
2288
2289 /*
2290 * Initialize global zone kstats
2291 */
2292 zone_kstat_create(&zone0);
2293
2294 /*
2295 * Initialize zone label.
2296 * mlp are initialized when tnzonecfg is loaded.
2297 */
2298 zone0.zone_slabel = l_admin_low;
2299 rw_init(&zone0.zone_mlps.mlpl_rwlock, NULL, RW_DEFAULT, NULL);
2300 label_hold(l_admin_low);
2301
2302 /*
2303 * Initialise the lock for the database structure used by mntfs.
2304 */
2305 rw_init(&zone0.zone_mntfs_db_lock, NULL, RW_DEFAULT, NULL);
2306
2307 mutex_enter(&zonehash_lock);
2308 zone_uniqid(&zone0);
2309 ASSERT(zone0.zone_uniqid == GLOBAL_ZONEUNIQID);
2310
2311 zonehashbyid = mod_hash_create_idhash("zone_by_id", zone_hash_size,
2312 mod_hash_null_valdtor);
2313 zonehashbyname = mod_hash_create_strhash("zone_by_name",
2314 zone_hash_size, mod_hash_null_valdtor);
2315 /*
2316 * maintain zonehashbylabel only for labeled systems
2317 */
2318 if (is_system_labeled())
2319 zonehashbylabel = mod_hash_create_extended("zone_by_label",
2320 zone_hash_size, mod_hash_null_keydtor,
2321 mod_hash_null_valdtor, hash_bylabel, NULL,
2322 hash_labelkey_cmp, KM_SLEEP);
2323 zonecount = 1;
2324
2325 (void) mod_hash_insert(zonehashbyid, (mod_hash_key_t)GLOBAL_ZONEID,
2326 (mod_hash_val_t)&zone0);
2371 /*
2372 * Remove any zone caps.
2373 */
2374 cpucaps_zone_remove(zone);
2375
2376 ASSERT(zone->zone_cpucap == NULL);
2377
2378 /* remove from deathrow list */
2379 if (zone_status_get(zone) == ZONE_IS_DEAD) {
2380 ASSERT(zone->zone_ref == 0);
2381 mutex_enter(&zone_deathrow_lock);
2382 list_remove(&zone_deathrow, zone);
2383 mutex_exit(&zone_deathrow_lock);
2384 }
2385
2386 list_destroy(&zone->zone_ref_list);
2387 zone_free_zsd(zone);
2388 zone_free_datasets(zone);
2389 list_destroy(&zone->zone_dl_list);
2390
2391 if (zone->zone_rootvp != NULL)
2392 VN_RELE(zone->zone_rootvp);
2393 if (zone->zone_rootpath)
2394 kmem_free(zone->zone_rootpath, zone->zone_rootpathlen);
2395 if (zone->zone_name != NULL)
2396 kmem_free(zone->zone_name, ZONENAME_MAX);
2397 if (zone->zone_slabel != NULL)
2398 label_rele(zone->zone_slabel);
2399 if (zone->zone_nodename != NULL)
2400 kmem_free(zone->zone_nodename, _SYS_NMLN);
2401 if (zone->zone_domain != NULL)
2402 kmem_free(zone->zone_domain, _SYS_NMLN);
2403 if (zone->zone_privset != NULL)
2404 kmem_free(zone->zone_privset, sizeof (priv_set_t));
2405 if (zone->zone_rctls != NULL)
2406 rctl_set_free(zone->zone_rctls);
2407 if (zone->zone_bootargs != NULL)
2408 strfree(zone->zone_bootargs);
2409 if (zone->zone_initname != NULL)
2410 strfree(zone->zone_initname);
3186 ASSERT(zret != NULL);
3187 status = zone_status_get(zret);
3188 if (status < ZONE_IS_READY || status > ZONE_IS_DOWN) {
3189 /*
3190 * Zone practically doesn't exist.
3191 */
3192 zret = global_zone;
3193 }
3194 zone_hold(zret);
3195 mutex_exit(&zonehash_lock);
3196 return (zret);
3197 }
3198
3199 /*
3200 * Public interface for updating per-zone load averages. Called once per
3201 * second.
3202 *
3203 * Based on loadavg_update(), genloadavg() and calcloadavg() from clock.c.
3204 */
3205 void
3206 zone_loadavg_update()
3207 {
3208 zone_t *zp;
3209 zone_status_t status;
3210 struct loadavg_s *lavg;
3211 hrtime_t zone_total;
3212 int i;
3213 hrtime_t hr_avg;
3214 int nrun;
3215 static int64_t f[3] = { 135, 27, 9 };
3216 int64_t q, r;
3217
3218 mutex_enter(&zonehash_lock);
3219 for (zp = list_head(&zone_active); zp != NULL;
3220 zp = list_next(&zone_active, zp)) {
3221 mutex_enter(&zp->zone_lock);
3222
3223 /* Skip zones that are on the way down or not yet up */
3224 status = zone_status_get(zp);
3225 if (status < ZONE_IS_READY || status >= ZONE_IS_DOWN) {
3226 /* For all practical purposes the zone doesn't exist. */
3227 mutex_exit(&zp->zone_lock);
3228 continue;
3229 }
3230
3231 /*
3232 * Update the 10 second moving average data in zone_loadavg.
3233 */
3234 lavg = &zp->zone_loadavg;
3235
3236 zone_total = zp->zone_utime + zp->zone_stime + zp->zone_wtime;
3237 scalehrtime(&zone_total);
3238
3239 /* The zone_total should always be increasing. */
3240 lavg->lg_loads[lavg->lg_cur] = (zone_total > lavg->lg_total) ?
3241 zone_total - lavg->lg_total : 0;
3242 lavg->lg_cur = (lavg->lg_cur + 1) % S_LOADAVG_SZ;
3243 /* lg_total holds the prev. 1 sec. total */
3244 lavg->lg_total = zone_total;
3245
3246 /*
3247 * To simplify the calculation, we don't calculate the load avg.
3248 * until the zone has been up for at least 10 seconds and our
3249 * moving average is thus full.
3250 */
3251 if ((lavg->lg_len + 1) < S_LOADAVG_SZ) {
3252 lavg->lg_len++;
3253 mutex_exit(&zp->zone_lock);
3254 continue;
3255 }
3256
4506 zone_free(zone);
4507 return (zone_create_error(error, 0, extended_error));
4508 }
4509
4510 /* initialize node name to be the same as zone name */
4511 zone->zone_nodename = kmem_alloc(_SYS_NMLN, KM_SLEEP);
4512 (void) strncpy(zone->zone_nodename, zone->zone_name, _SYS_NMLN);
4513 zone->zone_nodename[_SYS_NMLN - 1] = '\0';
4514
4515 zone->zone_domain = kmem_alloc(_SYS_NMLN, KM_SLEEP);
4516 zone->zone_domain[0] = '\0';
4517 zone->zone_hostid = HW_INVALID_HOSTID;
4518 zone->zone_shares = 1;
4519 zone->zone_shmmax = 0;
4520 zone->zone_ipc.ipcq_shmmni = 0;
4521 zone->zone_ipc.ipcq_semmni = 0;
4522 zone->zone_ipc.ipcq_msgmni = 0;
4523 zone->zone_bootargs = NULL;
4524 zone->zone_fs_allowed = NULL;
4525
4526 secflags_zero(&zone0.zone_secflags.psf_lower);
4527 secflags_zero(&zone0.zone_secflags.psf_effective);
4528 secflags_zero(&zone0.zone_secflags.psf_inherit);
4529 secflags_fullset(&zone0.zone_secflags.psf_upper);
4530
4531 zone->zone_initname =
4532 kmem_alloc(strlen(zone_default_initname) + 1, KM_SLEEP);
4533 (void) strcpy(zone->zone_initname, zone_default_initname);
4534 zone->zone_nlwps = 0;
4535 zone->zone_nlwps_ctl = INT_MAX;
4536 zone->zone_nprocs = 0;
4537 zone->zone_nprocs_ctl = INT_MAX;
4538 zone->zone_locked_mem = 0;
4539 zone->zone_locked_mem_ctl = UINT64_MAX;
4540 zone->zone_max_swap = 0;
4541 zone->zone_max_swap_ctl = UINT64_MAX;
4542 zone->zone_max_lofi = 0;
4543 zone->zone_max_lofi_ctl = UINT64_MAX;
4544 zone0.zone_lockedmem_kstat = NULL;
4545 zone0.zone_swapresv_kstat = NULL;
4546
4547 /*
4548 * Zsched initializes the rctls.
4549 */
4550 zone->zone_rctls = NULL;
4551
4552 if ((error = parse_rctls(rctlbuf, rctlbufsz, &rctls)) != 0) {
4553 zone_free(zone);
4554 return (zone_create_error(error, 0, extended_error));
4555 }
4556
4557 if ((error = parse_zfs(zone, zfsbuf, zfsbufsz)) != 0) {
4558 zone_free(zone);
4559 return (set_errno(error));
4560 }
4561
4562 /*
4563 * Read in the trusted system parameters:
4564 * match flag and sensitivity label.
4565 */
4566 zone->zone_match = match;
|
1895 kstat_named_setstr(&zmp->zm_zonename, zone->zone_name);
1896 kstat_named_init(&zmp->zm_pgpgin, "pgpgin", KSTAT_DATA_UINT64);
1897 kstat_named_init(&zmp->zm_anonpgin, "anonpgin", KSTAT_DATA_UINT64);
1898 kstat_named_init(&zmp->zm_execpgin, "execpgin", KSTAT_DATA_UINT64);
1899 kstat_named_init(&zmp->zm_fspgin, "fspgin", KSTAT_DATA_UINT64);
1900 kstat_named_init(&zmp->zm_anon_alloc_fail, "anon_alloc_fail",
1901 KSTAT_DATA_UINT64);
1902
1903 ksp->ks_update = zone_mcap_kstat_update;
1904 ksp->ks_private = zone;
1905
1906 kstat_install(ksp);
1907 return (ksp);
1908 }
1909
1910 static int
1911 zone_misc_kstat_update(kstat_t *ksp, int rw)
1912 {
1913 zone_t *zone = ksp->ks_private;
1914 zone_misc_kstat_t *zmp = ksp->ks_data;
1915 hrtime_t hrtime;
1916 uint64_t tmp;
1917
1918 if (rw == KSTAT_WRITE)
1919 return (EACCES);
1920
1921 tmp = cpu_uarray_sum(zone->zone_ustate, ZONE_USTATE_STIME);
1922 hrtime = UINT64_OVERFLOW_TO_INT64(tmp);
1923 scalehrtime(&hrtime);
1924 zmp->zm_stime.value.ui64 = hrtime;
1925
1926 tmp = cpu_uarray_sum(zone->zone_ustate, ZONE_USTATE_UTIME);
1927 hrtime = UINT64_OVERFLOW_TO_INT64(tmp);
1928 scalehrtime(&hrtime);
1929 zmp->zm_utime.value.ui64 = hrtime;
1930
1931 tmp = cpu_uarray_sum(zone->zone_ustate, ZONE_USTATE_WTIME);
1932 hrtime = UINT64_OVERFLOW_TO_INT64(tmp);
1933 scalehrtime(&hrtime);
1934 zmp->zm_wtime.value.ui64 = hrtime;
1935
1936 zmp->zm_avenrun1.value.ui32 = zone->zone_avenrun[0];
1937 zmp->zm_avenrun5.value.ui32 = zone->zone_avenrun[1];
1938 zmp->zm_avenrun15.value.ui32 = zone->zone_avenrun[2];
1939
1940 zmp->zm_ffcap.value.ui32 = zone->zone_ffcap;
1941 zmp->zm_ffnoproc.value.ui32 = zone->zone_ffnoproc;
1942 zmp->zm_ffnomem.value.ui32 = zone->zone_ffnomem;
1943 zmp->zm_ffmisc.value.ui32 = zone->zone_ffmisc;
1944
1945 zmp->zm_nested_intp.value.ui32 = zone->zone_nested_intp;
1946
1947 zmp->zm_init_pid.value.ui32 = zone->zone_proc_initpid;
1948 zmp->zm_boot_time.value.ui64 = (uint64_t)zone->zone_boot_time;
1949
1950 return (0);
1951 }
1952
1953 static kstat_t *
1954 zone_misc_kstat_create(zone_t *zone)
1955 {
2086 zone0.zone_name = GLOBAL_ZONENAME;
2087 zone0.zone_nodename = utsname.nodename;
2088 zone0.zone_domain = srpc_domain;
2089 zone0.zone_hostid = HW_INVALID_HOSTID;
2090 zone0.zone_fs_allowed = NULL;
2091 psecflags_default(&zone0.zone_secflags);
2092 zone0.zone_ref = 1;
2093 zone0.zone_id = GLOBAL_ZONEID;
2094 zone0.zone_status = ZONE_IS_RUNNING;
2095 zone0.zone_rootpath = "/";
2096 zone0.zone_rootpathlen = 2;
2097 zone0.zone_psetid = ZONE_PS_INVAL;
2098 zone0.zone_ncpus = 0;
2099 zone0.zone_ncpus_online = 0;
2100 zone0.zone_proc_initpid = 1;
2101 zone0.zone_initname = initname;
2102 zone0.zone_lockedmem_kstat = NULL;
2103 zone0.zone_swapresv_kstat = NULL;
2104 zone0.zone_nprocs_kstat = NULL;
2105
2106 list_create(&zone0.zone_ref_list, sizeof (zone_ref_t),
2107 offsetof(zone_ref_t, zref_linkage));
2108 list_create(&zone0.zone_zsd, sizeof (struct zsd_entry),
2109 offsetof(struct zsd_entry, zsd_linkage));
2110 list_insert_head(&zone_active, &zone0);
2111
2112 /*
2113 * The root filesystem is not mounted yet, so zone_rootvp cannot be set
2114 * to anything meaningful. It is assigned to be 'rootdir' in
2115 * vfs_mountroot().
2116 */
2117 zone0.zone_rootvp = NULL;
2118 zone0.zone_vfslist = NULL;
2119 zone0.zone_bootargs = initargs;
2120 zone0.zone_privset = kmem_alloc(sizeof (priv_set_t), KM_SLEEP);
2121 /*
2122 * The global zone has all privileges
2123 */
2124 priv_fillset(zone0.zone_privset);
2125 /*
2289 */
2290
2291 /*
2292 * Initialize global zone kstats
2293 */
2294 zone_kstat_create(&zone0);
2295
2296 /*
2297 * Initialize zone label.
2298 * mlp are initialized when tnzonecfg is loaded.
2299 */
2300 zone0.zone_slabel = l_admin_low;
2301 rw_init(&zone0.zone_mlps.mlpl_rwlock, NULL, RW_DEFAULT, NULL);
2302 label_hold(l_admin_low);
2303
2304 /*
2305 * Initialise the lock for the database structure used by mntfs.
2306 */
2307 rw_init(&zone0.zone_mntfs_db_lock, NULL, RW_DEFAULT, NULL);
2308
2309 zone0.zone_ustate = cpu_uarray_zalloc(ZONE_USTATE_MAX, KM_SLEEP);
2310
2311 mutex_enter(&zonehash_lock);
2312 zone_uniqid(&zone0);
2313 ASSERT(zone0.zone_uniqid == GLOBAL_ZONEUNIQID);
2314
2315 zonehashbyid = mod_hash_create_idhash("zone_by_id", zone_hash_size,
2316 mod_hash_null_valdtor);
2317 zonehashbyname = mod_hash_create_strhash("zone_by_name",
2318 zone_hash_size, mod_hash_null_valdtor);
2319 /*
2320 * maintain zonehashbylabel only for labeled systems
2321 */
2322 if (is_system_labeled())
2323 zonehashbylabel = mod_hash_create_extended("zone_by_label",
2324 zone_hash_size, mod_hash_null_keydtor,
2325 mod_hash_null_valdtor, hash_bylabel, NULL,
2326 hash_labelkey_cmp, KM_SLEEP);
2327 zonecount = 1;
2328
2329 (void) mod_hash_insert(zonehashbyid, (mod_hash_key_t)GLOBAL_ZONEID,
2330 (mod_hash_val_t)&zone0);
2375 /*
2376 * Remove any zone caps.
2377 */
2378 cpucaps_zone_remove(zone);
2379
2380 ASSERT(zone->zone_cpucap == NULL);
2381
2382 /* remove from deathrow list */
2383 if (zone_status_get(zone) == ZONE_IS_DEAD) {
2384 ASSERT(zone->zone_ref == 0);
2385 mutex_enter(&zone_deathrow_lock);
2386 list_remove(&zone_deathrow, zone);
2387 mutex_exit(&zone_deathrow_lock);
2388 }
2389
2390 list_destroy(&zone->zone_ref_list);
2391 zone_free_zsd(zone);
2392 zone_free_datasets(zone);
2393 list_destroy(&zone->zone_dl_list);
2394
2395 cpu_uarray_free(zone->zone_ustate);
2396
2397 if (zone->zone_rootvp != NULL)
2398 VN_RELE(zone->zone_rootvp);
2399 if (zone->zone_rootpath)
2400 kmem_free(zone->zone_rootpath, zone->zone_rootpathlen);
2401 if (zone->zone_name != NULL)
2402 kmem_free(zone->zone_name, ZONENAME_MAX);
2403 if (zone->zone_slabel != NULL)
2404 label_rele(zone->zone_slabel);
2405 if (zone->zone_nodename != NULL)
2406 kmem_free(zone->zone_nodename, _SYS_NMLN);
2407 if (zone->zone_domain != NULL)
2408 kmem_free(zone->zone_domain, _SYS_NMLN);
2409 if (zone->zone_privset != NULL)
2410 kmem_free(zone->zone_privset, sizeof (priv_set_t));
2411 if (zone->zone_rctls != NULL)
2412 rctl_set_free(zone->zone_rctls);
2413 if (zone->zone_bootargs != NULL)
2414 strfree(zone->zone_bootargs);
2415 if (zone->zone_initname != NULL)
2416 strfree(zone->zone_initname);
3192 ASSERT(zret != NULL);
3193 status = zone_status_get(zret);
3194 if (status < ZONE_IS_READY || status > ZONE_IS_DOWN) {
3195 /*
3196 * Zone practically doesn't exist.
3197 */
3198 zret = global_zone;
3199 }
3200 zone_hold(zret);
3201 mutex_exit(&zonehash_lock);
3202 return (zret);
3203 }
3204
3205 /*
3206 * Public interface for updating per-zone load averages. Called once per
3207 * second.
3208 *
3209 * Based on loadavg_update(), genloadavg() and calcloadavg() from clock.c.
3210 */
3211 void
3212 zone_loadavg_update(void)
3213 {
3214 zone_t *zp;
3215 zone_status_t status;
3216 struct loadavg_s *lavg;
3217 hrtime_t zone_total;
3218 uint64_t tmp;
3219 int i;
3220 hrtime_t hr_avg;
3221 int nrun;
3222 static int64_t f[3] = { 135, 27, 9 };
3223 int64_t q, r;
3224
3225 mutex_enter(&zonehash_lock);
3226 for (zp = list_head(&zone_active); zp != NULL;
3227 zp = list_next(&zone_active, zp)) {
3228 mutex_enter(&zp->zone_lock);
3229
3230 /* Skip zones that are on the way down or not yet up */
3231 status = zone_status_get(zp);
3232 if (status < ZONE_IS_READY || status >= ZONE_IS_DOWN) {
3233 /* For all practical purposes the zone doesn't exist. */
3234 mutex_exit(&zp->zone_lock);
3235 continue;
3236 }
3237
3238 /*
3239 * Update the 10 second moving average data in zone_loadavg.
3240 */
3241 lavg = &zp->zone_loadavg;
3242
3243 tmp = cpu_uarray_sum_all(zp->zone_ustate);
3244 zone_total = UINT64_OVERFLOW_TO_INT64(tmp);
3245
3246 scalehrtime(&zone_total);
3247
3248 /* The zone_total should always be increasing. */
3249 lavg->lg_loads[lavg->lg_cur] = (zone_total > lavg->lg_total) ?
3250 zone_total - lavg->lg_total : 0;
3251 lavg->lg_cur = (lavg->lg_cur + 1) % S_LOADAVG_SZ;
3252 /* lg_total holds the prev. 1 sec. total */
3253 lavg->lg_total = zone_total;
3254
3255 /*
3256 * To simplify the calculation, we don't calculate the load avg.
3257 * until the zone has been up for at least 10 seconds and our
3258 * moving average is thus full.
3259 */
3260 if ((lavg->lg_len + 1) < S_LOADAVG_SZ) {
3261 lavg->lg_len++;
3262 mutex_exit(&zp->zone_lock);
3263 continue;
3264 }
3265
4515 zone_free(zone);
4516 return (zone_create_error(error, 0, extended_error));
4517 }
4518
4519 /* initialize node name to be the same as zone name */
4520 zone->zone_nodename = kmem_alloc(_SYS_NMLN, KM_SLEEP);
4521 (void) strncpy(zone->zone_nodename, zone->zone_name, _SYS_NMLN);
4522 zone->zone_nodename[_SYS_NMLN - 1] = '\0';
4523
4524 zone->zone_domain = kmem_alloc(_SYS_NMLN, KM_SLEEP);
4525 zone->zone_domain[0] = '\0';
4526 zone->zone_hostid = HW_INVALID_HOSTID;
4527 zone->zone_shares = 1;
4528 zone->zone_shmmax = 0;
4529 zone->zone_ipc.ipcq_shmmni = 0;
4530 zone->zone_ipc.ipcq_semmni = 0;
4531 zone->zone_ipc.ipcq_msgmni = 0;
4532 zone->zone_bootargs = NULL;
4533 zone->zone_fs_allowed = NULL;
4534
4535 psecflags_default(&zone->zone_secflags);
4536
4537 zone->zone_initname =
4538 kmem_alloc(strlen(zone_default_initname) + 1, KM_SLEEP);
4539 (void) strcpy(zone->zone_initname, zone_default_initname);
4540 zone->zone_nlwps = 0;
4541 zone->zone_nlwps_ctl = INT_MAX;
4542 zone->zone_nprocs = 0;
4543 zone->zone_nprocs_ctl = INT_MAX;
4544 zone->zone_locked_mem = 0;
4545 zone->zone_locked_mem_ctl = UINT64_MAX;
4546 zone->zone_max_swap = 0;
4547 zone->zone_max_swap_ctl = UINT64_MAX;
4548 zone->zone_max_lofi = 0;
4549 zone->zone_max_lofi_ctl = UINT64_MAX;
4550 zone0.zone_lockedmem_kstat = NULL;
4551 zone0.zone_swapresv_kstat = NULL;
4552
4553 zone->zone_ustate = cpu_uarray_zalloc(ZONE_USTATE_MAX, KM_SLEEP);
4554
4555 /*
4556 * Zsched initializes the rctls.
4557 */
4558 zone->zone_rctls = NULL;
4559
4560 if ((error = parse_rctls(rctlbuf, rctlbufsz, &rctls)) != 0) {
4561 zone_free(zone);
4562 return (zone_create_error(error, 0, extended_error));
4563 }
4564
4565 if ((error = parse_zfs(zone, zfsbuf, zfsbufsz)) != 0) {
4566 zone_free(zone);
4567 return (set_errno(error));
4568 }
4569
4570 /*
4571 * Read in the trusted system parameters:
4572 * match flag and sensitivity label.
4573 */
4574 zone->zone_match = match;
|