diff options
author | Jack Wang <jinpu.wang@profitbricks.com> | 2013-11-07 05:37:37 -0500 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2013-11-08 17:43:17 -0500 |
commit | 71444b97816ae08a1cc435f044f9f1f4cbd51e6a (patch) | |
tree | 832d457167b77f33684fc3d2443c5c5a8b0d4da3 /drivers/infiniband | |
parent | 4d73f95f708ce540a85113b00f5363d0593d871d (diff) |
IB/srp: Add change_queue_depth and change_queue_type support
Currently, it's not possible to change queue depth for a device behind
SRP host. Sometimes, we need to adjust queue_depth for performance
reason (eg storage busy, we need lower queue_depth to avoid running
into SCSI error handler), so this patch add support for SRP driver.
Signed-off-by: Jack Wang <jinpu.wang@profitbricks.com>
Tested-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: David Dillow <dillowda@ornl.gov>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 6aa660d188a3..a8f8d0b8a777 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <scsi/scsi.h> | 46 | #include <scsi/scsi.h> |
47 | #include <scsi/scsi_device.h> | 47 | #include <scsi/scsi_device.h> |
48 | #include <scsi/scsi_dbg.h> | 48 | #include <scsi/scsi_dbg.h> |
49 | #include <scsi/scsi_tcq.h> | ||
49 | #include <scsi/srp.h> | 50 | #include <scsi/srp.h> |
50 | #include <scsi/scsi_transport_srp.h> | 51 | #include <scsi/scsi_transport_srp.h> |
51 | 52 | ||
@@ -1882,6 +1883,57 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) | |||
1882 | return 0; | 1883 | return 0; |
1883 | } | 1884 | } |
1884 | 1885 | ||
1886 | /** | ||
1887 | * srp_change_queue_type - changing device queue tag type | ||
1888 | * @sdev: scsi device struct | ||
1889 | * @tag_type: requested tag type | ||
1890 | * | ||
1891 | * Returns queue tag type. | ||
1892 | */ | ||
1893 | static int | ||
1894 | srp_change_queue_type(struct scsi_device *sdev, int tag_type) | ||
1895 | { | ||
1896 | if (sdev->tagged_supported) { | ||
1897 | scsi_set_tag_type(sdev, tag_type); | ||
1898 | if (tag_type) | ||
1899 | scsi_activate_tcq(sdev, sdev->queue_depth); | ||
1900 | else | ||
1901 | scsi_deactivate_tcq(sdev, sdev->queue_depth); | ||
1902 | } else | ||
1903 | tag_type = 0; | ||
1904 | |||
1905 | return tag_type; | ||
1906 | } | ||
1907 | |||
1908 | /** | ||
1909 | * srp_change_queue_depth - setting device queue depth | ||
1910 | * @sdev: scsi device struct | ||
1911 | * @qdepth: requested queue depth | ||
1912 | * @reason: SCSI_QDEPTH_DEFAULT/SCSI_QDEPTH_QFULL/SCSI_QDEPTH_RAMP_UP | ||
1913 | * (see include/scsi/scsi_host.h for definition) | ||
1914 | * | ||
1915 | * Returns queue depth. | ||
1916 | */ | ||
1917 | static int | ||
1918 | srp_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) | ||
1919 | { | ||
1920 | struct Scsi_Host *shost = sdev->host; | ||
1921 | int max_depth; | ||
1922 | if (reason == SCSI_QDEPTH_DEFAULT || reason == SCSI_QDEPTH_RAMP_UP) { | ||
1923 | max_depth = shost->can_queue; | ||
1924 | if (!sdev->tagged_supported) | ||
1925 | max_depth = 1; | ||
1926 | if (qdepth > max_depth) | ||
1927 | qdepth = max_depth; | ||
1928 | scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); | ||
1929 | } else if (reason == SCSI_QDEPTH_QFULL) | ||
1930 | scsi_track_queue_full(sdev, qdepth); | ||
1931 | else | ||
1932 | return -EOPNOTSUPP; | ||
1933 | |||
1934 | return sdev->queue_depth; | ||
1935 | } | ||
1936 | |||
1885 | static int srp_send_tsk_mgmt(struct srp_target_port *target, | 1937 | static int srp_send_tsk_mgmt(struct srp_target_port *target, |
1886 | u64 req_tag, unsigned int lun, u8 func) | 1938 | u64 req_tag, unsigned int lun, u8 func) |
1887 | { | 1939 | { |
@@ -2173,6 +2225,8 @@ static struct scsi_host_template srp_template = { | |||
2173 | .slave_configure = srp_slave_configure, | 2225 | .slave_configure = srp_slave_configure, |
2174 | .info = srp_target_info, | 2226 | .info = srp_target_info, |
2175 | .queuecommand = srp_queuecommand, | 2227 | .queuecommand = srp_queuecommand, |
2228 | .change_queue_depth = srp_change_queue_depth, | ||
2229 | .change_queue_type = srp_change_queue_type, | ||
2176 | .eh_abort_handler = srp_abort, | 2230 | .eh_abort_handler = srp_abort, |
2177 | .eh_device_reset_handler = srp_reset_device, | 2231 | .eh_device_reset_handler = srp_reset_device, |
2178 | .eh_host_reset_handler = srp_reset_host, | 2232 | .eh_host_reset_handler = srp_reset_host, |