From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 27 15:30:22 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 2E280106566C; Wed, 27 Apr 2011 15:30:22 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 7C6A38FC13; Wed, 27 Apr 2011 15:30:20 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p3RFUCxJ093989 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Apr 2011 18:30:12 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p3RFUCYJ085597; Wed, 27 Apr 2011 18:30:12 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p3RFUCt3085596; Wed, 27 Apr 2011 18:30:12 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 27 Apr 2011 18:30:12 +0300 From: Kostik Belousov To: Bartosz Fabianowski Message-ID: <20110427153012.GX48734@deviant.kiev.zoral.com.ua> References: <4DB695DB.1080505@chillt.de> <20110426124403.GQ48734@deviant.kiev.zoral.com.ua> <4DB76085.4000402@chillt.de> <201104271019.31844.jhb@freebsd.org> <4DB818A3.1020104@chillt.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ElEgulhWJDonIdTi" Content-Disposition: inline In-Reply-To: <4DB818A3.1020104@chillt.de> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_05, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org, 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:30:22 -0000 --ElEgulhWJDonIdTi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 27, 2011 at 03:22:43PM +0200, Bartosz Fabianowski wrote: > >Err, if you use cdevpriv you shouldn't even have a d_close method. All= =20 > >your > >d_close logic should be in the cdevpriv destructor >=20 > I see. There is no documentation for any of this, so I just implemented= =20 > it in the way I *thought* it should work: >=20 > .d_close =3D drv_close, >=20 > int drv_close(...) { > devfs_clear_cdevpriv(); > } >=20 > static void cdevpriv_dtr(void *data) { > free(data, M_USBDEV); > } >=20 > If I understand you correctly, I can leave out the drv_close() method.=20 > When close() is called, devfs_clear_cdevpriv() will be executed=20 > implcitly for me and my dstructor will run - right? You are mixing the global 'last close', that is performed when last file opened over the device node is closed, and the last filedescriptor close which causes the file to be decomissioned. The global kind of last close is communicated to cdev by calling cdevsw close method. It is known to be not quite reliable, and esp. hard in relation to the forced unmounts of devfs mount points. The close of file (when no other file descriptors referencing the file are left) ends in cdevpriv destructor call. --ElEgulhWJDonIdTi Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk24NoQACgkQC3+MBN1Mb4gJtgCgyPUGE00LSBdBF6y7FdXXGnhy nPYAoIgNV2gDCEBPDKvXm+JmJT3ux8sA =h1Oa -----END PGP SIGNATURE----- --ElEgulhWJDonIdTi--