From owner-freebsd-hackers@FreeBSD.ORG Sun May 11 20:50:33 2008 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 E5D661065672; Sun, 11 May 2008 20:50:33 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from hosted.kievnet.com (hosted.kievnet.com [193.138.144.10]) by mx1.freebsd.org (Postfix) with ESMTP id 9AA588FC1A; Sun, 11 May 2008 20:50:33 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from localhost ([127.0.0.1] helo=edge.pp.kiev.ua) by hosted.kievnet.com with esmtpa (Exim 4.62) (envelope-from ) id 1JvIV4-0005QA-MY; Sun, 11 May 2008 23:50:30 +0300 Message-ID: <48275C0C.2040601@icyb.net.ua> Date: Sun, 11 May 2008 23:50:20 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.12 (X11/20080320) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org References: <480E4269.2090604@icyb.net.ua> <480FBAB9.1000904@icyb.net.ua> <48103F36.6060707@icyb.net.ua> <200804240811.26183.jhb@freebsd.org> <4810FD1E.70602@icyb.net.ua> <20080425095009.GD18958@deviant.kiev.zoral.com.ua> <4811E6BC.4060306@icyb.net.ua> <20080425143646.GF18958@deviant.kiev.zoral.com.ua> In-Reply-To: <20080425143646.GF18958@deviant.kiev.zoral.com.ua> Content-Type: multipart/mixed; boundary="------------030709040303030500080608" Cc: Kostik Belousov Subject: Re: devctl (alike?) for devfs 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: Sun, 11 May 2008 20:50:34 -0000 This is a multi-part message in MIME format. --------------030709040303030500080608 Content-Type: text/plain; charset=KOI8-U; format=flowed Content-Transfer-Encoding: 7bit Kostik, John, Warner, thank you for your guidance and suggestions. I am currently testing the patch attached and I am using a kernel with WITNESS and INVARIANTS enabled. Scope of my testing is plugging/unplugging of UMASS devices. I get CREATE notifications all right. I do not get any panics/complaints from the kernel, good. Unfortunately I do not get any DESTROY notifications either. Could you please look through the patch? Is there any control flow path that I missed or something even more obvious? I hope that we do not have any cdev leaks. I am testing the patch with RELENG_7 as of May 6. -- Andriy Gapon --------------030709040303030500080608 Content-Type: text/plain; name="devfs-notify.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="devfs-notify.diff" diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 1db25f8..0245253 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -99,6 +100,9 @@ dev_unlock_and_free(void) mtx_unlock(&devmtx); while ((cdp = TAILQ_FIRST(&cdp_free)) != NULL) { + if (!cold) + devctl_notify("DEVFS", cdp->cdp_c.si_name, "DESTROY", NULL); + TAILQ_REMOVE(&cdp_free, cdp, cdp_list); devfs_free(&cdp->cdp_c); } @@ -172,8 +176,12 @@ dev_rel(struct cdev *dev) flag = 1; } dev_unlock(); - if (flag) + if (flag) { + if (!cold) + devctl_notify("DEVFS", dev->si_name, "DESTROY", NULL); + devfs_free(dev); + } } struct cdevsw * @@ -706,6 +714,10 @@ make_dev_credv(int flags, struct cdevsw *devsw, int minornr, devfs_create(dev); clean_unrhdrl(devfs_inos); dev_unlock_and_free(); + + if (!cold) + devctl_notify("DEVFS", dev->si_name, "CREATE", NULL); + return (dev); } @@ -794,6 +806,10 @@ make_dev_alias(struct cdev *pdev, const char *fmt, ...) clean_unrhdrl(devfs_inos); dev_unlock(); dev_depends(pdev, dev); + + if (!cold) + devctl_notify("DEVFS", dev->si_name, "CREATE", NULL); + return (dev); } --------------030709040303030500080608--