Page MenuHomeFreeBSD

devfs: unlock the directory vnode around the call to dev_clone handler
AcceptedPublic

Authored by kib on Sat, Jan 31, 11:05 PM.
Tags
None
Referenced Files
F143928888: D55028.id170923.diff
Mon, Feb 2, 3:12 AM
F143912473: D55028.id.diff
Sun, Feb 1, 9:27 PM
F143909106: D55028.id.diff
Sun, Feb 1, 8:14 PM
F143908674: D55028.id170914.diff
Sun, Feb 1, 8:04 PM
F143908597: D55028.diff
Sun, Feb 1, 8:02 PM
F143899063: D55028.id170914.diff
Sun, Feb 1, 5:03 PM
Subscribers

Details

Reviewers
markj
jah
kevans
Summary
The lock around dev_clone is unfortunate because cloner might need to
take its own locks that establish the order with devfs vnodes, and then
transiently participates in further VFS locks order.  For instance, this
way the proctree_lock or allproc_lock become involved.

Unlock dvp, we can unwind if the vnode become doomed while cloner was
called.

Reported by:    pho

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Sat, Jan 31, 11:05 PM
kib added a reviewer: kevans.
kib added a subscriber: pho.
sys/fs/devfs/devfs_vnops.c
1156

Why is it correct to handle the DOOMED case after checking cdev == NULL? It's not immediately clear to me.

kib marked an inline comment as done.Sun, Feb 1, 1:59 AM
kib added inline comments.
sys/fs/devfs/devfs_vnops.c
1156

Why is it not? If cdev == NULL, we fall to some of the paths that end up with return (ENOENT);. Either the devfs instance is being unmounted, and then DEVFS_DMP_DROP() is true and we use the exit path starting at line 1153 (patched). Or we break out of the loop, and since de == NULL, we return ENOENT in line 1179.

markj added inline comments.
sys/fs/devfs/devfs_vnops.c
1156

I see now, thanks. Specifically, I missed that we must fall into the de == NULL case if the case on line 1162 is hit.

This revision is now accepted and ready to land.Sun, Feb 1, 2:13 AM
kib marked an inline comment as done.

Add comment explaining why dvp is unlocked, and how possible reclamation is handled.

This revision now requires review to proceed.Sun, Feb 1, 2:23 AM
This revision is now accepted and ready to land.Sun, Feb 1, 3:26 AM