From: Tejun Heo <htejun@gmail.com>
To: James.Bottomley@steeleye.com, axboe@suse.de
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH scsi-misc-2.6 07/08] scsi: remove bogus {get|put}_device() calls
Date: Wed, 23 Mar 2005 11:14:54 +0900 (KST) [thread overview]
Message-ID: <20050323021335.0D9E25EE@htj.dyndns.org> (raw)
In-Reply-To: <20050323021335.960F95F8@htj.dyndns.org>
07_scsi_refcnt_cleanup.patch
SCSI request submission paths can be categorized like the
following.
* through high-level driver (sd, st, sg...)
+ requests (fs / pc)
+ ioctls
+ flushes (issue_flush / barrier rqs)
+ backing dev (unplug fn / field referencing)
+ high-level specific (init / revalidation...)
* through scsi-midlayer
+ midlevel specific (init...)
+ transport specific (domain validations...)
All accesses either
* open high-level driver before submitting requests and
closes with no request left.
* get_device() before submitting requests and put_device()
with no request left.
So, basically, SCSI high-level object (scsi_disk) and
mid-level object (scsi_device) are reference counted by users,
not the requests they submit. Reference count cannot go zero
with active users and users cannot access the object once the
reference count reaches zero.
So, the {get/put}_device() calls in scsi_get_command() and
scsi_request_fn() are bogus and misleading. In addition,
get_device() cannot synchronize 1->0 and 0->1 transitions and
always returns the device pointer given as the argument. The
== NULL tests are just misleading.
Signed-off-by: Tejun Heo <htejun@gmail.com>
scsi.c | 9 +--------
scsi_lib.c | 12 +-----------
2 files changed, 2 insertions(+), 19 deletions(-)
Index: scsi-export/drivers/scsi/scsi.c
===================================================================
--- scsi-export.orig/drivers/scsi/scsi.c 2005-03-23 09:40:11.000000000 +0900
+++ scsi-export/drivers/scsi/scsi.c 2005-03-23 09:40:11.000000000 +0900
@@ -246,10 +246,6 @@ struct scsi_cmnd *scsi_get_command(struc
{
struct scsi_cmnd *cmd;
- /* Bail if we can't get a reference to the device */
- if (!get_device(&dev->sdev_gendev))
- return NULL;
-
cmd = __scsi_get_command(dev->host, gfp_mask);
if (likely(cmd != NULL)) {
@@ -264,8 +260,7 @@ struct scsi_cmnd *scsi_get_command(struc
spin_lock_irqsave(&dev->list_lock, flags);
list_add_tail(&cmd->list, &dev->cmd_list);
spin_unlock_irqrestore(&dev->list_lock, flags);
- } else
- put_device(&dev->sdev_gendev);
+ }
return cmd;
}
@@ -303,8 +298,6 @@ void scsi_put_command(struct scsi_cmnd *
if (likely(cmd != NULL))
kmem_cache_free(shost->cmd_pool->slab, cmd);
-
- put_device(&sdev->sdev_gendev);
}
EXPORT_SYMBOL(scsi_put_command);
Index: scsi-export/drivers/scsi/scsi_lib.c
===================================================================
--- scsi-export.orig/drivers/scsi/scsi_lib.c 2005-03-23 09:40:11.000000000 +0900
+++ scsi-export/drivers/scsi/scsi_lib.c 2005-03-23 09:40:11.000000000 +0900
@@ -1200,10 +1200,6 @@ static void scsi_request_fn(struct reque
struct scsi_cmnd *cmd;
struct request *req;
- if(!get_device(&sdev->sdev_gendev))
- /* We must be tearing the block queue down already */
- return;
-
/*
* To start with, we keep looping until the queue is empty, or until
* the host is no longer able to accept any more requests.
@@ -1288,7 +1284,7 @@ static void scsi_request_fn(struct reque
}
}
- goto out;
+ return;
not_ready:
spin_unlock_irq(shost->host_lock);
@@ -1306,12 +1302,6 @@ static void scsi_request_fn(struct reque
sdev->device_busy--;
if(sdev->device_busy == 0)
blk_plug_device(q);
- out:
- /* must be careful here...if we trigger the ->remove() function
- * we cannot be holding the q lock */
- spin_unlock_irq(q->queue_lock);
- put_device(&sdev->sdev_gendev);
- spin_lock_irq(q->queue_lock);
}
u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
next prev parent reply other threads:[~2005-03-23 2:28 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-23 2:14 [PATCH scsi-misc-2.6 00/08] scsi: small fixes & cleanups Tejun Heo
2005-03-23 2:14 ` [PATCH scsi-misc-2.6 01/08] scsi: remove unused bounce-buffer release path Tejun Heo
2005-03-23 4:07 ` James Bottomley
2005-03-23 6:08 ` Tejun Heo
2005-03-23 15:27 ` Jens Axboe
2005-03-23 2:14 ` [PATCH scsi-misc-2.6 02/08] scsi: don't use blk_insert_request() for requeueing Tejun Heo
2005-03-23 2:14 ` [PATCH scsi-misc-2.6 03/08] scsi: remove unused scsi_cmnd->internal_timeout field Tejun Heo
2005-03-23 2:14 ` [PATCH scsi-misc-2.6 04/08] scsi: remove meaningless volatile qualifiers from structure definitions Tejun Heo
2005-03-23 4:15 ` James Bottomley
2005-03-23 4:22 ` Jeff Garzik
2005-03-23 5:28 ` Tejun Heo
2005-03-23 15:16 ` James Bottomley
2005-03-23 2:14 ` [PATCH scsi-misc-2.6 05/08] scsi: remove a timer race from scsi_queue_insert() and cleanup timer Tejun Heo
2005-03-23 2:14 ` [PATCH scsi-misc-2.6 06/08] scsi: remove meaningless scsi_cmnd->serial_number_at_timeout field Tejun Heo
2005-03-23 2:14 ` Tejun Heo [this message]
2005-03-23 4:15 ` [PATCH scsi-misc-2.6 07/08] scsi: remove bogus {get|put}_device() calls James Bottomley
2005-03-23 9:13 ` Tejun Heo
2005-03-29 17:02 ` Patrick Mansfield
2005-03-23 2:14 ` [PATCH scsi-misc-2.6 08/08] scsi: fix hot unplug sequence Tejun Heo
2005-03-23 4:08 ` James Bottomley
2005-03-23 4:50 ` Tejun Heo
2005-03-23 7:19 ` Jens Axboe
2005-03-23 15:20 ` James Bottomley
2005-03-23 15:25 ` Jens Axboe
2005-03-25 0:45 ` James Bottomley
2005-03-25 3:15 ` Tejun Heo
2005-03-25 5:02 ` James Bottomley
2005-03-25 5:38 ` Tejun Heo
2005-03-25 19:19 ` James Bottomley
2005-03-25 21:43 ` Tejun Heo
2005-03-25 22:49 ` James Bottomley
2005-03-26 7:27 ` Kai Makisara
2005-03-26 14:48 ` James Bottomley
2005-03-23 15:12 ` 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=20050323021335.0D9E25EE@htj.dyndns.org \
--to=htejun@gmail.com \
--cc=James.Bottomley@steeleye.com \
--cc=axboe@suse.de \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®