Print this page
2882 implement libzfs_core
2883 changing "canmount" property to "on" should not always remount dataset
2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Chris Siden <christopher.siden@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Bill Pijewski <wdp@joyent.com>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>


   5  * Common Development and Distribution License (the "License").
   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 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */



  25 
  26 #include <sys/refcount.h>
  27 #include <sys/rrwlock.h>
  28 
  29 /*
  30  * This file contains the implementation of a re-entrant read
  31  * reader/writer lock (aka "rrwlock").
  32  *
  33  * This is a normal reader/writer lock with the additional feature
  34  * of allowing threads who have already obtained a read lock to
  35  * re-enter another read lock (re-entrant read) - even if there are
  36  * waiting writers.
  37  *
  38  * Callers who have not obtained a read lock give waiting writers priority.
  39  *
  40  * The rrwlock_t lock does not allow re-entrant writers, nor does it
  41  * allow a re-entrant mix of reads and writes (that is, it does not
  42  * allow a caller who has already obtained a read lock to be able to
  43  * then grab a write lock without first dropping all read locks, and
  44  * vice versa).


 245         }
 246         mutex_exit(&rrl->rr_lock);
 247 }
 248 
 249 boolean_t
 250 rrw_held(rrwlock_t *rrl, krw_t rw)
 251 {
 252         boolean_t held;
 253 
 254         mutex_enter(&rrl->rr_lock);
 255         if (rw == RW_WRITER) {
 256                 held = (rrl->rr_writer == curthread);
 257         } else {
 258                 held = (!refcount_is_zero(&rrl->rr_anon_rcount) ||
 259                     !refcount_is_zero(&rrl->rr_linked_rcount));
 260         }
 261         mutex_exit(&rrl->rr_lock);
 262 
 263         return (held);
 264 }












   5  * Common Development and Distribution License (the "License").
   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 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright (c) 2012 by Delphix. All rights reserved.
  27  */
  28 
  29 #include <sys/refcount.h>
  30 #include <sys/rrwlock.h>
  31 
  32 /*
  33  * This file contains the implementation of a re-entrant read
  34  * reader/writer lock (aka "rrwlock").
  35  *
  36  * This is a normal reader/writer lock with the additional feature
  37  * of allowing threads who have already obtained a read lock to
  38  * re-enter another read lock (re-entrant read) - even if there are
  39  * waiting writers.
  40  *
  41  * Callers who have not obtained a read lock give waiting writers priority.
  42  *
  43  * The rrwlock_t lock does not allow re-entrant writers, nor does it
  44  * allow a re-entrant mix of reads and writes (that is, it does not
  45  * allow a caller who has already obtained a read lock to be able to
  46  * then grab a write lock without first dropping all read locks, and
  47  * vice versa).


 248         }
 249         mutex_exit(&rrl->rr_lock);
 250 }
 251 
 252 boolean_t
 253 rrw_held(rrwlock_t *rrl, krw_t rw)
 254 {
 255         boolean_t held;
 256 
 257         mutex_enter(&rrl->rr_lock);
 258         if (rw == RW_WRITER) {
 259                 held = (rrl->rr_writer == curthread);
 260         } else {
 261                 held = (!refcount_is_zero(&rrl->rr_anon_rcount) ||
 262                     !refcount_is_zero(&rrl->rr_linked_rcount));
 263         }
 264         mutex_exit(&rrl->rr_lock);
 265 
 266         return (held);
 267 }
 268 
 269 void
 270 rrw_tsd_destroy(void *arg)
 271 {
 272         rrw_node_t *rn = arg;
 273         if (rn != NULL) {
 274                 panic("thread %p terminating with rrw lock %p held",
 275                     (void *)curthread, (void *)rn->rn_rrl);
 276         }
 277 }