Skip to content

Commit

Permalink
Show rrwlock writer after 60 seconds (DEBUG)
Browse files Browse the repository at this point in the history
A debug patch to identify the writing process holding the rrwlock.
If after 60 seconds of blocking a write the lock cannot be taken
print to the console the process name and pid of the holder.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#1862
  • Loading branch information
behlendorf authored and FransUrbo committed Dec 5, 2013
1 parent 1bbdf78 commit ef76b09
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions module/zfs/rrwlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,22 @@ rrw_enter_write(rrwlock_t *rrl)
refcount_count(&rrl->rr_linked_rcount) > 0 ||
rrl->rr_writer != NULL) {
rrl->rr_writer_wanted = B_TRUE;
#if defined(DEBUG) && defined(_KERNEL)
/*
* XXX: Debugging to determine which process is holding
* the rrwlock. After blocking here for 60 seconds wake
* up and log the holder to the console.
*/
if (cv_timedwait(&rrl->rr_cv, &rrl->rr_lock,
ddi_get_lbolt() + 60 * hz) == -1) {
kthread_t *thr = rrl->rr_writer;
printk(KERN_NOTICE "ZFS: rrl->rr_writer=%p (%s/%d)\n",
thr, thr ? thr->comm : "", thr ? thr->pid : -1);
}
#else
cv_wait(&rrl->rr_cv, &rrl->rr_lock);
#endif /* DEBUG && _KERNEL */

}
rrl->rr_writer_wanted = B_FALSE;
rrl->rr_writer = curthread;
Expand Down

0 comments on commit ef76b09

Please sign in to comment.