Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Apr 2011 10:19:31 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        Kostik Belousov <kostikbel@gmail.com>, Bartosz Fabianowski <freebsd@chillt.de>, Hans Petter Selasky <hselasky@c2i.net>
Subject:   Re: Is there some implicit locking of device methods?
Message-ID:  <201104271019.31844.jhb@freebsd.org>
In-Reply-To: <4DB76085.4000402@chillt.de>
References:  <4DB695DB.1080505@chillt.de> <20110426124403.GQ48734@deviant.kiev.zoral.com.ua> <4DB76085.4000402@chillt.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, April 26, 2011 8:17:09 pm Bartosz Fabianowski wrote:
> > If you needs per-file private data for cdev, you would be better served
> > by cdevpriv(9) KPI. Cloning is too hard to use correctly for such task.
> 
> Thanks, I just got that working. To help those going down a similar path 
> in the future, I would like to note quickly that the following must be 
> added to the cdevsw structure to ensure proper clean-up:
> 
> .d_flags = D_TRACKCLOSE
> 
> I just spent hours debugging panics until I realized only the last 
> close() was triggering a call to my .d_close method.

Err, if you use cdevpriv you shouldn't even have a d_close method.  All your 
d_close logic should be in the cdevpriv destructor, and the kernel will call 
your destructor when all references to an open file descriptor go away (i.e. 
it is closed).

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104271019.31844.jhb>