Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp997844ybv; Thu, 13 Feb 2020 13:39:52 -0800 (PST) X-Google-Smtp-Source: APXvYqyVPRS756Ptb8QK6GE/eGLcZCixh2/iRL1v5oRSv/OWW7TwH9kWpDqxkdkaapRm5xkF/hWT X-Received: by 2002:aca:1005:: with SMTP id 5mr4500719oiq.16.1581629992471; Thu, 13 Feb 2020 13:39:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581629992; cv=none; d=google.com; s=arc-20160816; b=b4yPnRSLUbJms7zZWdv5JGByHS1ex1fuq2jITSHAx5rdqsKL1KjkLN8YK5GuCjhbyg r1mJGlQMWn3r4AS4fzSKR+9gShF0JREYq+rN77t3Kp3TEAqAdzieUXXhwwRssM+eKz2d SgUqoPVBCwxtYX7xddjJ7p+7MhWweOnPSCqpsZTsLtESAoTYLno5zjJiTCdU020x/nVc GfUaW0WHO5trWo2JKAmrXlkUZgks47fMRhXJXZ04FmOqc3xev0MGO6Z41NqomdF6msDm i0Haac9hOrlDRf6FBnEHf3sHp1EwUB9i7xIeqTrDBDuo22mROwYJVhZt+vGrJ1Z/h7PF efPQ== 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:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=4gojb3BfFcxJOeoqlbsxb4brCvYi43S2aCFYxrKefRA=; b=YYiEFJ13DLBvlTjw4Gffbb1Aca6S2IGpBGeTIvMP6mZGnMzp9Sur9BVTN6OocL8jfA 2NJ+07P24jWGtsk533UR4FtXqeLhojMbJgUAeGCgdnupCA3dAeGlacCqY65u4wdY3IpB 79srpFJcsfgVgDpY++eItV3k4i/sNo0uSNXIZsAO+xsJafVugguXCiG0Skla3wTbLV/Y fg1/jRS+ULIwHhtMMLiKEoSudHzN8ogruW6kwac/mWUWzc0grt9rV0EvfjrVD8J0OzL9 tr8sWQ7nMq+48XM6Fc1DSY8Ot/AavnJAYgi3WCoDRwgdqOQDmFa9tnoUbaoxVBewaRhy snBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wizzup.org header.s=mail header.b=c4lAL5sT; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=wizzup.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 107si1710573oth.14.2020.02.13.13.39.39; Thu, 13 Feb 2020 13:39:52 -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=@wizzup.org header.s=mail header.b=c4lAL5sT; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=wizzup.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728248AbgBMVK2 (ORCPT + 99 others); Thu, 13 Feb 2020 16:10:28 -0500 Received: from a80-127-99-228.adsl.xs4all.nl ([80.127.99.228]:51610 "EHLO hetgrotebos.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727705AbgBMVK1 (ORCPT ); Thu, 13 Feb 2020 16:10:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=wizzup.org; s=mail; h=Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Sender:Reply-To:Content-Transfer-Encoding:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe :List-Post:List-Owner:List-Archive; bh=4gojb3BfFcxJOeoqlbsxb4brCvYi43S2aCFYxrKefRA=; b=c4lAL5sTTQDVp+aLDlEJQCFfE9 5UVvFss3fMBHjH+54M6Q79jCQPtSvoiESRHLG5yscImqV+jxzfk/rEbZmPw82Ki6n4ZW/VG+i8GKs yQxcMGikNgm8IjRWuqDiTadMElfgbpun1HBVxxYrAj+tmcHrv5x9tznY4TqvSLkxMnM7EBfudmgdY KWQLNM4ZAR0GuiXL3BZDffQdcWR4U/uZFYa0wbZkHpN5HN9QgenGbGllvEFpZPZytrC9zcZ4ObYXx xSoUkv+o+ykFNEQZXYdo42RnLl1wyoKmgXwROQxXTnWACx/cqoyT4XNAdZ7bE9q9i6jq/I9HOvDyN +G4Fyj0w==; Received: from deepwater.fritz.box ([192.168.178.25] helo=[0.0.0.0]) by hetgrotebos.org with esmtpsa (TLS1.3) tls TLS_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1j2Lke-0002LM-6n; Thu, 13 Feb 2020 21:10:24 +0000 Subject: Re: [RFC PATCH] scsi: sr: get rid of sr global mutex To: linux-scsi@vger.kernel.org Cc: Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" , Arnd Bergmann , linux-kernel@vger.kernel.org References: <20200212164445.1171-1-merlijn@wizzup.org> From: Merlijn Wajer Autocrypt: addr=merlijn@wizzup.org; prefer-encrypt=mutual; keydata= mQINBFESzAkBEACuLy46KxYl4IfKuNhz3UWXSlA1GqMwgOhGUJw/ineKS6T1FiRqcbhO/Zj8 oWobO5Mu743AY8PQtH9eo28jnz6Pg0vQLC2y6+3mtO4Ud+z+l06RadvgCH5F/6ibUqAdU2Eu CoyN6dk01zCyh5VRWqoWQsNkN9n5jdcbq9ZNhpOsUIYTIX/JVqMiZuwYS/YodDCbuBRk7isT frXHfbrXRzb/Fm6RfoFNcfL+wlqX62S55uWJdmjgwFd5sK4D/n68wjrFObi2Ar8Q2AYgi5Ib Qh6GNS7jHyDm5rT5EdMmU54ZoH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AQDeleOk zXwcuoJMF9/3NKPFmMnYqCmqcMqftnD1xzOID0pnD/0UeS7mT41dxzKMsacFqaSbraj3s7dg pZ3ApopOcgXZTS5DI3x7jCDj/jhltuAhZf7Vsz3PBLgNs0Ay9eYtBUbzUND165B7jjDKATfb vm/LJohftKYpLVMn/fWsH5XxzsjUHMHrmFQGcb3hwADeCmRM/1NUykdwI07pWwddyAI2wbqS HqyI2bHHZMPkuSnj5X/9zmWRYJPkYX4EWWK5Vyv3ynQdPZSn+fukNSVILV/ku7jtZ+NvsbdV YimlSKtxQL4Y+xcC2YKf9nhWDMn5ouckoTu9mHW30/da8Ta2sISmP28BzO1F+RJYcQ1L5Qmq heKFOvKG5phFgmuspZaJvB+0PZAJUA3hm9Zo0mSG+Hxf0U9Wc10dAKe4QnuPUedPPK7FeIlR Ahxr7uokP2QIjS6ZYbdVauSUop5w4nQvMp65NvvejeGnOTR4SDkwovQKSzvbyUpoulNPgkVO +q2smvVAO0X1gAu0TI13r/s0TUk0shKmPtjGxUocyNoX53FCOXyrqFFzfF0RR/kZyHqNvNun auuXY5GfVPDcxjPwzm4Yjj4YvbfRLpAiQOOciMgiJlbn4A+BhvSSS54scJMln1Jh7KkDgeqz aP0nj9EfQy1vMXGp1i0sYzhMKaM9nsmV/q1Iisqc8ojjpmR00jVnz/aSX3eHexXOlB3Y6Qs+ /XslHw== Message-ID: Date: Thu, 13 Feb 2020 22:11:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <20200212164445.1171-1-merlijn@wizzup.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="cOpIReCRqUS0dM2IAW7xUvgdsrVnd7PzM" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --cOpIReCRqUS0dM2IAW7xUvgdsrVnd7PzM Content-Type: multipart/mixed; boundary="MtmV2JiIiLWTCnfRuGBzZNZaAQ1iEVVGs" --MtmV2JiIiLWTCnfRuGBzZNZaAQ1iEVVGs Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable Hi, I was wondering if or what changes the maintainers would like me to make in order to get this merged. This regression was introduced back in 2010 and it recently took me just under a week to find the root cause. The Internet Archive is digitising hundreds of thousands of CDs, in an effort to preserve whatever is on those CDs, and not being able to digitise more than one CD per machine is a real pain. My hope is that once I can massage the patch into something that can be approved, we can also send the patch to the various stable trees. Digging through some old email threads I also found a suggestion to move the lock instead to the cdrom device. Would that be preferred to having the lock per sr instance? Merlijn On 12/02/2020 17:44, Merlijn Wajer wrote: > When replacing the Big Kernel Lock in commit: > <2a48fc0ab24241755dc93bfd4f01d68efab47f5a> ("block: autoconvert trivial= BKL > users to private mutex") , the lock was replaced with a sr-wide lock. >=20 > This causes very poor performance when using multiple sr devices, as th= e > sr driver was not able to execute more than one command to one drive at= > any given time, even when there were many CD drives available. >=20 > Replace the global mutex with per-sr-device mutex. >=20 > Someone tried this patch at the time, but it never made it > upstream, due to possible concerns with race conditions, but it's not > clear the patch actually caused those: >=20 > https://www.spinics.net/lists/linux-scsi/msg63706.html > https://www.spinics.net/lists/linux-scsi/msg63750.html >=20 > Also see >=20 > http://lists.xiph.org/pipermail/paranoia/2019-December/001647.html >=20 > Signed-off-by: Merlijn Wajer > --- > drivers/scsi/sr.c | 16 +++++++++------- > drivers/scsi/sr.h | 2 ++ > 2 files changed, 11 insertions(+), 7 deletions(-) >=20 > diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c > index 38ddbbfe5..6809fdcfd 100644 > --- a/drivers/scsi/sr.c > +++ b/drivers/scsi/sr.c > @@ -77,7 +77,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM); > CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET|= \ > CDC_MRW|CDC_MRW_W|CDC_RAM) > =20 > -static DEFINE_MUTEX(sr_mutex); > static int sr_probe(struct device *); > static int sr_remove(struct device *); > static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt); > @@ -535,9 +534,9 @@ static int sr_block_open(struct block_device *bdev,= fmode_t mode) > scsi_autopm_get_device(sdev); > check_disk_change(bdev); > =20 > - mutex_lock(&sr_mutex); > + mutex_lock(&cd->lock); > ret =3D cdrom_open(&cd->cdi, bdev, mode); > - mutex_unlock(&sr_mutex); > + mutex_unlock(&cd->lock); > =20 > scsi_autopm_put_device(sdev); > if (ret) > @@ -550,10 +549,10 @@ static int sr_block_open(struct block_device *bde= v, fmode_t mode) > static void sr_block_release(struct gendisk *disk, fmode_t mode) > { > struct scsi_cd *cd =3D scsi_cd(disk); > - mutex_lock(&sr_mutex); > + mutex_lock(&cd->lock); > cdrom_release(&cd->cdi, mode); > scsi_cd_put(cd); > - mutex_unlock(&sr_mutex); > + mutex_unlock(&cd->lock); > } > =20 > static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, uns= igned cmd, > @@ -564,7 +563,7 @@ static int sr_block_ioctl(struct block_device *bdev= , fmode_t mode, unsigned cmd, > void __user *argp =3D (void __user *)arg; > int ret; > =20 > - mutex_lock(&sr_mutex); > + mutex_lock(&cd->lock); > =20 > ret =3D scsi_ioctl_block_when_processing_errors(sdev, cmd, > (mode & FMODE_NDELAY) !=3D 0); > @@ -594,7 +593,7 @@ static int sr_block_ioctl(struct block_device *bdev= , fmode_t mode, unsigned cmd, > scsi_autopm_put_device(sdev); > =20 > out: > - mutex_unlock(&sr_mutex); > + mutex_unlock(&cd->lock); > return ret; > } > =20 > @@ -700,6 +699,7 @@ static int sr_probe(struct device *dev) > disk =3D alloc_disk(1); > if (!disk) > goto fail_free; > + mutex_init(&cd->lock); > =20 > spin_lock(&sr_index_lock); > minor =3D find_first_zero_bit(sr_index_bits, SR_DISKS); > @@ -1009,6 +1009,8 @@ static void sr_kref_release(struct kref *kref) > =20 > put_disk(disk); > =20 > + mutex_destroy(&cd->lock); > + > kfree(cd); > } > =20 > diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h > index a2bb7b8ba..339c624e0 100644 > --- a/drivers/scsi/sr.h > +++ b/drivers/scsi/sr.h > @@ -20,6 +20,7 @@ > =20 > #include > #include > +#include > =20 > #define MAX_RETRIES 3 > #define SR_TIMEOUT (30 * HZ) > @@ -51,6 +52,7 @@ typedef struct scsi_cd { > bool ignore_get_event:1; /* GET_EVENT is unreliable, use TUR */ > =20 > struct cdrom_device_info cdi; > + struct mutex lock; > /* We hold gendisk and scsi_device references on probe and use > * the refs on this kref to decide when to release them */ > struct kref kref; >=20 --MtmV2JiIiLWTCnfRuGBzZNZaAQ1iEVVGs-- --cOpIReCRqUS0dM2IAW7xUvgdsrVnd7PzM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRM5LT7NbLF9yb6a/UGN09rynK8WgUCXkW7fgAKCRAGN09rynK8 Wq47AQDoioDeHAkd135GF9+HheMMyMFIhIUaXDa5xAaVrvlNigD7BIw/LF4e1WCR 7JlNXms0nICiHo1J2pPGG5XJ0hd8bAw= =fjoK -----END PGP SIGNATURE----- --cOpIReCRqUS0dM2IAW7xUvgdsrVnd7PzM--