diff options
author | John Levon <john.levon@sun.com> | 2010-06-16 10:02:44 -0700 |
---|---|---|
committer | John Levon <john.levon@sun.com> | 2010-06-16 10:02:44 -0700 |
commit | 0fbb751d81ab0a7c7ddfd8d4e447e075a9f7024f (patch) | |
tree | 547ed35c638d3c30c437e212b458d74268e35afa /usr/src/uts/common/os/rctl.c | |
parent | ded9341448cd6e2573619c7f6fe98909bdd35ec6 (diff) | |
download | illumos-joyent-0fbb751d81ab0a7c7ddfd8d4e447e075a9f7024f.tar.gz |
PSARC 2010/144 lofi(7D) in non global zones
6354954 lofi support in non-global zones
6942891 prof_lookup_globaldev() leaks rootdir refs
6945005 lofiadm -a /dev/lofi/1: recursive mutex enter
6946486 lofi_ioctl() shouldn't allow disk ioctl()s on /dev/lofictl
Diffstat (limited to 'usr/src/uts/common/os/rctl.c')
-rw-r--r-- | usr/src/uts/common/os/rctl.c | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/usr/src/uts/common/os/rctl.c b/usr/src/uts/common/os/rctl.c index bd32159049..fed4331f23 100644 --- a/usr/src/uts/common/os/rctl.c +++ b/usr/src/uts/common/os/rctl.c @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/atomic.h> @@ -3058,6 +3057,64 @@ rctl_decr_swap(zone_t *zone, size_t swap) } /* + * rctl_incr_lofi(proc_t *, zone_t *, size_t) + * + * Overview + * Increments the number of lofi devices for the zone. + * + * Return values + * 0 on success. EAGAIN if increment fails due an rctl value + * on the zone. + * + * Callers context + * p_lock held on specified proc. + */ +int +rctl_incr_lofi(proc_t *proc, zone_t *zone, size_t incr) +{ + rctl_entity_p_t e; + + ASSERT(MUTEX_HELD(&proc->p_lock)); + ASSERT(incr > 0); + + e.rcep_p.zone = zone; + e.rcep_t = RCENTITY_ZONE; + + mutex_enter(&zone->zone_rctl_lock); + + /* Check for overflow */ + if ((zone->zone_max_lofi + incr) < zone->zone_max_lofi) { + mutex_exit(&zone->zone_rctl_lock); + return (EAGAIN); + } + if ((zone->zone_max_lofi + incr) > zone->zone_max_lofi_ctl) { + if (rctl_test_entity(rc_zone_max_lofi, zone->zone_rctls, + proc, &e, incr, 0) & RCT_DENY) { + mutex_exit(&zone->zone_rctl_lock); + return (EAGAIN); + } + } + zone->zone_max_lofi += incr; + mutex_exit(&zone->zone_rctl_lock); + return (0); +} + +/* + * rctl_decr_lofi(zone_t *, size_t) + * + * Overview + * Decrements the number of lofi devices for the zone. + */ +void +rctl_decr_lofi(zone_t *zone, size_t decr) +{ + mutex_enter(&zone->zone_rctl_lock); + ASSERT(zone->zone_max_lofi >= decr); + zone->zone_max_lofi -= decr; + mutex_exit(&zone->zone_rctl_lock); +} + +/* * Create resource kstat */ static kstat_t * |