* [PATCH] tmscsim: scsi device attributes
@ 2004-10-21 20:31 Guennadi Liakhovetski
2004-10-22 12:40 ` Matthew Wilcox
0 siblings, 1 reply; 4+ messages in thread
From: Guennadi Liakhovetski @ 2004-10-21 20:31 UTC (permalink / raw)
To: James Bottomley; +Cc: linux-scsi
A write method to adjust per-device queue-depth
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
diff -u a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
--- a/drivers/scsi/tmscsim.c Wed Oct 20 21:49:46 2004
+++ b/drivers/scsi/tmscsim.c Thu Oct 21 22:03:35 2004
@@ -2275,6 +2275,33 @@
return 0;
}
+static ssize_t dc390_store_queue_depth(struct device *dev, const char *buf, size_t count)
+{
+ struct scsi_device *sdev = to_scsi_device(dev);
+ struct dc390_acb *acb = (struct dc390_acb *)sdev->host->hostdata;
+ int queue_depth = simple_strtoul(buf, NULL, 0);
+
+ if (queue_depth > acb->TagMaxNum || !sdev->tagged_supported)
+ return -EINVAL;
+
+ scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, queue_depth);
+
+ return count;
+}
+
+static struct device_attribute dc390_queue_depth_attr = {
+ .attr = {
+ .name = "queue_depth",
+ .mode = S_IRUSR | S_IWUSR,
+ },
+ .store = dc390_store_queue_depth
+};
+
+static struct device_attribute *dc390_dev_attrs[] = {
+ &dc390_queue_depth_attr,
+ NULL,
+};
+
static struct scsi_host_template driver_template = {
.module = THIS_MODULE,
.proc_name = "tmscsim",
@@ -2290,6 +2317,7 @@
.sg_tablesize = SG_ALL,
.cmd_per_lun = 1,
.use_clustering = DISABLE_CLUSTERING,
+ .sdev_attrs = dc390_dev_attrs,
};
/***********************************************************************
Thanks
Guennadi
---
Guennadi Liakhovetski
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tmscsim: scsi device attributes
2004-10-21 20:31 [PATCH] tmscsim: scsi device attributes Guennadi Liakhovetski
@ 2004-10-22 12:40 ` Matthew Wilcox
2004-10-22 13:00 ` James Bottomley
0 siblings, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2004-10-22 12:40 UTC (permalink / raw)
To: Guennadi Liakhovetski; +Cc: James Bottomley, linux-scsi
On Thu, Oct 21, 2004 at 10:31:25PM +0200, Guennadi Liakhovetski wrote:
> A write method to adjust per-device queue-depth
How about something more along the following lines? I haven't converted
sym2 to the generic queue code yet, so it's untested (and is obviously
broken because nothing initialises max_queue_depth).
Index: drivers/scsi/scsi_sysfs.c
===================================================================
RCS file: /var/cvs/linux-2.6/drivers/scsi/scsi_sysfs.c,v
retrieving revision 1.15
diff -u -p -r1.15 scsi_sysfs.c
--- drivers/scsi/scsi_sysfs.c 21 Oct 2004 18:59:23 -0000 1.15
+++ drivers/scsi/scsi_sysfs.c 22 Oct 2004 12:29:51 -0000
@@ -15,6 +15,7 @@
#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
+#include <scsi/scsi_tcq.h>
#include <scsi/scsi_transport.h>
#include "scsi_priv.h"
@@ -248,7 +249,7 @@ static DEVICE_ATTR(field, S_IRUGO, sdev_
/*
- * sdev_rd_attr: create a function and attribute variable for a
+ * sdev_rw_attr: create a function and attribute variable for a
* read/write field.
*/
#define sdev_rw_attr(field, format_string) \
@@ -268,7 +269,7 @@ static DEVICE_ATTR(field, S_IRUGO | S_IW
* so leave this code in */
#if 0
/*
- * sdev_rd_attr: create a function and attribute variable for a
+ * sdev_rw_attr_bit: create a function and attribute variable for a
* read/write bit field.
*/
#define sdev_rw_attr_bit(field) \
@@ -310,12 +311,28 @@ static int scsi_sdev_check_buf_bit(const
* 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");
sdev_rd_attr (model, "%.16s\n");
sdev_rd_attr (rev, "%.4s\n");
+
+sdev_show_function(queue_depth, "%d\n")
+
+static ssize_t
+sdev_store_queue_depth(struct device *dev, const char *buf, size_t count)
+{
+ struct scsi_device *sdev = to_scsi_device(dev);
+ int new_depth = simple_strtoul(buf, NULL, 0);
+
+ if (new_depth > sdev->max_queue_depth)
+ return -EINVAL;
+
+ scsi_activate_tcq(sdev, new_depth);
+ return count;
+}
+
+static DEVICE_ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth, sdev_store_queue_depth);
static ssize_t
sdev_show_timeout (struct device *dev, char *buf)
Index: include/scsi/scsi_device.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/scsi/scsi_device.h,v
retrieving revision 1.13
diff -u -p -r1.13 scsi_device.h
--- include/scsi/scsi_device.h 21 Oct 2004 19:00:10 -0000 1.13
+++ include/scsi/scsi_device.h 22 Oct 2004 12:29:59 -0000
@@ -50,6 +50,7 @@ struct scsi_device {
struct list_head starved_entry;
struct scsi_cmnd *current_cmnd; /* currently active command */
unsigned short queue_depth; /* How deep of a queue we want */
+ unsigned short max_queue_depth; /* The limit for the above */
unsigned short last_queue_full_depth; /* These two are used by */
unsigned short last_queue_full_count; /* scsi_track_queue_full() */
unsigned long last_queue_full_time;/* don't let QUEUE_FULLs on the same
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tmscsim: scsi device attributes
2004-10-22 12:40 ` Matthew Wilcox
@ 2004-10-22 13:00 ` James Bottomley
2004-10-22 19:27 ` Guennadi Liakhovetski
0 siblings, 1 reply; 4+ messages in thread
From: James Bottomley @ 2004-10-22 13:00 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: Guennadi Liakhovetski, SCSI Mailing List
On Fri, 2004-10-22 at 08:40, Matthew Wilcox wrote:
> How about something more along the following lines? I haven't converted
> sym2 to the generic queue code yet, so it's untested (and is obviously
> broken because nothing initialises max_queue_depth).
Yes, I was considering something like this. The original queue code in
53c700 was designed as an example of how to do attribute overrides.
However, there needs to be a callback into the LLD to tell it that the
queue is being overriden (and allow a veto for depth increases). I'll
look at adding the extra pieces.
James
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tmscsim: scsi device attributes
2004-10-22 13:00 ` James Bottomley
@ 2004-10-22 19:27 ` Guennadi Liakhovetski
0 siblings, 0 replies; 4+ messages in thread
From: Guennadi Liakhovetski @ 2004-10-22 19:27 UTC (permalink / raw)
To: James Bottomley; +Cc: Matthew Wilcox, SCSI Mailing List
On Fri, 22 Oct 2004, James Bottomley wrote:
> On Fri, 2004-10-22 at 08:40, Matthew Wilcox wrote:
> > How about something more along the following lines? I haven't converted
> > sym2 to the generic queue code yet, so it's untested (and is obviously
> > broken because nothing initialises max_queue_depth).
>
> Yes, I was considering something like this. The original queue code in
> 53c700 was designed as an example of how to do attribute overrides.
> However, there needs to be a callback into the LLD to tell it that the
> queue is being overriden (and allow a veto for depth increases). I'll
> look at adding the extra pieces.
Right. Feel free to hold off the patch, until you implement the generic
sdev_store_queue_depth().
Thanks
Guennadi
---
Guennadi Liakhovetski
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-10-22 21:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-21 20:31 [PATCH] tmscsim: scsi device attributes Guennadi Liakhovetski
2004-10-22 12:40 ` Matthew Wilcox
2004-10-22 13:00 ` James Bottomley
2004-10-22 19:27 ` Guennadi Liakhovetski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox