From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 27 15:01:03 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24473106566C for ; Wed, 27 Apr 2011 15:01:03 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id EAF748FC19 for ; Wed, 27 Apr 2011 15:01:02 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 8D2F346B51; Wed, 27 Apr 2011 11:01:02 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 0AA248A027; Wed, 27 Apr 2011 11:01:02 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Wed, 27 Apr 2011 10:19:31 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <4DB695DB.1080505@chillt.de> <20110426124403.GQ48734@deviant.kiev.zoral.com.ua> <4DB76085.4000402@chillt.de> In-Reply-To: <4DB76085.4000402@chillt.de> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201104271019.31844.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 27 Apr 2011 11:01:02 -0400 (EDT) Cc: Kostik Belousov , Bartosz Fabianowski , Hans Petter Selasky Subject: Re: Is there some implicit locking of device methods? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2011 15:01:03 -0000 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