public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Patrick Mansfield <patmans@us.ibm.com>
To: linux-scsi@vger.kernel.org
Subject: [PATCH] 5/7 alloc a request_queue on each scsi_alloc_sdev call
Date: Mon, 24 Mar 2003 18:03:25 -0800	[thread overview]
Message-ID: <20030324180325.D15047@beaverton.ibm.com> (raw)
In-Reply-To: <20030324180304.C15047@beaverton.ibm.com>; from patmans@us.ibm.com on Mon, Mar 24, 2003 at 06:03:04PM -0800

Call scsi_alloc_queue each time we call scsi_alloc_sdev; call
scsi_free_queue each time we do not find backing LUN.

This code is less optimal, but leads to cleaner code, and the lock
split-up patch needs this change.

diff -purN -X /home/patman/dontdiff req_fn-cleanup-25/drivers/scsi/scsi_scan.c salloc_queue-25/drivers/scsi/scsi_scan.c
--- req_fn-cleanup-25/drivers/scsi/scsi_scan.c	Mon Mar 24 12:14:28 2003
+++ salloc_queue-25/drivers/scsi/scsi_scan.c	Mon Mar 24 12:15:05 2003
@@ -380,7 +380,7 @@ static void print_inquiry(unsigned char 
  *     Scsi_Device pointer, or NULL on failure.
  **/
 static struct scsi_device *scsi_alloc_sdev(struct Scsi_Host *shost,
-	       	struct request_queue **q, uint channel, uint id, uint lun)
+	       	uint channel, uint id, uint lun)
 {
 	struct scsi_device *sdev, *device;
 
@@ -415,14 +415,9 @@ static struct scsi_device *scsi_alloc_sd
 	 */
 	sdev->borken = 1;
 
-	if (!q || *q == NULL) {
-		sdev->request_queue = scsi_alloc_queue(shost);
-		if (!sdev->request_queue)
-			goto out_free_dev;
-	} else {
-		sdev->request_queue = *q;
-		*q = NULL;
-	}
+	sdev->request_queue = scsi_alloc_queue(shost);
+	if (!sdev->request_queue)
+		goto out_free_dev;
 
 	sdev->request_queue->queuedata = sdev;
 	scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
@@ -462,10 +457,7 @@ static struct scsi_device *scsi_alloc_sd
 	return sdev;
 
 out_free_queue:
-	if (q && sdev->request_queue) {
-		*q = sdev->request_queue;
-		sdev->request_queue = NULL;
-	} else if (sdev->request_queue)
+	if (sdev->request_queue)
 		scsi_free_queue(sdev->request_queue);
 
 out_free_dev:
@@ -1282,15 +1274,15 @@ static int scsi_add_lun(Scsi_Device *sde
  *     SCSI_SCAN_LUN_PRESENT: a new Scsi_Device was allocated and initialized
  **/
 static int scsi_probe_and_add_lun(struct Scsi_Host *host,
-		struct request_queue **q, uint channel, uint id, uint lun,
-		int *bflagsp, struct scsi_device **sdevp)
+		uint channel, uint id, uint lun, int *bflagsp,
+		struct scsi_device **sdevp)
 {
 	struct scsi_device *sdev;
 	struct scsi_request *sreq;
 	unsigned char *result;
 	int bflags, res = SCSI_SCAN_NO_RESPONSE;
 
-	sdev = scsi_alloc_sdev(host, q, channel, id, lun);
+	sdev = scsi_alloc_sdev(host, channel, id, lun);
 	if (!sdev)
 		goto out;
 	sreq = scsi_allocate_request(sdev);
@@ -1344,13 +1336,8 @@ static int scsi_probe_and_add_lun(struct
 	if (res == SCSI_SCAN_LUN_PRESENT) {
 		if (sdevp)
 			*sdevp = sdev;
-	} else {
-		if (q) {
-			*q = sdev->request_queue;
-			sdev->request_queue = NULL;
-		}
+	} else
 		scsi_free_sdev(sdev);
-	}
  out:
 	return res;
 }
@@ -1368,9 +1355,8 @@ static int scsi_probe_and_add_lun(struct
  *
  *     Modifies sdevscan->lun.
  **/
-static void scsi_sequential_lun_scan(struct Scsi_Host *shost,
-	       	struct request_queue **q, uint channel, uint id,
-	       	int bflags, int lun0_res, int scsi_level)
+static void scsi_sequential_lun_scan(struct Scsi_Host *shost, uint channel,
+		uint id, int bflags, int lun0_res, int scsi_level)
 {
 	unsigned int sparse_lun, lun, max_dev_lun;
 
@@ -1438,7 +1424,7 @@ static void scsi_sequential_lun_scan(str
 	 * sparse_lun.
 	 */
 	for (lun = 1; lun < max_dev_lun; ++lun)
-		if ((scsi_probe_and_add_lun(shost, q, channel, id, lun,
+		if ((scsi_probe_and_add_lun(shost, channel, id, lun,
 		      NULL, NULL) != SCSI_SCAN_LUN_PRESENT) && !sparse_lun)
 			return;
 }
@@ -1491,8 +1477,7 @@ static int scsilun_to_int(ScsiLun *scsil
  *     0: scan completed (or no memory, so further scanning is futile)
  *     1: no report lun scan, or not configured
  **/
-static int scsi_report_lun_scan(Scsi_Device *sdev, struct request_queue **q,
-		int bflags)
+static int scsi_report_lun_scan(Scsi_Device *sdev, int bflags)
 {
 #ifdef CONFIG_SCSI_REPORT_LUNS
 
@@ -1653,8 +1638,8 @@ static int scsi_report_lun_scan(Scsi_Dev
 		} else {
 			int res;
 
-			res = scsi_probe_and_add_lun(sdev->host, q,
-				sdev->channel, sdev->id, lun, NULL, NULL);
+			res = scsi_probe_and_add_lun(sdev->host, sdev->channel,
+				sdev->id, lun, NULL, NULL);
 			if (res == SCSI_SCAN_NO_RESPONSE) {
 				/*
 				 * Got some results, but now none, abort.
@@ -1682,8 +1667,7 @@ struct scsi_device *scsi_add_device(stru
 	struct scsi_device *sdev;
 	int error = -ENODEV, res;
 
-	res = scsi_probe_and_add_lun(shost, NULL, channel, id, lun,
-			NULL, &sdev);
+	res = scsi_probe_and_add_lun(shost, channel, id, lun, NULL, &sdev);
 	if (res == SCSI_SCAN_LUN_PRESENT)
 		error = scsi_attach_device(sdev);
 
@@ -1724,8 +1708,8 @@ int scsi_remove_device(struct scsi_devic
  *     First try a REPORT LUN scan, if that does not scan the target, do a
  *     sequential scan of LUNs on the target id.
  **/
-static void scsi_scan_target(struct Scsi_Host *shost, struct request_queue **q,
-			     unsigned int channel, unsigned int id)
+static void scsi_scan_target(struct Scsi_Host *shost, unsigned int channel,
+			     unsigned int id)
 {
 	int bflags = 0;
 	int res;
@@ -1741,14 +1725,14 @@ static void scsi_scan_target(struct Scsi
 	 * Scan LUN 0, if there is some response, scan further. Ideally, we
 	 * would not configure LUN 0 until all LUNs are scanned.
 	 */
-	res = scsi_probe_and_add_lun(shost, q, channel, id, 0, &bflags, &sdev);
+	res = scsi_probe_and_add_lun(shost, channel, id, 0, &bflags, &sdev);
 	if (res == SCSI_SCAN_LUN_PRESENT) {
-		if (scsi_report_lun_scan(sdev, q, bflags) != 0)
+		if (scsi_report_lun_scan(sdev, bflags) != 0)
 			/*
 			 * The REPORT LUN did not scan the target,
 			 * do a sequential scan.
 			 */
-			scsi_sequential_lun_scan(shost, q, channel, id, bflags,
+			scsi_sequential_lun_scan(shost, channel, id, bflags,
 				       	res, sdev->scsi_level);
 	} else if (res == SCSI_SCAN_TARGET_PRESENT) {
 		/*
@@ -1757,7 +1741,7 @@ static void scsi_scan_target(struct Scsi
 		 * sequential lun scan with a bflags of SPARSELUN and
 		 * a default scsi level of SCSI_2
 		 */
-		scsi_sequential_lun_scan(shost, q, channel, id, BLIST_SPARSELUN,
+		scsi_sequential_lun_scan(shost, channel, id, BLIST_SPARSELUN,
 				SCSI_SCAN_TARGET_PRESENT, SCSI_2);
 	}
 }
@@ -1772,7 +1756,6 @@ static void scsi_scan_target(struct Scsi
  **/
 void scsi_scan_host(struct Scsi_Host *shost)
 {
-	struct request_queue *q = NULL;
 	uint channel, id, order_id;
 
 	/*
@@ -1797,12 +1780,9 @@ void scsi_scan_host(struct Scsi_Host *sh
 				order_id = shost->max_id - id - 1;
 			else
 				order_id = id;
-			scsi_scan_target(shost, &q, channel, order_id);
+			scsi_scan_target(shost, channel, order_id);
 		}
 	}
-
-	if (q)
-		scsi_free_queue(q);
 }
 
 void scsi_forget_host(struct Scsi_Host *shost)
@@ -1841,7 +1821,7 @@ struct scsi_device *scsi_get_host_dev(st
 {
 	struct scsi_device *sdev;
 
-	sdev = scsi_alloc_sdev(shost, NULL, 0, shost->this_id, 0);
+	sdev = scsi_alloc_sdev(shost, 0, shost->this_id, 0);
 	if (sdev) {
 		sdev->borken = 0;
 	}

  reply	other threads:[~2003-03-25  2:06 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-25  1:53 [PATCH] 0/7 per scsi_device queue lock patches Patrick Mansfield
2003-03-25  1:54 ` [PATCH] 1/7 starved changes - use a list_head for starved queue's Patrick Mansfield
2003-03-25  2:02   ` [PATCH] 2/7 add missing scsi_queue_next_request calls Patrick Mansfield
2003-03-25  2:02     ` [PATCH] 3/7 consolidate single_lun code Patrick Mansfield
2003-03-25  2:03       ` [PATCH] 4/7 cleanup/consolidate code in scsi_request_fn Patrick Mansfield
2003-03-25  2:03         ` Patrick Mansfield [this message]
2003-03-25  2:03           ` [PATCH] 6/7 add and use a per-scsi_device queue_lock Patrick Mansfield
2003-03-25  2:04             ` [PATCH] 7/7 fix single_lun code for " Patrick Mansfield
2003-03-25 21:23               ` Luben Tuikov
2003-03-26 21:47                 ` Patrick Mansfield
2003-03-26 22:12                   ` Luben Tuikov
2003-03-25 21:03             ` [PATCH] 6/7 add and use a " Luben Tuikov
2003-03-26 21:33               ` Patrick Mansfield
2003-03-25 21:20             ` James Bottomley
2003-03-26  2:01               ` Patrick Mansfield
2003-03-27 16:09                 ` James Bottomley
2003-03-28  0:30                   ` Patrick Mansfield
2003-03-25  7:12           ` [PATCH] 5/7 alloc a request_queue on each scsi_alloc_sdev call Christoph Hellwig
2003-03-25  7:18             ` Jens Axboe
2003-03-25 21:32         ` [PATCH] 4/7 cleanup/consolidate code in scsi_request_fn Luben Tuikov
2003-03-26  0:58           ` Patrick Mansfield
2003-03-26 17:07             ` Luben Tuikov
2003-03-26 17:13               ` Patrick Mansfield
2003-03-26 17:25                 ` Luben Tuikov
2003-03-25 20:36       ` [PATCH] 3/7 consolidate single_lun code Luben Tuikov
2003-03-26 19:11         ` Patrick Mansfield
2003-03-26 22:05           ` Luben Tuikov
2003-03-27 22:43             ` Patrick Mansfield
2003-03-28 15:09               ` Luben Tuikov
2003-03-28 20:06                 ` Patrick Mansfield
2003-03-25 20:50       ` Luben Tuikov
2003-03-25 19:41     ` [PATCH] 2/7 add missing scsi_queue_next_request calls Luben Tuikov
2003-03-25 19:39   ` [PATCH] 1/7 starved changes - use a list_head for starved queue's Luben Tuikov
2003-03-27 16:14 ` [PATCH] 0/7 per scsi_device queue lock patches 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=20030324180325.D15047@beaverton.ibm.com \
    --to=patmans@us.ibm.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