Skip to content

Commit e368400

Browse files
Brian Kingmartinkpetersen
authored andcommitted
scsi: ibmvfc: Add max_sectors module parameter
There are some scenarios that can occur, such as performing an upgrade of the virtual I/O server, where the supported max transfer of the backing device for an ibmvfc HBA can change. If the max transfer of the backing device decreases, this can cause issues with previously discovered LUNs. This patch accomplishes two things. First, it changes the default ibmvfc max transfer value to 1MB. This is generally supported by all backing devices, which should mitigate this issue out of the box. Secondly, it adds a module parameter, enabling a user to increase the max transfer value to values that are larger than 1MB, as long as they have configured these larger values on the virtual I/O server as well. [mkp: fix checkpatch warnings] Signed-off-by: Brian King <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Martin Wilck <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent b112947 commit e368400

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

drivers/scsi/ibmvscsi/ibmvfc.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static unsigned int default_timeout = IBMVFC_DEFAULT_TIMEOUT;
3737
static u64 max_lun = IBMVFC_MAX_LUN;
3838
static unsigned int max_targets = IBMVFC_MAX_TARGETS;
3939
static unsigned int max_requests = IBMVFC_MAX_REQUESTS_DEFAULT;
40+
static u16 max_sectors = IBMVFC_MAX_SECTORS;
4041
static u16 scsi_qdepth = IBMVFC_SCSI_QDEPTH;
4142
static unsigned int disc_threads = IBMVFC_MAX_DISC_THREADS;
4243
static unsigned int ibmvfc_debug = IBMVFC_DEBUG;
@@ -83,6 +84,9 @@ MODULE_PARM_DESC(default_timeout,
8384
module_param_named(max_requests, max_requests, uint, S_IRUGO);
8485
MODULE_PARM_DESC(max_requests, "Maximum requests for this adapter. "
8586
"[Default=" __stringify(IBMVFC_MAX_REQUESTS_DEFAULT) "]");
87+
module_param_named(max_sectors, max_sectors, ushort, S_IRUGO);
88+
MODULE_PARM_DESC(max_sectors, "Maximum sectors for this adapter. "
89+
"[Default=" __stringify(IBMVFC_MAX_SECTORS) "]");
8690
module_param_named(scsi_qdepth, scsi_qdepth, ushort, S_IRUGO);
8791
MODULE_PARM_DESC(scsi_qdepth, "Maximum scsi command depth per adapter queue. "
8892
"[Default=" __stringify(IBMVFC_SCSI_QDEPTH) "]");
@@ -1494,7 +1498,7 @@ static void ibmvfc_set_login_info(struct ibmvfc_host *vhost)
14941498
memset(login_info, 0, sizeof(*login_info));
14951499

14961500
login_info->ostype = cpu_to_be32(IBMVFC_OS_LINUX);
1497-
login_info->max_dma_len = cpu_to_be64(IBMVFC_MAX_SECTORS << 9);
1501+
login_info->max_dma_len = cpu_to_be64(max_sectors << 9);
14981502
login_info->max_payload = cpu_to_be32(sizeof(struct ibmvfc_fcp_cmd_iu));
14991503
login_info->max_response = cpu_to_be32(sizeof(struct ibmvfc_fcp_rsp));
15001504
login_info->partition_num = cpu_to_be32(vhost->partition_number);
@@ -5230,7 +5234,7 @@ static void ibmvfc_npiv_login_done(struct ibmvfc_event *evt)
52305234
}
52315235

52325236
vhost->logged_in = 1;
5233-
npiv_max_sectors = min((uint)(be64_to_cpu(rsp->max_dma_len) >> 9), IBMVFC_MAX_SECTORS);
5237+
npiv_max_sectors = min((uint)(be64_to_cpu(rsp->max_dma_len) >> 9), max_sectors);
52345238
dev_info(vhost->dev, "Host partition: %s, device: %s %s %s max sectors %u\n",
52355239
rsp->partition_name, rsp->device_name, rsp->port_loc_code,
52365240
rsp->drc_name, npiv_max_sectors);
@@ -6329,7 +6333,7 @@ static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
63296333
shost->can_queue = scsi_qdepth;
63306334
shost->max_lun = max_lun;
63316335
shost->max_id = max_targets;
6332-
shost->max_sectors = IBMVFC_MAX_SECTORS;
6336+
shost->max_sectors = max_sectors;
63336337
shost->max_cmd_len = IBMVFC_MAX_CDB_LEN;
63346338
shost->unique_id = shost->host_no;
63356339
shost->nr_hw_queues = mq_enabled ? min(max_scsi_queues, nr_scsi_hw_queues) : 1;
@@ -6556,6 +6560,7 @@ static struct fc_function_template ibmvfc_transport_functions = {
65566560
**/
65576561
static int __init ibmvfc_module_init(void)
65586562
{
6563+
int min_max_sectors = PAGE_SIZE >> 9;
65596564
int rc;
65606565

65616566
if (!firmware_has_feature(FW_FEATURE_VIO))
@@ -6564,6 +6569,16 @@ static int __init ibmvfc_module_init(void)
65646569
printk(KERN_INFO IBMVFC_NAME": IBM Virtual Fibre Channel Driver version: %s %s\n",
65656570
IBMVFC_DRIVER_VERSION, IBMVFC_DRIVER_DATE);
65666571

6572+
/*
6573+
* Range check the max_sectors module parameter. The upper bounds is
6574+
* implicity checked since the parameter is a ushort.
6575+
*/
6576+
if (max_sectors < min_max_sectors) {
6577+
printk(KERN_ERR IBMVFC_NAME ": max_sectors must be at least %d.\n",
6578+
min_max_sectors);
6579+
max_sectors = min_max_sectors;
6580+
}
6581+
65676582
ibmvfc_transport_template = fc_attach_transport(&ibmvfc_transport_functions);
65686583
if (!ibmvfc_transport_template)
65696584
return -ENOMEM;

drivers/scsi/ibmvscsi/ibmvfc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define IBMVFC_DEBUG 0
3333
#define IBMVFC_MAX_TARGETS 1024
3434
#define IBMVFC_MAX_LUN 0xffffffff
35-
#define IBMVFC_MAX_SECTORS 0xffffu
35+
#define IBMVFC_MAX_SECTORS 2048
3636
#define IBMVFC_MAX_DISC_THREADS 4
3737
#define IBMVFC_TGT_MEMPOOL_SZ 64
3838
#define IBMVFC_MAX_CMDS_PER_LUN 64

0 commit comments

Comments
 (0)