Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153327156
D22548.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D22548.diff
View Options
Index: head/sys/fs/devfs/devfs_devs.c
===================================================================
--- head/sys/fs/devfs/devfs_devs.c
+++ head/sys/fs/devfs/devfs_devs.c
@@ -138,6 +138,8 @@
if (cdp == NULL)
return (NULL);
+ mtx_init(&cdp->cdp_threadlock, "devthrd", NULL, MTX_DEF);
+
cdp->cdp_dirents = &cdp->cdp_dirent0;
cdev = &cdp->cdp_c;
@@ -180,6 +182,7 @@
devfs_free_cdp_inode(cdp->cdp_inode);
if (cdp->cdp_maxdirent > 0)
free(cdp->cdp_dirents, M_DEVFS2);
+ mtx_destroy(&cdp->cdp_threadlock);
free(cdp, M_CDEVP);
}
Index: head/sys/fs/devfs/devfs_int.h
===================================================================
--- head/sys/fs/devfs/devfs_int.h
+++ head/sys/fs/devfs/devfs_int.h
@@ -70,6 +70,8 @@
void *cdp_dtr_cb_arg;
LIST_HEAD(, cdev_privdata) cdp_fdpriv;
+
+ struct mtx cdp_threadlock;
};
#define cdev2priv(c) __containerof(c, struct cdev_priv, cdp_c)
Index: head/sys/kern/kern_conf.c
===================================================================
--- head/sys/kern/kern_conf.c
+++ head/sys/kern/kern_conf.c
@@ -186,16 +186,16 @@
*ref = 0;
return (dev->si_devsw);
}
- dev_lock();
+ cdp = cdev2priv(dev);
+ mtx_lock(&cdp->cdp_threadlock);
csw = dev->si_devsw;
if (csw != NULL) {
- cdp = cdev2priv(dev);
if ((cdp->cdp_flags & CDP_SCHED_DTR) == 0)
atomic_add_long(&dev->si_threadcount, 1);
else
csw = NULL;
}
- dev_unlock();
+ mtx_unlock(&cdp->cdp_threadlock);
if (csw != NULL)
*ref = 1;
return (csw);
@@ -223,19 +223,21 @@
}
csw = NULL;
- dev_lock();
+ VI_LOCK(vp);
dev = vp->v_rdev;
if (dev == NULL) {
- dev_unlock();
+ VI_UNLOCK(vp);
return (NULL);
}
cdp = cdev2priv(dev);
+ mtx_lock(&cdp->cdp_threadlock);
if ((cdp->cdp_flags & CDP_SCHED_DTR) == 0) {
csw = dev->si_devsw;
if (csw != NULL)
atomic_add_long(&dev->si_threadcount, 1);
}
- dev_unlock();
+ mtx_unlock(&cdp->cdp_threadlock);
+ VI_UNLOCK(vp);
if (csw != NULL) {
*devp = dev;
*ref = 1;
@@ -1136,20 +1138,26 @@
dev->si_flags &= ~SI_CLONELIST;
}
+ mtx_lock(&cdp->cdp_threadlock);
csw = dev->si_devsw;
dev->si_devsw = NULL; /* already NULL for SI_ALIAS */
while (csw != NULL && csw->d_purge != NULL && dev->si_threadcount) {
csw->d_purge(dev);
+ mtx_unlock(&cdp->cdp_threadlock);
msleep(csw, &devmtx, PRIBIO, "devprg", hz/10);
+ mtx_lock(&cdp->cdp_threadlock);
if (dev->si_threadcount)
printf("Still %lu threads in %s\n",
dev->si_threadcount, devtoname(dev));
}
while (dev->si_threadcount != 0) {
/* Use unique dummy wait ident */
+ mtx_unlock(&cdp->cdp_threadlock);
msleep(&csw, &devmtx, PRIBIO, "devdrn", hz / 10);
+ mtx_lock(&cdp->cdp_threadlock);
}
+ mtx_unlock(&cdp->cdp_threadlock);
dev_unlock();
if ((cdp->cdp_flags & CDP_UNREF_DTR) == 0) {
/* avoid out of order notify events */
Index: head/sys/kern/subr_witness.c
===================================================================
--- head/sys/kern/subr_witness.c
+++ head/sys/kern/subr_witness.c
@@ -602,6 +602,7 @@
{ "vm map (system)", &lock_class_mtx_sleep },
{ "vnode interlock", &lock_class_mtx_sleep },
{ "cdev", &lock_class_mtx_sleep },
+ { "devthrd", &lock_class_mtx_sleep },
{ NULL, NULL },
/*
* VM
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 21, 12:19 PM (13 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31848477
Default Alt Text
D22548.diff (3 KB)
Attached To
Mode
D22548: devfs: introduce a per-dev lock to protect ->si_devsw
Attached
Detach File
Event Timeline
Log In to Comment