From owner-freebsd-current@FreeBSD.ORG Mon Jul 9 04:18:39 2007 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3D7B716A400 for ; Mon, 9 Jul 2007 04:18:39 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.freebsd.org (Postfix) with ESMTP id CC20E13C45D for ; Mon, 9 Jul 2007 04:18:38 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from [192.168.254.15] (ydesk.samsco.home [192.168.254.15]) (authenticated bits=0) by pooker.samsco.org (8.13.8/8.13.8) with ESMTP id l694IVrf079578; Sun, 8 Jul 2007 22:18:31 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <4691B717.502@samsco.org> Date: Sun, 08 Jul 2007 22:18:31 -0600 From: Scott Long User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.7) Gecko/20050416 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kostik Belousov References: <20070703180141.GJ2200@deviant.kiev.zoral.com.ua> <20070705144443.GV2200@deviant.kiev.zoral.com.ua> <20070707160042.GJ2200@deviant.kiev.zoral.com.ua> <07070809441413.59322@www.mmlab.cse.yzu.edu.tw> <20070708024815.GK2200@deviant.kiev.zoral.com.ua> <0707082155317.77206@www.mmlab.cse.yzu.edu.tw> <20070708191928.GM2200@deviant.kiev.zoral.com.ua> In-Reply-To: <20070708191928.GM2200@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (pooker.samsco.org [192.168.254.1]); Sun, 08 Jul 2007 22:18:32 -0600 (MDT) X-Spam-Status: No, score=-1.4 required=5.5 tests=ALL_TRUSTED autolearn=failed version=3.1.8 X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on pooker.samsco.org Cc: Tai-hwa Liang , current@freebsd.org Subject: Re: HEADS UP: destroy_dev_sched() KPI in the tree X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2007 04:18:39 -0000 Kostik Belousov wrote: > On Sun, Jul 08, 2007 at 10:00:14PM +0800, Tai-hwa Liang wrote: > >>On Sun, 8 Jul 2007, Kostik Belousov wrote: >> >>>On Sun, Jul 08, 2007 at 09:47:41AM +0800, Tai-hwa Liang wrote: >> >>[...] >> >>>> Though it was reviewed before destroy_dev_sched() KPI enters to the >>>> tree, >>>>I'd be appreciate it if you can reviewed the attached patch again. >>> >>>So, this is still the problem for scsi_targ ? >>> >>>It probably make sense to postpone free of softc until all threads >>>finished using it. You may use destroy_dev_sched_cb() to run the >>>function after the device is actually destroyed. It would just call >>>free(). >> >> Probably; however, I did not see any code inside scsi_target.c to >>detach or unregister the scsi_target device. Will this cause any >>cdev leakage? > > This is not about cdev linkage. Immediately after call to > destriy_dev_sched(), driver code frees dev' softc. Thus, if any thread > is still inside cdev method, it could access freed memory. Postponing > the call to free until all threads leave the cdev methods would eliminate > this bug. > Nate and I and the other SCSI guys can take a whack at scsi_targ, so don't worry too much about slaying the dragons in it. Scott