Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Apr 2011 18:30:12 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Bartosz Fabianowski <freebsd@chillt.de>
Cc:        freebsd-hackers@freebsd.org, Hans Petter Selasky <hselasky@c2i.net>
Subject:   Re: Is there some implicit locking of device methods?
Message-ID:  <20110427153012.GX48734@deviant.kiev.zoral.com.ua>
In-Reply-To: <4DB818A3.1020104@chillt.de>
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>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



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