1029 void
1030 dsl_pool_config_enter(dsl_pool_t *dp, void *tag)
1031 {
1032 /*
1033 * We use a "reentrant" reader-writer lock, but not reentrantly.
1034 *
1035 * The rrwlock can (with the track_all flag) track all reading threads,
1036 * which is very useful for debugging which code path failed to release
1037 * the lock, and for verifying that the *current* thread does hold
1038 * the lock.
1039 *
1040 * (Unlike a rwlock, which knows that N threads hold it for
1041 * read, but not *which* threads, so rw_held(RW_READER) returns TRUE
1042 * if any thread holds it for read, even if this thread doesn't).
1043 */
1044 ASSERT(!rrw_held(&dp->dp_config_rwlock, RW_READER));
1045 rrw_enter(&dp->dp_config_rwlock, RW_READER, tag);
1046 }
1047
1048 void
1049 dsl_pool_config_exit(dsl_pool_t *dp, void *tag)
1050 {
1051 rrw_exit(&dp->dp_config_rwlock, tag);
1052 }
1053
1054 boolean_t
1055 dsl_pool_config_held(dsl_pool_t *dp)
1056 {
1057 return (RRW_LOCK_HELD(&dp->dp_config_rwlock));
1058 }
1059
1060 boolean_t
1061 dsl_pool_config_held_writer(dsl_pool_t *dp)
1062 {
1063 return (RRW_WRITE_HELD(&dp->dp_config_rwlock));
1064 }
|
1029 void
1030 dsl_pool_config_enter(dsl_pool_t *dp, void *tag)
1031 {
1032 /*
1033 * We use a "reentrant" reader-writer lock, but not reentrantly.
1034 *
1035 * The rrwlock can (with the track_all flag) track all reading threads,
1036 * which is very useful for debugging which code path failed to release
1037 * the lock, and for verifying that the *current* thread does hold
1038 * the lock.
1039 *
1040 * (Unlike a rwlock, which knows that N threads hold it for
1041 * read, but not *which* threads, so rw_held(RW_READER) returns TRUE
1042 * if any thread holds it for read, even if this thread doesn't).
1043 */
1044 ASSERT(!rrw_held(&dp->dp_config_rwlock, RW_READER));
1045 rrw_enter(&dp->dp_config_rwlock, RW_READER, tag);
1046 }
1047
1048 void
1049 dsl_pool_config_enter_prio(dsl_pool_t *dp, void *tag)
1050 {
1051 ASSERT(!rrw_held(&dp->dp_config_rwlock, RW_READER));
1052 rrw_enter_read_prio(&dp->dp_config_rwlock, tag);
1053 }
1054
1055 void
1056 dsl_pool_config_exit(dsl_pool_t *dp, void *tag)
1057 {
1058 rrw_exit(&dp->dp_config_rwlock, tag);
1059 }
1060
1061 boolean_t
1062 dsl_pool_config_held(dsl_pool_t *dp)
1063 {
1064 return (RRW_LOCK_HELD(&dp->dp_config_rwlock));
1065 }
1066
1067 boolean_t
1068 dsl_pool_config_held_writer(dsl_pool_t *dp)
1069 {
1070 return (RRW_WRITE_HELD(&dp->dp_config_rwlock));
1071 }
|