From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: John Kacur <jkacur@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@elte.hu>,
Christoph Hellwig <hch@infradead.org>,
Jonathan Corbet <corbet@lwn.net>,
Andrew Morton <akpm@linux-foundation.org>,
Vincent Sanders <vince@simtec.co.uk>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH RFC] [PATCH] drivers/scsi/ch.c: Remove BKL in ch_open
Date: Mon, 12 Oct 2009 15:03:51 +0200 [thread overview]
Message-ID: <4AD32937.4060001@s5r6.in-berlin.de> (raw)
In-Reply-To: <alpine.LFD.2.00.0910111443400.3587@localhost.localdomain>
On 10/11/2009 3:45 PM, John Kacur wrote:
> Locking in ch_open is covered by the spin_lock, it serializes the calls
> to idr_find and scsi_device_get. The BKL appears redundant to me here.
Superficially this looks OK (i.e. no race with driver init in general).
But I do wonder if there isn't already a race condition possible with
the current code, between ch_probe and the file operations. ch_probe
makes a scsi_changer instance available in the IDR and creates the
corresponding character device file _before_ the scsi_changer instance
is fully initialized.
(Full quote follows for lsml)
> From b385c85bb5c2579e542cfe55475b729325eb65e1 Mon Sep 17 00:00:00 2001
> From: John Kacur <jkacur@redhat.com>
> Date: Sun, 11 Oct 2009 13:06:54 +0200
> Subject: [PATCH] drivers/scsi/ch.c: Remove BKL in ch_open
>
> Everything in ch_open is covered by a spin_lock, so the lock_kernel is redundant
> Remove it.
>
> Signed-off-by: John Kacur <jkacur@redhat.com>
> ---
> drivers/scsi/ch.c | 5 +----
> 1 files changed, 1 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
> index fe11c1d..4ba8b67 100644
> --- a/drivers/scsi/ch.c
> +++ b/drivers/scsi/ch.c
> @@ -579,19 +579,16 @@ ch_open(struct inode *inode, struct file *file)
> scsi_changer *ch;
> int minor = iminor(inode);
>
> - lock_kernel();
> spin_lock(&ch_index_lock);
> ch = idr_find(&ch_index_idr, minor);
>
> if (NULL == ch || scsi_device_get(ch->device)) {
> spin_unlock(&ch_index_lock);
> - unlock_kernel();
> return -ENXIO;
> }
> + file->private_data = ch;
> spin_unlock(&ch_index_lock);
>
> - file->private_data = ch;
> - unlock_kernel();
> return 0;
> }
>
--
Stefan Richter
-=====-==--= =-=- -==--
http://arcgraph.de/sr/
prev parent reply other threads:[~2009-10-12 13:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-11 13:45 John Kacur
2009-10-11 14:37 ` Alan Cox
2009-10-11 15:29 ` Arjan van de Ven
2009-10-11 15:54 ` Alan Cox
2009-10-11 16:03 ` Arjan van de Ven
2009-10-11 16:14 ` Alan Cox
2009-10-11 16:19 ` Arjan van de Ven
2009-10-11 17:09 ` Jonathan Corbet
2009-10-12 13:03 ` Stefan Richter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AD32937.4060001@s5r6.in-berlin.de \
--to=stefanr@s5r6.in-berlin.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=corbet@lwn.net \
--cc=fweisbec@gmail.com \
--cc=hch@infradead.org \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=vince@simtec.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®