public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Anderson <andmike@us.ibm.com>
To: James Bottomley <James.Bottomley@steeleye.com>
Cc: SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] correct module refcounting
Date: Tue, 28 Oct 2003 16:17:24 -0800	[thread overview]
Message-ID: <20031029001724.GA2029@beaverton.ibm.com> (raw)
In-Reply-To: <1067377564.1788.39.camel@mulgrave>

James Bottomley [James.Bottomley@steeleye.com] wrote:
> There's a race window between doing the last scsi_device_put and having
> the devices actually released where the module may be unloaded.  The fix
> is to move the module accounting into the
> scsi_allocate_sdev/scsi_free_sdev pieces of the SCSI routines.
> 
> I also think we probably want to move sdev_gendev population into
> scsi_allocate_sdev.  Note this will change how we do initial scans
> because now we'll be using the generic device release infrastructure to
> free even temporary devices.  Unless anyone has a better idea...?
> 

If we do this we will need to do a two phase init of the sdev_gendev
like we do with the host. Otherwise every device_register will cause the
sd_probe to be called.

> Finally, when this is done, we can take a device reference over both
> scsi_get_command/scsi_put_command and also within the scsi_request_fn so
> we know the device can never be released while it has outstanding
> commands or while we are running its queues.
> 

What case of IO in-flight post a upper level driver release call are you
trying to protect. Do you think these extra atomic_incs will have any
negative impact.

> James
> 
> ===== drivers/scsi/scsi_scan.c 1.110 vs edited =====
> --- 1.110/drivers/scsi/scsi_scan.c	Mon Oct 27 06:01:50 2003
> +++ edited/drivers/scsi/scsi_scan.c	Tue Oct 28 15:39:00 2003
> @@ -192,6 +192,9 @@
>  	struct scsi_device *sdev, *device;
>  	unsigned long flags;
>  
> +	if (!try_module_get(sdev->host->hostt->module))
> +		goto out;
> +
>  	sdev = kmalloc(sizeof(*sdev), GFP_ATOMIC);
>  	if (!sdev)
>  		goto out;

Shouldn't this chunk be after the setting of sdev. I applied your patch
and it oops on me. After I moved it I am booted, but I have not done any
adds / deletes.

-andmike
--
Michael Anderson
andmike@us.ibm.com


  reply	other threads:[~2003-10-29  0:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-28 21:46 [PATCH] correct module refcounting James Bottomley
2003-10-29  0:17 ` Mike Anderson [this message]
2003-10-29  0:42   ` James Bottomley
2003-10-29  1:46     ` Mike Anderson
2003-10-31 12:18 ` Christoph Hellwig
2003-10-31 15:00   ` James Bottomley

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=20031029001724.GA2029@beaverton.ibm.com \
    --to=andmike@us.ibm.com \
    --cc=James.Bottomley@steeleye.com \
    --cc=linux-scsi@vger.kernel.org \
    /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