diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index 8f7cf00cf80e..885318bad76f 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -397,7 +397,7 @@ spec_node_init(vnode_t *vp, dev_t rdev) sd->sd_bdevvp = NULL; sd->sd_iocnt = 0; sd->sd_opened = false; - sd->sd_closing = false; + sd->sd_closing = NULL; sn->sn_dev = sd; sd = NULL; } else { @@ -1672,8 +1672,10 @@ spec_close(void *v) sd->sd_bdevvp = NULL; } if (count == 0) { + KASSERTMSG(sd->sd_closing == NULL, "sd_closing=%p", + sd->sd_closing); sd->sd_opened = false; - sd->sd_closing = true; + sd->sd_closing = curlwp; } mutex_exit(&device_lock); @@ -1722,8 +1724,9 @@ spec_close(void *v) * reacquiring the lock would deadlock. */ mutex_enter(&device_lock); - KASSERT(sd->sd_closing); - sd->sd_closing = false; + KASSERT(!sd->sd_opened); + KASSERTMSG(sd->sd_closing == curlwp, "sd_closing=%p", sd->sd_closing); + sd->sd_closing = NULL; cv_broadcast(&specfs_iocv); mutex_exit(&device_lock); diff --git a/sys/miscfs/specfs/specdev.h b/sys/miscfs/specfs/specdev.h index c55ab7aaa90a..4f3d315b5053 100644 --- a/sys/miscfs/specfs/specdev.h +++ b/sys/miscfs/specfs/specdev.h @@ -80,7 +80,7 @@ typedef struct specdev { dev_t sd_rdev; volatile u_int sd_iocnt; /* # bdev/cdev_* operations active */ bool sd_opened; /* true if successfully opened */ - bool sd_closing; /* true when bdev/cdev_close ongoing */ + struct lwp *sd_closing; /* true when bdev/cdev_close ongoing */ } specdev_t; /*