--Xc2zRdLclVh020+J
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Apr 25, 2008 at 12:35:26AM +0300, Andriy Gapon wrote:
>=20
> I decided to do it in devfs_devs.c because there are less entry points
> there and the code is much simpler (you know: aliases, clones).
> I also had to add !cold condition, because apparently we have devices
> created so early in the boot, that devctl is not ready to handle a
> notification. My system hanged after only getting to the following line
> in verbose boot:
> ULE: setup cpu 0
> However it is possible that it did something wrong - at that time I had
> devctl calls in kern_conf.
>=20
> I guess this also should be OK from the user perspective because they
> would be interested in device events after a system is booted and devd
> is running.
>=20
> Here is a log of devd started with -dD flags in single-user mode, then I
> attached and later detached an external hdd:
> http://www.icyb.net.ua/~avg/devd.log.gz
> Search for DEVFS for interesting lines.
>=20
> --=20
> Andriy Gapon


> diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c
> index ca5c2de..3556799 100644
> --- a/sys/fs/devfs/devfs_devs.c
> +++ b/sys/fs/devfs/devfs_devs.c
> @@ -33,6 +33,7 @@
> #include
> #include
> #include
> +#include
> #include
> #include
> #include
> @@ -518,6 +519,9 @@ devfs_create(struct cdev *dev)
> dev_refl(dev);
> TAILQ_INSERT_TAIL(&cdevp_list, cdp, cdp_list);
> devfs_generation++;
> +
> + if (!cold)
> + devctl_notify("DEVFS", dev->si_name, "ATTACH", NULL);
> }
> =20
> void
> @@ -529,6 +533,9 @@ devfs_destroy(struct cdev *dev)
> cdp =3D dev->si_priv;
> cdp->cdp_flags &=3D ~CDP_ACTIVE;
> devfs_generation++;
> +
> + if (!cold)
> + devctl_notify("DEVFS", dev->si_name, "DETACH", NULL);
> }
> =20
> static void


Did you run this with WITNESS ?

You put the whole devctl_notify() call under the dev_mtx. This includes
the malloc(), PROC_LOCK() and signalling, and some internal devctl_queue()
stuff. This is wrong.

--Xc2zRdLclVh020+J
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (FreeBSD)

iEYEARECAAYFAkgRqVEACgkQC3+MBN1Mb4hTrgCeLqWrGFHU2n VieITScAHlZL6x
f5UAoJ8tOstn8GmRE2XbmmUDv0yeO3lf
=9Tr4
-----END PGP SIGNATURE-----

--Xc2zRdLclVh020+J--