From owner-freebsd-scsi@FreeBSD.ORG Tue Mar 30 14:25:31 2010 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E609106564A; Tue, 30 Mar 2010 14:25:31 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-pw0-f54.google.com (mail-pw0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id E2FF48FC15; Tue, 30 Mar 2010 14:25:30 +0000 (UTC) Received: by pwi9 with SMTP id 9so23853pwi.13 for ; Tue, 30 Mar 2010 07:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:received:message-id:subject :from:to:cc:content-type; bh=abXEErDqFkhfVqKPxCMTyrCzZ79G4y+IhzIz2SLWEZI=; b=xq2NROGEyLb7v2xTBo2rHhDyBgUseZujD6HFl+UXi8x+uMVQsAxg6R6OvhVrR3JWRd ezkUeIJA5cUaupWyo8qHhTnj+EVFB3K7rXLzvMiNlVNsJrAgbY2THNsneVdzSIbKujKy bsGGbXdwlds6dHEpGNyBhO+lYCWjaZBTMnVIw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=RPjcMAER4Bjbg+49apROy9gz/+R4bOLMF5fudu3Q5bH3kB27ry0+tsg/RPJf998/GE 2RLD8fqKfzi2F/2xKKiyY1aBC3/kX9+TxW92wq8vTMDER/n3X0BX9e/V3ydglOGCfTD5 woHKIs0XUM8bNix9DukYfPvA3vkLe6B0360+I= MIME-Version: 1.0 Sender: asmrookie@gmail.com Received: by 10.231.155.74 with HTTP; Tue, 30 Mar 2010 07:25:30 -0700 (PDT) In-Reply-To: <4BA5C746.7060203@FreeBSD.org> References: <3bbf2fe11002281655i61a5f0a0if3f381ad0c4a1ef8@mail.gmail.com> <3bbf2fe11003031547kd5f7314t3d83b2bde06c1c2f@mail.gmail.com> <4B8EF990.5030407@feral.com> <3bbf2fe11003031607wa3727b5ke89bc2a909d4d6a6@mail.gmail.com> <4B901419.8060800@feral.com> <3bbf2fe11003041737p30690522ya81e1b8f4bd6bbf9@mail.gmail.com> <3bbf2fe11003120601y3c403a1ct50f9fc6c1f0903bf@mail.gmail.com> <4B9A91DA.7030107@FreeBSD.org> <3bbf2fe11003200523t60895bfv1fa73d04e58a7838@mail.gmail.com> <4BA5C746.7060203@FreeBSD.org> Date: Tue, 30 Mar 2010 16:25:30 +0200 X-Google-Sender-Auth: 3b3471f80891d3e1 Received: by 10.142.196.10 with SMTP id t10mr2691360wff.223.1269959130360; Tue, 30 Mar 2010 07:25:30 -0700 (PDT) Message-ID: <3bbf2fe11003300725vdb1e4ddrf112778ca2bbbc20@mail.gmail.com> From: Attilio Rao To: Alexander Motin Content-Type: text/plain; charset=UTF-8 Cc: freebsd-scsi@freebsd.org, "Justin T. Gibbs" , mj@feral.com, Ed Maste Subject: Re: How is supposed to be protected the units list? X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Mar 2010 14:25:31 -0000 2010/3/21 Alexander Motin : > Attilio Rao wrote: >> So I made this new patch using the bus lock: >> http://www.freebsd.org/~attilio/Sandvine/pdrv/xpt_lock.diff > > OK. I've looked on both and I think both have race window between unit > number allocation and insertion into the list. I've changed last patch > to not drop the lock in meantime. What do you think about this: > http://people.freebsd.org/~mav/unit_lock.patch > ? > > Part about scsi_da.c I don't like in both cases, as I am not sure that > locks can't be recursed there in case of some errors. I don't see how > adding second lock could solve it. The lock recursion is going to happen because of the necessary refcount acquisition as Matt pointed out? Or there is another recursion? In the former case, the global lock will help because you may just acquire it, refcount the periph, cache them and run lockless. You can't do this with xpt_lock_bus because of the recursion in cam_periph_acquire. So we want to live this unprotected and just live with this bug? Attilio -- Peace can only be achieved by understanding - A. Einstein