diff options
author | trasz <trasz@FreeBSD.org> | 2015-08-03 16:35:18 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2015-08-03 16:35:18 +0000 |
commit | f15074a1857df917230bbf5adab4b7c74621482c (patch) | |
tree | 9f9d085852a3e0b4c279c0450e56626cb8df4eac /sys/geom | |
parent | b3cc954757e517fc939e4621cd2f7aa38e33eba7 (diff) | |
download | FreeBSD-src-f15074a1857df917230bbf5adab4b7c74621482c.zip FreeBSD-src-f15074a1857df917230bbf5adab4b7c74621482c.tar.gz |
Fix panic that would happen on forcibly unmounting devfs (note that
as it is now, devfs ignores MNT_FORCE anyway, so it needs to be modified
to trigger the panic) with consumers still opened.
Note that this still results in a leak of r/w/e counters. It seems
to be harmless, though. If anyone knows a better way to approach
this - please tell.
Discussed with: kib@, mav@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3050
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/geom_dev.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index 2539e1b..3df7f3e 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -401,6 +401,20 @@ g_dev_close(struct cdev *dev, int flags, int fmt, struct thread *td) #else e = 0; #endif + + /* + * The vgonel(9) - caused by eg. forced unmount of devfs - calls + * VOP_CLOSE(9) on devfs vnode without any FREAD or FWRITE flags, + * which would result in zero deltas, which in turn would cause + * panic in g_access(9). + * + * Note that we cannot zero the counters (ie. do "r = cp->acr" + * etc) instead, because the consumer might be opened in another + * devfs instance. + */ + if (r + w + e == 0) + return (EINVAL); + sc = cp->private; mtx_lock(&sc->sc_mtx); sc->sc_open += r + w + e; |