Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6083948ybv; Tue, 18 Feb 2020 09:32:43 -0800 (PST) X-Google-Smtp-Source: APXvYqxhKeeHNRqyC4PZSYx5FBL4VdxeyvNJaHKd9MYBNAg78jV9cLZDaHvhKDkkTMI+i+qtEdCY X-Received: by 2002:a05:6808:289:: with SMTP id z9mr1894378oic.48.1582047163703; Tue, 18 Feb 2020 09:32:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582047163; cv=none; d=google.com; s=arc-20160816; b=fSSbhq3D6SuuEPK/WhQn9Si1yL6dC+cuCmIwmL9d2MgIrGcHjVoZmw3C20BQQ3n/oG AvppteO/0UPUMmIukpuvEu2theovMpztPb2dIUAtKUK5Bywy29xhqGYkjKJx5fm6xX/Q Ke1inOHbY8949YthGq7gX0TJNbmSgMXQdxJuZl7wTZR87LFPS4dIS+/wqdR+254HydlC KV22tBRL6Oi8zTwc06MvaMAoYFNBnSxdyDqhDObVly9vT8NrLXXKNhTA1RtJgy/G951O J8s45gZuoC1YLT8HSFW3ReuvZaEapLGzFy/1xmP4SxnULnWXTCzYwKg4ZWX7M23ZGX1M bCdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=PcqDvJ5Bqd8W6iSdFN/gFMt5Tdi6uwpEt753vRvopj0=; b=IvhvJdhnU95J2c6mz7EoTrE9Itw6HYdPiL+F52DOAKL0z2YdiK+JO8CpXHbQzOhBAZ cpp/Pnrw6gYSbKTBloc39TZRt4UmHExgsEKHB/ou2hxdEJc+Cj+ww3Pif7LU7v7IXzZf FHqzwRGCx658dbGCih+sAPf/hyHyDzPr4sHqxI1LfDHTclXwtgbOVcAWJvFSi96GHOmv wib2vtDD6nJtvqs5zZejePEJ5fSEn8An5i0V5vdSpPmlqIoEwvtke9TFRnDwBxZxTeza h3Or48nEWA/fbF3MMAGIRiQJw48+J8qLeCaf6+sd5lID7V0wEHGTeZW46iTbr/Ahcx7+ hOdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=sTcl4Pzx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g72si8793238oib.157.2020.02.18.09.32.31; Tue, 18 Feb 2020 09:32:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=sTcl4Pzx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbgBRRcA (ORCPT + 99 others); Tue, 18 Feb 2020 12:32:00 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:52058 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726415AbgBRRb7 (ORCPT ); Tue, 18 Feb 2020 12:31:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=PcqDvJ5Bqd8W6iSdFN/gFMt5Tdi6uwpEt753vRvopj0=; b=sTcl4Pzx4IjLdQRIijwcqzyQ+O y+J31nvB4R18VrYDO3WiRnkFySNu1isqDYLonPl+2/DLPzgVtco7iedJP5dq+JlUiLhgp7N8GBb/5 jm56fx6OnU7ng0LIuX8/GeE+UzTuy0pBPW4pBWE9JL9RJ0xqum1tEbxu55VaJId3NqWZj7Ya2MKKC ulZ3WHGYUiiG6+NvqqsR4ljpVrbYW93hZ4LGeA7TvNcvV1nBSbxy6BXKCsR/q11vjo68rnyXE8yOa asfa/To1Szm5yz6g4njqo7yAA+SznzvWpCkO+oO9NvrE8AyEPUkM18wdg/vENxtQFIbHl4muZFz1m weMoRMyw==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j46j0-0005Wi-1v; Tue, 18 Feb 2020 17:31:58 +0000 Date: Tue, 18 Feb 2020 09:31:58 -0800 From: Christoph Hellwig To: James Bottomley Cc: Christoph Hellwig , Merlijn Wajer , merlijn@wizzup.org, linux-scsi@vger.kernel.org, Jens Axboe , "Martin K. Petersen" , Arnd Bergmann , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] scsi: sr: get rid of sr global mutex Message-ID: <20200218173158.GA18386@infradead.org> References: <20200218143918.30267-1-merlijn@archive.org> <20200218171259.GA6724@infradead.org> <1582046428.16681.7.camel@linux.ibm.com> <20200218172347.GA3020@infradead.org> <1582046914.16681.11.camel@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1582046914.16681.11.camel@linux.ibm.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 18, 2020 at 09:28:34AM -0800, James Bottomley wrote: > On Tue, 2020-02-18 at 09:23 -0800, Christoph Hellwig wrote: > > On Tue, Feb 18, 2020 at 09:20:28AM -0800, James Bottomley wrote: > > > > > Replace the global mutex with per-sr-device mutex. > > > > > > > > Do we actually need the lock at all? What is protected by it? > > > > > > We do at least for cdrom_open. It modifies the cdi structure with > > > no other protection and concurrent modification would at least > > > screw up the use counter which is not atomic. Same reasoning for > > > cdrom_release. > > > > Wouldn't the right fix to add locking to cdrom_open/release instead > > of having an undocumented requirement for the callers? > > Yes ... but that's somewhat of a bigger patch because you now have to > reason about the callbacks within cdrom. There's also the question of > whether you can assume ops->generic_packet() has its own concurrency > protections ... it's certainly true for SCSI, but is it for anything > else? Although I suppose you can just not care and run the internal > lock over it anyway. We have 4 instances of struct cdrom_device_ops in the kernel, one of which has a no-op generic_packet. So I don't think this should be a huge project.