]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[SCSI] scsi_dh: add the interface scsi_dh_set_params()
authorChandra Seetharaman <sekharan@us.ibm.com>
Mon, 3 Aug 2009 19:42:33 +0000 (12:42 -0700)
committerJames Bottomley <James.Bottomley@suse.de>
Sat, 22 Aug 2009 22:52:14 +0000 (17:52 -0500)
When we moved the device handler functionality from dm layer to SCSI layer
we dropped the parameter functionality.

This path adds an interface to scsi dh layer to set device handler
parameters.

Basically, multipath layer need to create a string with all the parameters
and call scsi_dh_set_params() after it called scsi_dh_attach() on a
device.

If a device handler provides such an interface it will handle the parameters
as it expects them.

Reported-by: Eddie Williams <Eddie.Williams@steeleye.com>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Tested-by: Eddie Williams <Eddie.Williams@steeleye.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/device_handler/scsi_dh.c
include/scsi/scsi_device.h
include/scsi/scsi_dh.h

index 53a7385e1b4d22d32767c69ef719d348b8fff361..3ee1cbc89479ffa74332fd06553e3d770296f8a2 100644 (file)
@@ -451,6 +451,39 @@ int scsi_dh_activate(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(scsi_dh_activate);
 
+/*
+ * scsi_dh_set_params - set the parameters for the device as per the
+ *      string specified in params.
+ * @q - Request queue that is associated with the scsi_device for
+ *      which the parameters to be set.
+ * @params - parameters in the following format
+ *      "no_of_params\0param1\0param2\0param3\0...\0"
+ *      for example, string for 2 parameters with value 10 and 21
+ *      is specified as "2\010\021\0".
+ */
+int scsi_dh_set_params(struct request_queue *q, const char *params)
+{
+       int err = -SCSI_DH_NOSYS;
+       unsigned long flags;
+       struct scsi_device *sdev;
+       struct scsi_device_handler *scsi_dh = NULL;
+
+       spin_lock_irqsave(q->queue_lock, flags);
+       sdev = q->queuedata;
+       if (sdev && sdev->scsi_dh_data)
+               scsi_dh = sdev->scsi_dh_data->scsi_dh;
+       if (scsi_dh && scsi_dh->set_params && get_device(&sdev->sdev_gendev))
+               err = 0;
+       spin_unlock_irqrestore(q->queue_lock, flags);
+
+       if (err)
+               return err;
+       err = scsi_dh->set_params(sdev, params);
+       put_device(&sdev->sdev_gendev);
+       return err;
+}
+EXPORT_SYMBOL_GPL(scsi_dh_set_params);
+
 /*
  * scsi_dh_handler_exist - Return TRUE(1) if a device handler exists for
  *     the given name. FALSE(0) otherwise.
index 1f3a4c8044c07c7f5281bcd74a4cbe5495dfd1ac..9af48cbf0036782386e6cfdf403476b8b159d563 100644 (file)
@@ -187,6 +187,7 @@ struct scsi_device_handler {
        void (*detach)(struct scsi_device *);
        int (*activate)(struct scsi_device *);
        int (*prep_fn)(struct scsi_device *, struct request *);
+       int (*set_params)(struct scsi_device *, const char *);
 };
 
 struct scsi_dh_data {
index 33efce20c26c937c08a89380dd1949b9eed60806..ff2407405b42e5ed5ec0a4017b633ef6ce746a02 100644 (file)
@@ -60,6 +60,7 @@ extern int scsi_dh_activate(struct request_queue *);
 extern int scsi_dh_handler_exist(const char *);
 extern int scsi_dh_attach(struct request_queue *, const char *);
 extern void scsi_dh_detach(struct request_queue *);
+extern int scsi_dh_set_params(struct request_queue *, const char *);
 #else
 static inline int scsi_dh_activate(struct request_queue *req)
 {
@@ -77,4 +78,8 @@ static inline void scsi_dh_detach(struct request_queue *q)
 {
        return;
 }
+static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
+{
+       return -SCSI_DH_NOSYS;
+}
 #endif