@@ -159,8 +159,8 @@ rrw_destroy(rrwlock_t *rrl)
159
159
refcount_destroy (& rrl -> rr_linked_rcount );
160
160
}
161
161
162
- void
163
- rrw_enter_read (rrwlock_t * rrl , void * tag )
162
+ static void
163
+ rrw_enter_read_impl (rrwlock_t * rrl , boolean_t prio , void * tag )
164
164
{
165
165
mutex_enter (& rrl -> rr_lock );
166
166
#if !defined(DEBUG ) && defined(_KERNEL )
@@ -176,7 +176,7 @@ rrw_enter_read(rrwlock_t *rrl, void *tag)
176
176
ASSERT (refcount_count (& rrl -> rr_anon_rcount ) >= 0 );
177
177
178
178
while (rrl -> rr_writer != NULL || (rrl -> rr_writer_wanted &&
179
- refcount_is_zero (& rrl -> rr_anon_rcount ) &&
179
+ refcount_is_zero (& rrl -> rr_anon_rcount ) && ! prio &&
180
180
rrn_find (rrl ) == NULL ))
181
181
cv_wait (& rrl -> rr_cv , & rrl -> rr_lock );
182
182
@@ -191,6 +191,25 @@ rrw_enter_read(rrwlock_t *rrl, void *tag)
191
191
mutex_exit (& rrl -> rr_lock );
192
192
}
193
193
194
+ void
195
+ rrw_enter_read (rrwlock_t * rrl , void * tag )
196
+ {
197
+ rrw_enter_read_impl (rrl , B_FALSE , tag );
198
+ }
199
+
200
+ /*
201
+ * take a read lock even if there are pending write lock requests. if we want
202
+ * to take a lock reentrantly, but from different threads (that have a
203
+ * relationship to each other), the normal detection mechanism to overrule
204
+ * the pending writer does not work, so we have to give an explicit hint here.
205
+ */
206
+ void
207
+ rrw_enter_read_prio (rrwlock_t * rrl , void * tag )
208
+ {
209
+ rrw_enter_read_impl (rrl , B_TRUE , tag );
210
+ }
211
+
212
+
194
213
void
195
214
rrw_enter_write (rrwlock_t * rrl )
196
215
{
0 commit comments