Date: Sat, 12 Jul 2014 18:53:47 +0200 From: Mateusz Guzik <mjguzik@gmail.com> To: Konstantin Belousov <kostikbel@gmail.com> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Mateusz Guzik <mjg@FreeBSD.org> Subject: Re: svn commit: r268570 - head/sys/kern Message-ID: <20140712165346.GA16884@dft-labs.eu> In-Reply-To: <20140712161801.GS93733@kib.kiev.ua> References: <201407121535.s6CFZ42f063120@svn.freebsd.org> <20140712161801.GS93733@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jul 12, 2014 at 07:18:01PM +0300, Konstantin Belousov wrote: > On Sat, Jul 12, 2014 at 03:35:04PM +0000, Mateusz Guzik wrote: > > Author: mjg > > Date: Sat Jul 12 15:35:04 2014 > > New Revision: 268570 > > URL: http://svnweb.freebsd.org/changeset/base/268570 > > > > Log: > > Clear nonblock and async on devctl close instaed of open. > > > > This is a purely cosmetic change. > > > > Modified: > > head/sys/kern/subr_bus.c > > > > Modified: head/sys/kern/subr_bus.c > > ============================================================================== > > --- head/sys/kern/subr_bus.c Sat Jul 12 15:19:30 2014 (r268569) > > +++ head/sys/kern/subr_bus.c Sat Jul 12 15:35:04 2014 (r268570) > > @@ -438,8 +438,6 @@ devopen(struct cdev *dev, int oflags, in > > } > > /* move to init */ > > devsoftc.inuse = 1; > > - devsoftc.nonblock = 0; > > - devsoftc.async = 0; > > mtx_unlock(&devsoftc.mtx); > > return (0); > > } > > @@ -450,6 +448,8 @@ devclose(struct cdev *dev, int fflag, in > > > > mtx_lock(&devsoftc.mtx); > > devsoftc.inuse = 0; > > + devsoftc.nonblock = 0; > > + devsoftc.async = 0; > > cv_broadcast(&devsoftc.cv); > > funsetown(&devsoftc.sigio); > > mtx_unlock(&devsoftc.mtx); > This is not pure cosmetic. devctl does not track closes, so opens are > not matched with close calls. Now any close clears nonblock and async, > which is not how it was done before. Tracking close calls does not > work reliably. > > FWIW, I think that both old and new behaviour are bugs, and I am not > sure why changing one for another (instead of fix). I don't see that, but maybe I'm misreading the code. There can be only one 'struct file' for devctl and devclose is only called when it is about to be destroyed. fd = open("/dev/devctl"); close(dup(fd)); does not result in calling devclose. If devclose is indeed reachable whlie fds are active this code needs serious help since devsoftc.inuse is of no use whatsoever. There is no support for multiple readers in the sense that each event can be read only once, hence the restriction on open. On the other hand it is indeed possible to obtain multiple fds for devctl which is harmless as far as consistency in the kernel goes. Concurrent reads are serialized with a mutex and closes are invisible to the device, except for the last one which destroys fp. -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140712165346.GA16884>