6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2015 Joyent, Inc. All rights reserved.
24 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>.
26 */
27
28 #ifndef _SYS_ZONE_H
29 #define _SYS_ZONE_H
30
31 #include <sys/types.h>
32 #include <sys/mutex.h>
33 #include <sys/param.h>
34 #include <sys/rctl.h>
35 #include <sys/ipc_rctl.h>
36 #include <sys/pset.h>
37 #include <sys/tsol/label.h>
38 #include <sys/cred.h>
39 #include <sys/netstack.h>
40 #include <sys/uadmin.h>
41 #include <sys/ksynch.h>
42 #include <sys/socket_impl.h>
43 #include <netinet/in.h>
44
45 #ifdef __cplusplus
80 #define ZONE_BOOT 7
81 #define ZONE_VERSION 8
82 #define ZONE_SETATTR 9
83 #define ZONE_ADD_DATALINK 10
84 #define ZONE_DEL_DATALINK 11
85 #define ZONE_CHECK_DATALINK 12
86 #define ZONE_LIST_DATALINK 13
87
88 /* zone attributes */
89 #define ZONE_ATTR_ROOT 1
90 #define ZONE_ATTR_NAME 2
91 #define ZONE_ATTR_STATUS 3
92 #define ZONE_ATTR_PRIVSET 4
93 #define ZONE_ATTR_UNIQID 5
94 #define ZONE_ATTR_POOLID 6
95 #define ZONE_ATTR_INITPID 7
96 #define ZONE_ATTR_SLBL 8
97 #define ZONE_ATTR_INITNAME 9
98 #define ZONE_ATTR_BOOTARGS 10
99 #define ZONE_ATTR_BRAND 11
100 #define ZONE_ATTR_PHYS_MCAP 12
101 #define ZONE_ATTR_SCHED_CLASS 13
102 #define ZONE_ATTR_FLAGS 14
103 #define ZONE_ATTR_HOSTID 15
104 #define ZONE_ATTR_FS_ALLOWED 16
105 #define ZONE_ATTR_NETWORK 17
106 #define ZONE_ATTR_INITNORESTART 20
107
108 /* Start of the brand-specific attribute namespace */
109 #define ZONE_ATTR_BRAND_ATTRS 32768
110
111 #define ZONE_FS_ALLOWED_MAX 1024
112
113 #define ZONE_EVENT_CHANNEL "com.sun:zones:status"
114 #define ZONE_EVENT_STATUS_CLASS "status"
115 #define ZONE_EVENT_STATUS_SUBCLASS "change"
116
117 #define ZONE_EVENT_UNINITIALIZED "uninitialized"
118 #define ZONE_EVENT_INITIALIZED "initialized"
119 #define ZONE_EVENT_READY "ready"
120 #define ZONE_EVENT_RUNNING "running"
121 #define ZONE_EVENT_SHUTTING_DOWN "shutting_down"
122
123 #define ZONE_CB_NAME "zonename"
124 #define ZONE_CB_NEWSTATE "newstate"
125 #define ZONE_CB_OLDSTATE "oldstate"
126 #define ZONE_CB_TIMESTAMP "when"
227 ZONE_IS_DEAD
228 } zone_status_t;
229 #define ZONE_MIN_STATE ZONE_IS_UNINITIALIZED
230 #define ZONE_MAX_STATE ZONE_IS_DEAD
231
232 /*
233 * Valid commands which may be issued by zoneadm to zoneadmd. The kernel also
234 * communicates with zoneadmd, but only uses Z_REBOOT and Z_HALT.
235 */
236 typedef enum zone_cmd {
237 Z_READY, Z_BOOT, Z_FORCEBOOT, Z_REBOOT, Z_HALT, Z_NOTE_UNINSTALLING,
238 Z_MOUNT, Z_FORCEMOUNT, Z_UNMOUNT, Z_SHUTDOWN
239 } zone_cmd_t;
240
241 /*
242 * The structure of a request to zoneadmd.
243 */
244 typedef struct zone_cmd_arg {
245 uint64_t uniqid; /* unique "generation number" */
246 zone_cmd_t cmd; /* requested action */
247 uint32_t _pad; /* need consistent 32/64 bit alignmt */
248 char locale[MAXPATHLEN]; /* locale in which to render messages */
249 char bootbuf[BOOTARGS_MAX]; /* arguments passed to zone_boot() */
250 } zone_cmd_arg_t;
251
252 /*
253 * Structure of zoneadmd's response to a request. A NULL return value means
254 * the caller should attempt to restart zoneadmd and retry.
255 */
256 typedef struct zone_cmd_rval {
257 int rval; /* return value of request */
258 char errbuf[1]; /* variable-sized buffer containing error messages */
259 } zone_cmd_rval_t;
260
261 /*
262 * The zone support infrastructure uses the zone name as a component
263 * of unix domain (AF_UNIX) sockets, which are limited to 108 characters
264 * in length, so ZONENAME_MAX is limited by that.
265 */
266 #define ZONENAME_MAX 64
267
268 #define GLOBAL_ZONENAME "global"
269
372 } zone_dataset_t;
373
374 /*
375 * structure for zone kstats
376 */
377 typedef struct zone_kstat {
378 kstat_named_t zk_zonename;
379 kstat_named_t zk_usage;
380 kstat_named_t zk_value;
381 } zone_kstat_t;
382
383 struct cpucap;
384
385 typedef struct {
386 hrtime_t cycle_start;
387 uint_t cycle_cnt;
388 hrtime_t zone_avg_cnt;
389 } sys_zio_cntr_t;
390
391 typedef struct {
392 kstat_named_t zm_zonename;
393 kstat_named_t zm_pgpgin;
394 kstat_named_t zm_anonpgin;
395 kstat_named_t zm_execpgin;
396 kstat_named_t zm_fspgin;
397 kstat_named_t zm_anon_alloc_fail;
398 } zone_mcap_kstat_t;
399
400 typedef struct {
401 kstat_named_t zm_zonename; /* full name, kstat truncates name */
402 kstat_named_t zm_utime;
403 kstat_named_t zm_stime;
404 kstat_named_t zm_wtime;
405 kstat_named_t zm_avenrun1;
406 kstat_named_t zm_avenrun5;
407 kstat_named_t zm_avenrun15;
408 kstat_named_t zm_ffcap;
409 kstat_named_t zm_ffnoproc;
410 kstat_named_t zm_ffnomem;
411 kstat_named_t zm_ffmisc;
412 kstat_named_t zm_nested_intp;
413 kstat_named_t zm_init_pid;
414 kstat_named_t zm_boot_time;
415 } zone_misc_kstat_t;
416
417 typedef struct zone {
489 /* grab after p_lock, before rcs_lock */
490 rctl_qty_t zone_locked_mem; /* bytes of locked memory in */
491 /* zone */
492 rctl_qty_t zone_locked_mem_ctl; /* Current locked memory */
493 /* limit. Protected by */
494 /* zone_rctls->rcs_lock */
495 rctl_qty_t zone_max_swap; /* bytes of swap reserved by zone */
496 rctl_qty_t zone_max_swap_ctl; /* current swap limit. */
497 /* Protected by */
498 /* zone_rctls->rcs_lock */
499 kmutex_t zone_rctl_lock; /* protects zone_max_lofi */
500 rctl_qty_t zone_max_lofi; /* lofi devs for zone */
501 rctl_qty_t zone_max_lofi_ctl; /* current lofi limit. */
502 /* Protected by */
503 /* zone_rctls->rcs_lock */
504 list_t zone_zsd; /* list of Zone-Specific Data values */
505 kcondvar_t zone_cv; /* used to signal state changes */
506 struct proc *zone_zsched; /* Dummy kernel "zsched" process */
507 pid_t zone_proc_initpid; /* pid of "init" for this zone */
508 char *zone_initname; /* fs path to 'init' */
509 int zone_boot_err; /* for zone_boot() if boot fails */
510 char *zone_bootargs; /* arguments passed via zone_boot() */
511 uint64_t zone_phys_mcap; /* physical memory cap */
512 /*
513 * zone_kthreads is protected by zone_status_lock.
514 */
515 kthread_t *zone_kthreads; /* kernel threads in zone */
516 struct priv_set *zone_privset; /* limit set for zone */
517 /*
518 * zone_vfslist is protected by vfs_list_lock().
519 */
520 struct vfs *zone_vfslist; /* list of FS's mounted in zone */
521 uint64_t zone_uniqid; /* unique zone generation number */
522 struct cred *zone_kcred; /* kcred-like, zone-limited cred */
523 /*
524 * zone_pool is protected by pool_lock().
525 */
526 struct pool *zone_pool; /* pool the zone is bound to */
527 hrtime_t zone_pool_mod; /* last pool bind modification time */
528 /* zone_psetid is protected by cpu_lock */
529 psetid_t zone_psetid; /* pset the zone is bound to */
530
531 time_t zone_boot_time; /* Similar to boot_time */
532
533 /*
534 * The following two can be read without holding any locks. They are
535 * updated under cpu_lock.
536 */
537 int zone_ncpus; /* zone's idea of ncpus */
538 int zone_ncpus_online; /* zone's idea of ncpus_online */
539 /*
540 * List of ZFS datasets exported to this zone.
541 */
542 list_t zone_datasets; /* list of datasets */
543
544 ts_label_t *zone_slabel; /* zone sensitivity label */
545 int zone_match; /* require label match for packets */
546 tsol_mlp_list_t zone_mlps; /* MLPs on zone-private addresses */
547
548 boolean_t zone_restart_init; /* Restart init if it dies? */
549 struct brand *zone_brand; /* zone's brand */
550 void *zone_brand_data; /* store brand specific data */
551 id_t zone_defaultcid; /* dflt scheduling class id */
552 kstat_t *zone_swapresv_kstat;
553 kstat_t *zone_lockedmem_kstat;
554 /*
555 * zone_dl_list is protected by zone_lock
556 */
557 list_t zone_dl_list;
558 netstack_t *zone_netstack;
559 struct cpucap *zone_cpucap; /* CPU caps data */
560
561 /*
562 * Data and counters used for ZFS fair-share disk IO.
563 */
564 rctl_qty_t zone_zfs_io_pri; /* ZFS IO priority */
565 uint_t zone_zfs_queued[2]; /* sync I/O enqueued count */
566 uint64_t zone_zfs_weight; /* used to prevent starvation */
567 uint64_t zone_io_util; /* IO utilization metric */
568 boolean_t zone_io_util_above_avg; /* IO util percent > avg. */
569 uint16_t zone_io_delay; /* IO delay on logical r/w */
570 kmutex_t zone_stg_io_lock; /* protects IO window data */
571 sys_zio_cntr_t zone_rd_ops; /* Counters for ZFS reads, */
572 sys_zio_cntr_t zone_wr_ops; /* writes and */
573 sys_zio_cntr_t zone_lwr_ops; /* logical writes. */
574
575 /*
576 * Solaris Auditing per-zone audit context
577 */
578 struct au_kcontext *zone_audit_kctxt;
579 /*
580 * For private use by mntfs.
581 */
582 struct mntelem *zone_mntfs_db;
583 krwlock_t zone_mntfs_db_lock;
584
585 struct klpd_reg *zone_pfexecd;
586
587 char *zone_fs_allowed;
588 rctl_qty_t zone_nprocs; /* number of processes in the zone */
589 rctl_qty_t zone_nprocs_ctl; /* current limit protected by */
590 /* zone_rctls->rcs_lock */
591 kstat_t *zone_nprocs_kstat;
592
593 kmutex_t zone_mcap_lock; /* protects mcap statistics */
594 kstat_t *zone_mcap_ksp;
595 zone_mcap_kstat_t *zone_mcap_stats;
596 uint64_t zone_pgpgin; /* pages paged in */
597 uint64_t zone_anonpgin; /* anon pages paged in */
598 uint64_t zone_execpgin; /* exec pages paged in */
599 uint64_t zone_fspgin; /* fs pages paged in */
600 uint64_t zone_anon_alloc_fail; /* cnt of anon alloc fails */
601
602 /*
603 * Misc. kstats and counters for zone cpu-usage aggregation.
604 * The zone_Xtime values are the sum of the micro-state accounting
605 * values for all threads that are running or have run in the zone.
606 * This is tracked in msacct.c as threads change state.
607 * The zone_stime is the sum of the LMS_SYSTEM times.
608 * The zone_utime is the sum of the LMS_USER times.
609 * The zone_wtime is the sum of the LMS_WAIT_CPU times.
610 * As with per-thread micro-state accounting values, these values are
611 * not scaled to nanosecs. The scaling is done by the
612 * zone_misc_kstat_update function when kstats are requested.
613 */
614 kmutex_t zone_misc_lock; /* protects misc statistics */
615 kstat_t *zone_misc_ksp;
616 zone_misc_kstat_t *zone_misc_stats;
617 uint64_t zone_stime; /* total system time */
618 uint64_t zone_utime; /* total user time */
619 uint64_t zone_wtime; /* total time waiting in runq */
620 /* fork-fail kstat tracking */
621 uint32_t zone_ffcap; /* hit an rctl cap */
842 */
843 extern struct pool *zone_pool_get(zone_t *);
844 extern void zone_pool_set(zone_t *, struct pool *);
845
846 /*
847 * Get/set the pset the zone is currently using.
848 */
849 extern psetid_t zone_pset_get(zone_t *);
850 extern void zone_pset_set(zone_t *, psetid_t);
851
852 /*
853 * Get the number of cpus/online-cpus visible from the given zone.
854 */
855 extern int zone_ncpus_get(zone_t *);
856 extern int zone_ncpus_online_get(zone_t *);
857
858 /*
859 * Returns true if the named pool/dataset is visible in the current zone.
860 */
861 extern int zone_dataset_visible(const char *, int *);
862
863 /*
864 * zone version of kadmin()
865 */
866 extern int zone_kadmin(int, int, const char *, cred_t *);
867 extern void zone_shutdown_global(void);
868
869 extern void mount_in_progress(zone_t *);
870 extern void mount_completed(zone_t *);
871
872 extern int zone_walk(int (*)(zone_t *, void *), void *);
873
874 extern rctl_hndl_t rc_zone_locked_mem;
875 extern rctl_hndl_t rc_zone_max_swap;
876 extern rctl_hndl_t rc_zone_max_lofi;
877
878 #endif /* _KERNEL */
879
880 #ifdef __cplusplus
881 }
882 #endif
883
884 #endif /* _SYS_ZONE_H */
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2015 Joyent, Inc. All rights reserved.
24 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>.
26 * Copyright 2016, Joyent, Inc.
27 */
28
29 #ifndef _SYS_ZONE_H
30 #define _SYS_ZONE_H
31
32 #include <sys/types.h>
33 #include <sys/mutex.h>
34 #include <sys/param.h>
35 #include <sys/rctl.h>
36 #include <sys/ipc_rctl.h>
37 #include <sys/pset.h>
38 #include <sys/tsol/label.h>
39 #include <sys/cred.h>
40 #include <sys/netstack.h>
41 #include <sys/uadmin.h>
42 #include <sys/ksynch.h>
43 #include <sys/socket_impl.h>
44 #include <netinet/in.h>
45
46 #ifdef __cplusplus
81 #define ZONE_BOOT 7
82 #define ZONE_VERSION 8
83 #define ZONE_SETATTR 9
84 #define ZONE_ADD_DATALINK 10
85 #define ZONE_DEL_DATALINK 11
86 #define ZONE_CHECK_DATALINK 12
87 #define ZONE_LIST_DATALINK 13
88
89 /* zone attributes */
90 #define ZONE_ATTR_ROOT 1
91 #define ZONE_ATTR_NAME 2
92 #define ZONE_ATTR_STATUS 3
93 #define ZONE_ATTR_PRIVSET 4
94 #define ZONE_ATTR_UNIQID 5
95 #define ZONE_ATTR_POOLID 6
96 #define ZONE_ATTR_INITPID 7
97 #define ZONE_ATTR_SLBL 8
98 #define ZONE_ATTR_INITNAME 9
99 #define ZONE_ATTR_BOOTARGS 10
100 #define ZONE_ATTR_BRAND 11
101 #define ZONE_ATTR_PMCAP_NOVER 12
102 #define ZONE_ATTR_SCHED_CLASS 13
103 #define ZONE_ATTR_FLAGS 14
104 #define ZONE_ATTR_HOSTID 15
105 #define ZONE_ATTR_FS_ALLOWED 16
106 #define ZONE_ATTR_NETWORK 17
107 #define ZONE_ATTR_DID 18
108 #define ZONE_ATTR_PMCAP_PAGEOUT 19
109 #define ZONE_ATTR_INITNORESTART 20
110 #define ZONE_ATTR_PG_FLT_DELAY 21
111 #define ZONE_ATTR_RSS 22
112 #define ZONE_ATTR_APP_SVC_CT 23
113 #define ZONE_ATTR_SCHED_FIXEDHI 24
114
115 /* Start of the brand-specific attribute namespace */
116 #define ZONE_ATTR_BRAND_ATTRS 32768
117
118 #define ZONE_FS_ALLOWED_MAX 1024
119
120 #define ZONE_EVENT_CHANNEL "com.sun:zones:status"
121 #define ZONE_EVENT_STATUS_CLASS "status"
122 #define ZONE_EVENT_STATUS_SUBCLASS "change"
123
124 #define ZONE_EVENT_UNINITIALIZED "uninitialized"
125 #define ZONE_EVENT_INITIALIZED "initialized"
126 #define ZONE_EVENT_READY "ready"
127 #define ZONE_EVENT_RUNNING "running"
128 #define ZONE_EVENT_SHUTTING_DOWN "shutting_down"
129
130 #define ZONE_CB_NAME "zonename"
131 #define ZONE_CB_NEWSTATE "newstate"
132 #define ZONE_CB_OLDSTATE "oldstate"
133 #define ZONE_CB_TIMESTAMP "when"
234 ZONE_IS_DEAD
235 } zone_status_t;
236 #define ZONE_MIN_STATE ZONE_IS_UNINITIALIZED
237 #define ZONE_MAX_STATE ZONE_IS_DEAD
238
239 /*
240 * Valid commands which may be issued by zoneadm to zoneadmd. The kernel also
241 * communicates with zoneadmd, but only uses Z_REBOOT and Z_HALT.
242 */
243 typedef enum zone_cmd {
244 Z_READY, Z_BOOT, Z_FORCEBOOT, Z_REBOOT, Z_HALT, Z_NOTE_UNINSTALLING,
245 Z_MOUNT, Z_FORCEMOUNT, Z_UNMOUNT, Z_SHUTDOWN
246 } zone_cmd_t;
247
248 /*
249 * The structure of a request to zoneadmd.
250 */
251 typedef struct zone_cmd_arg {
252 uint64_t uniqid; /* unique "generation number" */
253 zone_cmd_t cmd; /* requested action */
254 int status; /* init status on shutdown */
255 uint32_t debug; /* enable brand hook debug */
256 char locale[MAXPATHLEN]; /* locale in which to render messages */
257 char bootbuf[BOOTARGS_MAX]; /* arguments passed to zone_boot() */
258 /* Needed for 32/64 zoneadm -> zoneadmd door arg size check. */
259 int pad;
260 } zone_cmd_arg_t;
261
262 /*
263 * Structure of zoneadmd's response to a request. A NULL return value means
264 * the caller should attempt to restart zoneadmd and retry.
265 */
266 typedef struct zone_cmd_rval {
267 int rval; /* return value of request */
268 char errbuf[1]; /* variable-sized buffer containing error messages */
269 } zone_cmd_rval_t;
270
271 /*
272 * The zone support infrastructure uses the zone name as a component
273 * of unix domain (AF_UNIX) sockets, which are limited to 108 characters
274 * in length, so ZONENAME_MAX is limited by that.
275 */
276 #define ZONENAME_MAX 64
277
278 #define GLOBAL_ZONENAME "global"
279
382 } zone_dataset_t;
383
384 /*
385 * structure for zone kstats
386 */
387 typedef struct zone_kstat {
388 kstat_named_t zk_zonename;
389 kstat_named_t zk_usage;
390 kstat_named_t zk_value;
391 } zone_kstat_t;
392
393 struct cpucap;
394
395 typedef struct {
396 hrtime_t cycle_start;
397 uint_t cycle_cnt;
398 hrtime_t zone_avg_cnt;
399 } sys_zio_cntr_t;
400
401 typedef struct {
402 kstat_named_t zv_zonename;
403 kstat_named_t zv_nread;
404 kstat_named_t zv_reads;
405 kstat_named_t zv_rtime;
406 kstat_named_t zv_rlentime;
407 kstat_named_t zv_rcnt;
408 kstat_named_t zv_nwritten;
409 kstat_named_t zv_writes;
410 kstat_named_t zv_wtime;
411 kstat_named_t zv_wlentime;
412 kstat_named_t zv_wcnt;
413 kstat_named_t zv_10ms_ops;
414 kstat_named_t zv_100ms_ops;
415 kstat_named_t zv_1s_ops;
416 kstat_named_t zv_10s_ops;
417 kstat_named_t zv_delay_cnt;
418 kstat_named_t zv_delay_time;
419 } zone_vfs_kstat_t;
420
421 typedef struct {
422 kstat_named_t zz_zonename;
423 kstat_named_t zz_nread;
424 kstat_named_t zz_reads;
425 kstat_named_t zz_rtime;
426 kstat_named_t zz_rlentime;
427 kstat_named_t zz_nwritten;
428 kstat_named_t zz_writes;
429 kstat_named_t zz_waittime;
430 } zone_zfs_kstat_t;
431
432 typedef struct {
433 kstat_named_t zm_zonename;
434 kstat_named_t zm_rss;
435 kstat_named_t zm_phys_cap;
436 kstat_named_t zm_swap;
437 kstat_named_t zm_swap_cap;
438 kstat_named_t zm_nover;
439 kstat_named_t zm_pagedout;
440 kstat_named_t zm_pgpgin;
441 kstat_named_t zm_anonpgin;
442 kstat_named_t zm_execpgin;
443 kstat_named_t zm_fspgin;
444 kstat_named_t zm_anon_alloc_fail;
445 kstat_named_t zm_pf_throttle;
446 kstat_named_t zm_pf_throttle_usec;
447 } zone_mcap_kstat_t;
448
449 typedef struct {
450 kstat_named_t zm_zonename; /* full name, kstat truncates name */
451 kstat_named_t zm_utime;
452 kstat_named_t zm_stime;
453 kstat_named_t zm_wtime;
454 kstat_named_t zm_avenrun1;
455 kstat_named_t zm_avenrun5;
456 kstat_named_t zm_avenrun15;
457 kstat_named_t zm_ffcap;
458 kstat_named_t zm_ffnoproc;
459 kstat_named_t zm_ffnomem;
460 kstat_named_t zm_ffmisc;
461 kstat_named_t zm_nested_intp;
462 kstat_named_t zm_init_pid;
463 kstat_named_t zm_boot_time;
464 } zone_misc_kstat_t;
465
466 typedef struct zone {
538 /* grab after p_lock, before rcs_lock */
539 rctl_qty_t zone_locked_mem; /* bytes of locked memory in */
540 /* zone */
541 rctl_qty_t zone_locked_mem_ctl; /* Current locked memory */
542 /* limit. Protected by */
543 /* zone_rctls->rcs_lock */
544 rctl_qty_t zone_max_swap; /* bytes of swap reserved by zone */
545 rctl_qty_t zone_max_swap_ctl; /* current swap limit. */
546 /* Protected by */
547 /* zone_rctls->rcs_lock */
548 kmutex_t zone_rctl_lock; /* protects zone_max_lofi */
549 rctl_qty_t zone_max_lofi; /* lofi devs for zone */
550 rctl_qty_t zone_max_lofi_ctl; /* current lofi limit. */
551 /* Protected by */
552 /* zone_rctls->rcs_lock */
553 list_t zone_zsd; /* list of Zone-Specific Data values */
554 kcondvar_t zone_cv; /* used to signal state changes */
555 struct proc *zone_zsched; /* Dummy kernel "zsched" process */
556 pid_t zone_proc_initpid; /* pid of "init" for this zone */
557 char *zone_initname; /* fs path to 'init' */
558 int zone_init_status; /* init's exit status */
559 int zone_boot_err; /* for zone_boot() if boot fails */
560 char *zone_bootargs; /* arguments passed via zone_boot() */
561 rctl_qty_t zone_phys_mem_ctl; /* current phys. memory limit */
562 /*
563 * zone_kthreads is protected by zone_status_lock.
564 */
565 kthread_t *zone_kthreads; /* kernel threads in zone */
566 struct priv_set *zone_privset; /* limit set for zone */
567 /*
568 * zone_vfslist is protected by vfs_list_lock().
569 */
570 struct vfs *zone_vfslist; /* list of FS's mounted in zone */
571 uint64_t zone_uniqid; /* unique zone generation number */
572 struct cred *zone_kcred; /* kcred-like, zone-limited cred */
573 /*
574 * zone_pool is protected by pool_lock().
575 */
576 struct pool *zone_pool; /* pool the zone is bound to */
577 hrtime_t zone_pool_mod; /* last pool bind modification time */
578 /* zone_psetid is protected by cpu_lock */
579 psetid_t zone_psetid; /* pset the zone is bound to */
580
581 time_t zone_boot_time; /* Similar to boot_time */
582
583 /*
584 * The following two can be read without holding any locks. They are
585 * updated under cpu_lock.
586 */
587 int zone_ncpus; /* zone's idea of ncpus */
588 int zone_ncpus_online; /* zone's idea of ncpus_online */
589 /*
590 * List of ZFS datasets exported to this zone.
591 */
592 list_t zone_datasets; /* list of datasets */
593
594 ts_label_t *zone_slabel; /* zone sensitivity label */
595 int zone_match; /* require label match for packets */
596 tsol_mlp_list_t zone_mlps; /* MLPs on zone-private addresses */
597
598 boolean_t zone_restart_init; /* Restart init if it dies? */
599 boolean_t zone_reboot_on_init_exit; /* Reboot if init dies? */
600 boolean_t zone_setup_app_contract; /* setup contract? */
601 struct brand *zone_brand; /* zone's brand */
602 void *zone_brand_data; /* store brand specific data */
603 id_t zone_defaultcid; /* dflt scheduling class id */
604 boolean_t zone_fixed_hipri; /* fixed sched. hi prio */
605 kstat_t *zone_swapresv_kstat;
606 kstat_t *zone_lockedmem_kstat;
607 /*
608 * zone_dl_list is protected by zone_lock
609 */
610 list_t zone_dl_list;
611 netstack_t *zone_netstack;
612 struct cpucap *zone_cpucap; /* CPU caps data */
613
614 /*
615 * Data and counters used for ZFS fair-share disk IO.
616 */
617 rctl_qty_t zone_zfs_io_pri; /* ZFS IO priority */
618 uint_t zone_zfs_queued[2]; /* sync I/O enqueued count */
619 uint64_t zone_zfs_weight; /* used to prevent starvation */
620 uint64_t zone_io_util; /* IO utilization metric */
621 boolean_t zone_io_util_above_avg; /* IO util percent > avg. */
622 uint16_t zone_io_delay; /* IO delay on logical r/w */
623 kmutex_t zone_stg_io_lock; /* protects IO window data */
624 sys_zio_cntr_t zone_rd_ops; /* Counters for ZFS reads, */
625 sys_zio_cntr_t zone_wr_ops; /* writes and */
626 sys_zio_cntr_t zone_lwr_ops; /* logical writes. */
627
628 /*
629 * kstats and counters for I/O ops and bytes.
630 */
631 kmutex_t zone_io_lock; /* protects I/O statistics */
632 kstat_t *zone_io_ksp;
633 kstat_io_t *zone_io_kiop;
634
635 /*
636 * kstats and counters for VFS ops and bytes.
637 */
638 kmutex_t zone_vfs_lock; /* protects VFS statistics */
639 kstat_t *zone_vfs_ksp;
640 kstat_io_t zone_vfs_rwstats;
641 zone_vfs_kstat_t *zone_vfs_stats;
642
643 /*
644 * kstats for ZFS I/O ops and bytes.
645 */
646 kmutex_t zone_zfs_lock; /* protects ZFS statistics */
647 kstat_io_t zone_zfs_rwstats;
648 zone_zfs_kstat_t *zone_zfs_stats;
649
650 /*
651 * Solaris Auditing per-zone audit context
652 */
653 struct au_kcontext *zone_audit_kctxt;
654 /*
655 * For private use by mntfs.
656 */
657 struct mntelem *zone_mntfs_db;
658 krwlock_t zone_mntfs_db_lock;
659
660 struct klpd_reg *zone_pfexecd;
661
662 char *zone_fs_allowed;
663 rctl_qty_t zone_nprocs; /* number of processes in the zone */
664 rctl_qty_t zone_nprocs_ctl; /* current limit protected by */
665 /* zone_rctls->rcs_lock */
666 kstat_t *zone_nprocs_kstat;
667
668 /*
669 * kstats and counters for physical memory capping.
670 */
671 rctl_qty_t zone_phys_mem; /* current bytes of phys. mem. (RSS) */
672 kstat_t *zone_physmem_kstat;
673 uint64_t zone_mcap_nover; /* # of times over phys. cap */
674 uint64_t zone_mcap_pagedout; /* bytes of mem. paged out */
675 kmutex_t zone_mcap_lock; /* protects mcap statistics */
676 kstat_t *zone_mcap_ksp;
677 zone_mcap_kstat_t *zone_mcap_stats;
678 uint64_t zone_pgpgin; /* pages paged in */
679 uint64_t zone_anonpgin; /* anon pages paged in */
680 uint64_t zone_execpgin; /* exec pages paged in */
681 uint64_t zone_fspgin; /* fs pages paged in */
682 uint64_t zone_anon_alloc_fail; /* cnt of anon alloc fails */
683 uint64_t zone_pf_throttle; /* cnt of page flt throttles */
684 uint64_t zone_pf_throttle_usec; /* time of page flt throttles */
685
686 /* Num usecs to throttle page fault when zone is over phys. mem cap */
687 uint32_t zone_pg_flt_delay;
688
689 /*
690 * Misc. kstats and counters for zone cpu-usage aggregation.
691 * The zone_Xtime values are the sum of the micro-state accounting
692 * values for all threads that are running or have run in the zone.
693 * This is tracked in msacct.c as threads change state.
694 * The zone_stime is the sum of the LMS_SYSTEM times.
695 * The zone_utime is the sum of the LMS_USER times.
696 * The zone_wtime is the sum of the LMS_WAIT_CPU times.
697 * As with per-thread micro-state accounting values, these values are
698 * not scaled to nanosecs. The scaling is done by the
699 * zone_misc_kstat_update function when kstats are requested.
700 */
701 kmutex_t zone_misc_lock; /* protects misc statistics */
702 kstat_t *zone_misc_ksp;
703 zone_misc_kstat_t *zone_misc_stats;
704 uint64_t zone_stime; /* total system time */
705 uint64_t zone_utime; /* total user time */
706 uint64_t zone_wtime; /* total time waiting in runq */
707 /* fork-fail kstat tracking */
708 uint32_t zone_ffcap; /* hit an rctl cap */
929 */
930 extern struct pool *zone_pool_get(zone_t *);
931 extern void zone_pool_set(zone_t *, struct pool *);
932
933 /*
934 * Get/set the pset the zone is currently using.
935 */
936 extern psetid_t zone_pset_get(zone_t *);
937 extern void zone_pset_set(zone_t *, psetid_t);
938
939 /*
940 * Get the number of cpus/online-cpus visible from the given zone.
941 */
942 extern int zone_ncpus_get(zone_t *);
943 extern int zone_ncpus_online_get(zone_t *);
944
945 /*
946 * Returns true if the named pool/dataset is visible in the current zone.
947 */
948 extern int zone_dataset_visible(const char *, int *);
949 extern int zone_dataset_visible_inzone(zone_t *, const char *, int *);
950
951 /*
952 * zone version of kadmin()
953 */
954 extern int zone_kadmin(int, int, const char *, cred_t *);
955 extern void zone_shutdown_global(void);
956
957 extern void mount_in_progress(zone_t *);
958 extern void mount_completed(zone_t *);
959
960 extern int zone_walk(int (*)(zone_t *, void *), void *);
961
962 extern rctl_hndl_t rc_zone_locked_mem;
963 extern rctl_hndl_t rc_zone_max_swap;
964 extern rctl_hndl_t rc_zone_phys_mem;
965 extern rctl_hndl_t rc_zone_max_lofi;
966
967 #endif /* _KERNEL */
968
969 #ifdef __cplusplus
970 }
971 #endif
972
973 #endif /* _SYS_ZONE_H */
|