MCPcopy Create free account
hub / github.com/F-Stack/f-stack / devvn_refthread

Function devvn_refthread

freebsd/kern/kern_conf.c:204–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204struct cdevsw *
205devvn_refthread(struct vnode *vp, struct cdev **devp, int *ref)
206{
207 struct cdevsw *csw;
208 struct cdev_priv *cdp;
209 struct cdev *dev;
210
211 dev_lock_assert_unlocked();
212 if ((vp->v_vflag & VV_ETERNALDEV) != 0) {
213 dev = vp->v_rdev;
214 if (dev == NULL)
215 return (NULL);
216 KASSERT((dev->si_flags & SI_ETERNAL) != 0,
217 ("Not eternal cdev"));
218 *ref = 0;
219 csw = dev->si_devsw;
220 KASSERT(csw != NULL, ("Eternal cdev is destroyed"));
221 *devp = dev;
222 return (csw);
223 }
224
225 csw = NULL;
226 VI_LOCK(vp);
227 dev = vp->v_rdev;
228 if (dev == NULL) {
229 VI_UNLOCK(vp);
230 return (NULL);
231 }
232 cdp = cdev2priv(dev);
233 mtx_lock(&cdp->cdp_threadlock);
234 if ((cdp->cdp_flags & CDP_SCHED_DTR) == 0) {
235 csw = dev->si_devsw;
236 if (csw != NULL)
237 atomic_add_long(&dev->si_threadcount, 1);
238 }
239 mtx_unlock(&cdp->cdp_threadlock);
240 VI_UNLOCK(vp);
241 if (csw != NULL) {
242 *devp = dev;
243 *ref = 1;
244 }
245 return (csw);
246}
247
248void
249dev_relthread(struct cdev *dev, int ref)

Callers 2

ttyhook_registerFunction · 0.85
aio_qbioFunction · 0.85

Calls 3

atomic_add_longFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected