public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Miquel van Smoorenburg <miquels@cistron.nl>
To: Christoph Hellwig <hch@infradead.org>
Cc: James.Bottomley@SteelEye.com, linux-scsi@vger.kernel.org
Subject: Re: make sysfs scsi queue_depth read/write [patch]
Date: Wed, 14 Jan 2004 13:21:47 +0100	[thread overview]
Message-ID: <20040114122147.GA15152@cistron.nl> (raw)
In-Reply-To: <20040114115524.A29732@infradead.org>

According to Christoph Hellwig:
> Patch looks okay [...]
> This needs some locking.  Currently we have a single global lock protecting
> queue_depth updates, but none for reads.   (which looks a bit racy already,
> but no need to make it worse..)

Well, queue_depth is 32 bits, I think reading/writing to that is
atomic on most/all CPUs. We're not doing read/modify/write, just
an assignment, so it probably doesn't need locking.

Anyway, how about this:

--- linux-2.6.1/drivers/scsi/scsi.c.ORIG	2004-01-14 03:52:53.000000000 +0100
+++ linux-2.6.1/drivers/scsi/scsi.c	2004-01-14 13:12:37.000000000 +0100
@@ -889,6 +892,8 @@
 			sdev->ordered_tags = 0;
 			sdev->simple_tags = 1;
 			break;
+		case -1: /* Just set queue depth */
+			break;
 		default:
 			printk(KERN_WARNING "(scsi%d:%d:%d:%d) "
 				"scsi_adjust_queue_depth, bad queue type, "
--- linux-2.6.1/drivers/scsi/scsi_sysfs.c.ORIG	2004-01-09 07:59:10.000000000 +0100
+++ linux-2.6.1/drivers/scsi/scsi_sysfs.c	2004-01-14 13:13:47.000000000 +0100
@@ -259,7 +259,6 @@
  * Create the actual show/store functions and data structures.
  */
 sdev_rd_attr (device_blocked, "%d\n");
-sdev_rd_attr (queue_depth, "%d\n");
 sdev_rd_attr (type, "%d\n");
 sdev_rd_attr (scsi_level, "%d\n");
 sdev_rd_attr (vendor, "%.8s\n");
@@ -283,6 +282,22 @@
 };
 static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete);
 
+sdev_show_function(queue_depth, "%d\n")
+static ssize_t sdev_store_queue_depth(struct device *dev, const char *buf,
+				 size_t count)
+{
+	int val;
+	struct scsi_device *sdev;
+	if (sscanf(buf, "%d", &val) != 1)
+		return -EINVAL;
+	sdev = to_scsi_device(dev);
+	if (val < 1 || val > sdev->host->cmd_per_lun)
+		return -EINVAL;
+	scsi_adjust_queue_depth(sdev, -1, val);
+	return count;
+}
+static DEVICE_ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth, sdev_store_queue_depth)
+
 /* Default template for device attributes.  May NOT be modified */
 static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
 	&dev_attr_device_blocked,


Mike.

  reply	other threads:[~2004-01-14 12:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-14 11:41 make sysfs scsi queue_depth read/write [patch] Miquel van Smoorenburg
2004-01-14 11:55 ` Christoph Hellwig
2004-01-14 12:21   ` Miquel van Smoorenburg [this message]
2004-01-14 14:56 ` James Bottomley
2004-01-14 15:37   ` Miquel van Smoorenburg

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=20040114122147.GA15152@cistron.nl \
    --to=miquels@cistron.nl \
    --cc=James.Bottomley@SteelEye.com \
    --cc=hch@infradead.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