From f2d7532eb1e617089af76b427238108a5aa8c013 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 18 Nov 2015 03:59:30 +0000 Subject: [PATCH 001/121] scst: Add user space control for suspend/resume activities Useful to speed up mass management git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6693 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/README | 13 +++++++++++ scst/README_in-tree | 13 +++++++++++ scst/src/scst_main.c | 10 +++++++++ scst/src/scst_priv.h | 2 ++ scst/src/scst_sysfs.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+) diff --git a/scst/README b/scst/README index 978d8f6fb..395be9cc6 100644 --- a/scst/README +++ b/scst/README @@ -441,6 +441,19 @@ following entries: have different IDs and SNs. For instance, VDISK dev handler uses this ID to generate T10 vendor specific identifier and SN of the devices. + - suspend - globally suspends or releases all SCSI activities on all + devices. Useful for mass management, like adding or deleting LUNs. + Writing to it value v: + + * v > 0 - suspends activities, but waits no more, than v seconds + + * v = 0 - suspends activities, waits indefinitely + + * V < 0 - releases activities. + + Reading from this attribute returns number of previous suspend + requests. + - threads - allows to read and set number of global SCST I/O threads. Those threads used with async. dev handlers, for instance, vdisk BLOCKIO or NULLIO. diff --git a/scst/README_in-tree b/scst/README_in-tree index 91d0b6ca6..d1bcc9d59 100644 --- a/scst/README_in-tree +++ b/scst/README_in-tree @@ -305,6 +305,19 @@ following entries: have different IDs and SNs. For instance, VDISK dev handler uses this ID to generate T10 vendor specific identifier and SN of the devices. + - suspend - globally suspends or releases all SCSI activities on all + devices. Useful for mass management, like adding or deleting LUNs. + Writing to it value v: + + * v > 0 - suspends activities, but waits no more, than v seconds + + * v = 0 - suspends activities, waits indefinitely + + * V < 0 - releases activities. + + Reading from this attribute returns number of previous suspend + requests. + - threads - allows to read and set number of global SCST I/O threads. Those threads used with async. dev handlers, for instance, vdisk BLOCKIO or NULLIO. diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 85ab18fe1..4bfde9df1 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -1057,6 +1057,11 @@ static void __scst_resume_activity(void) TRACE_ENTRY(); + if (suspend_count == 0) { + PRINT_WARNING("Resume without suspend"); + goto out; + } + suspend_count--; TRACE_MGMT_DBG("suspend_count %d left", suspend_count); if (suspend_count > 0) @@ -1117,6 +1122,11 @@ void scst_resume_activity(void) } EXPORT_SYMBOL_GPL(scst_resume_activity); +int scst_get_suspend_count(void) +{ + return suspend_count; +} + static int scst_register_device(struct scsi_device *scsidp) { int res; diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 327504f35..6740845c6 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -729,6 +729,8 @@ void scst_ext_unblock_dev(struct scst_device *dev, bool stpg); void __scst_ext_blocking_done(struct scst_device *dev); void scst_ext_blocking_done(struct scst_device *dev); +int scst_get_suspend_count(void); + /* * Increases global SCST ref counters which prevent from entering into suspended * activities stage, so protects from any global management operations. diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 9b7336dd8..62497ecdc 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -7056,6 +7056,55 @@ static struct kobj_attribute scst_max_tasklet_cmd_attr = __ATTR(max_tasklet_cmd, S_IRUGO | S_IWUSR, scst_max_tasklet_cmd_show, scst_max_tasklet_cmd_store); +static ssize_t scst_suspend_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + int count; + + TRACE_ENTRY(); + + count = sprintf(buf, "%d\n", scst_get_suspend_count()); + + TRACE_EXIT(); + return count; +} + +static ssize_t scst_suspend_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + int res; + long val; + + TRACE_ENTRY(); + + res = kstrtol(buf, 0, &val); + if (res != 0) { + PRINT_ERROR("kstrtoul() for %s failed: %d ", buf, res); + goto out; + } + + if (val >= 0) { + PRINT_INFO("SYSFS: suspending activities (timeout %ld)...", val); + res = scst_suspend_activity(val*HZ); + if (res == 0) + PRINT_INFO("sysfs suspending done"); + } else { + PRINT_INFO("SYSFS: resuming activities"); + scst_resume_activity(); + } + + if (res == 0) + res = count; + +out: + TRACE_EXIT_RES(res); + return res; +} + +static struct kobj_attribute scst_suspend_attr = + __ATTR(suspend, S_IRUGO | S_IWUSR, scst_suspend_show, + scst_suspend_store); + #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) static ssize_t scst_main_trace_level_show(struct kobject *kobj, @@ -7281,6 +7330,7 @@ static struct attribute *scst_sysfs_root_default_attrs[] = { &scst_threads_attr.attr, &scst_setup_id_attr.attr, &scst_max_tasklet_cmd_attr.attr, + &scst_suspend_attr.attr, #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) &scst_main_trace_level_attr.attr, #endif From 1c9b1f0baad8cc0674e0e0d44bf65fa3b0fa78a8 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 18 Nov 2015 04:09:50 +0000 Subject: [PATCH 002/121] scst: Rework Copy Manager's sysfs interface The old version had management incompatible with scstadmin and had issues with LUNs management. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6694 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/README | 25 ++-- scst/README_in-tree | 25 ++-- scst/src/scst_copy_mgr.c | 273 +++++++++++++++++---------------------- scst/src/scst_lib.c | 60 ++++++--- scst/src/scst_main.c | 10 +- scst/src/scst_priv.h | 20 ++- scst/src/scst_proc.c | 8 +- scst/src/scst_sysfs.c | 11 +- 8 files changed, 206 insertions(+), 226 deletions(-) diff --git a/scst/README b/scst/README index 395be9cc6..8da5009cc 100644 --- a/scst/README +++ b/scst/README @@ -1859,34 +1859,25 @@ EXTENDED COPY ~~~~~~~~~~~~~ SCST implements EXTENDED COPY via internal Copy Manager target. This -target has the following specific attributes in its sysfs: +target has the following specific attribute in its sysfs: - allow_not_connected_copy - if not set (default), an initiator can perform copy only between devices it has direct access to via any target/session. If set, any initiator can copy between any devices in the system. - - mgmt - this attribute allows to control data from which devices can -be copied using Copy Manager. By default, devices belonging to dev -handlers with flag auto_cm_assignment_possible set are auto assigned to -the Copy Manager on the registration. Currently, only vdisk has this -flag set, so all other devices (pass-through, user space, etc.) should -be assigned to the Copy Manager manually. - -Mgmt attribute supports the following commands: - - - add [vname|H:C:I:L] - adds device with name vname or H:C:I:L numbers -(pass-through) to the Copy Manager. - - - del [vname|H:C:I:L] - deletes device with name vname or H:C:I:L numbers -(pass-through) from the Copy Manager. - +The Copy Manager has access only to those devices, for which it has LUNs +in /sys/kernel/scst_tgt/targets/copy_manager/copy_manager_tgt/luns/. +Devices from scst_vdisk dev handler added to it automatically upon +registration, but for other devices you need to manually add LUNs there +the same way as for any target driver. You can also delete any device at +any time from the Copy Manager visibility by deleting the corresponding +LUN from the sysfs. It might be useful during ALUA state switching. Internally SCST implements EXTENDED COPY as generation of sets of internal READ(16) and WRITE(16) SCSI commands. Dev handlers don't need any manual actions to use it. - Also SCST provides for dev handlers possibility to remap blocks instead of copy them, if they support this feature. It allows them to perform EXTENDED COPY command much faster by just metadata update of their diff --git a/scst/README_in-tree b/scst/README_in-tree index d1bcc9d59..669f97f44 100644 --- a/scst/README_in-tree +++ b/scst/README_in-tree @@ -1712,34 +1712,25 @@ EXTENDED COPY ~~~~~~~~~~~~~ SCST implements EXTENDED COPY via internal Copy Manager target. This -target has the following specific attributes in its sysfs: +target has the following specific attribute in its sysfs: - allow_not_connected_copy - if not set (default), an initiator can perform copy only between devices it has direct access to via any target/session. If set, any initiator can copy between any devices in the system. - - mgmt - this attribute allows to control data from which devices can -be copied using Copy Manager. By default, devices belonging to dev -handlers with flag auto_cm_assignment_possible set are auto assigned to -the Copy Manager on the registration. Currently, only vdisk has this -flag set, so all other devices (pass-through, user space, etc.) should -be assigned to the Copy Manager manually. - -Mgmt attribute supports the following commands: - - - add [vname|H:C:I:L] - adds device with name vname or H:C:I:L numbers -(pass-through) to the Copy Manager. - - - del [vname|H:C:I:L] - deletes device with name vname or H:C:I:L numbers -(pass-through) from the Copy Manager. - +The Copy Manager has access only to those devices, for which it has LUNs +in /sys/kernel/scst_tgt/targets/copy_manager/copy_manager_tgt/luns/. +Devices from scst_vdisk dev handler added to it automatically upon +registration, but for other devices you need to manually add LUNs there +the same way as for any target driver. You can also delete any device at +any time from the Copy Manager visibility by deleting the corresponding +LUN from the sysfs. It might be useful during ALUA state switching. Internally SCST implements EXTENDED COPY as generation of sets of internal READ(16) and WRITE(16) SCSI commands. Dev handlers don't need any manual actions to use it. - Also SCST provides for dev handlers possibility to remap blocks instead of copy them, if they support this feature. It allows them to perform EXTENDED COPY command much faster by just metadata update of their diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index c59233ba8..6fcfbfea7 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -2519,14 +2519,16 @@ static bool scst_cm_is_lun_free(unsigned int lun) } /* scst_mutex supposed to be held and activities suspended */ -static int scst_cm_dev_register(struct scst_device *dev) +static int scst_cm_dev_register(struct scst_device *dev, uint64_t lun) { int res, i; - unsigned int lun; struct scst_acg_dev *acg_dev; + bool add_lun; TRACE_ENTRY(); + TRACE_DBG("dev %s, LUN %ld", dev->virt_name, (unsigned long)lun); + for (i = 0; i < SESS_TGT_DEV_LIST_HASH_SIZE; i++) { struct scst_tgt_dev *tgt_dev; struct list_head *head = &scst_cm_sess->sess_tgt_dev_list[i]; @@ -2541,18 +2543,25 @@ static int scst_cm_dev_register(struct scst_device *dev) } } - while (1) { - lun = scst_cm_next_lun++; - if (lun == SCST_MAX_LUN) - continue; - if (scst_cm_is_lun_free(lun)) - break; - }; + if (lun == SCST_MAX_LUN) { + add_lun = true; + while (1) { + lun = scst_cm_next_lun++; + if (lun == SCST_MAX_LUN) + continue; + if (scst_cm_is_lun_free(lun)) + break; + } + } else + add_lun = false; - res = scst_acg_add_lun(scst_cm_tgt->default_acg, - scst_cm_tgt->tgt_luns_kobj, dev, lun, false, false, &acg_dev); - if (res != 0) - goto out_err; + if (add_lun) { + res = scst_acg_add_lun(scst_cm_tgt->default_acg, + scst_cm_tgt->tgt_luns_kobj, dev, lun, SCST_ADD_LUN_CM, + &acg_dev); + if (res != 0) + goto out_err; + } spin_lock_bh(&dev->dev_lock); scst_block_dev(dev); @@ -2578,13 +2587,15 @@ out_err: } /* scst_mutex supposed to be held and activities suspended */ -static void scst_cm_dev_unregister(struct scst_device *dev) +static void scst_cm_dev_unregister(struct scst_device *dev, bool del_lun) { int i; struct scst_cm_desig *des, *t; TRACE_ENTRY(); + TRACE_DBG("dev %s, del_lun %d", dev->virt_name, del_lun); + list_for_each_entry_safe(des, t, &scst_cm_desig_list, cm_desig_list_entry) { if (des->desig_tgt_dev->dev == dev) { TRACE_DBG("Deleting des %p", des); @@ -2593,6 +2604,9 @@ static void scst_cm_dev_unregister(struct scst_device *dev) } } + if (!del_lun) + goto out; + for (i = 0; i < SESS_TGT_DEV_LIST_HASH_SIZE; i++) { struct scst_tgt_dev *tgt_dev; struct list_head *head = &scst_cm_sess->sess_tgt_dev_list[i]; @@ -2606,6 +2620,7 @@ static void scst_cm_dev_unregister(struct scst_device *dev) } } +out: TRACE_EXIT(); return; } @@ -2620,7 +2635,7 @@ int scst_cm_on_dev_register(struct scst_device *dev) if (!dev->handler->auto_cm_assignment_possible) goto out; - res = scst_cm_dev_register(dev); + res = scst_cm_dev_register(dev, SCST_MAX_LUN); out: TRACE_EXIT_RES(res); @@ -2632,12 +2647,87 @@ void scst_cm_on_dev_unregister(struct scst_device *dev) { TRACE_ENTRY(); - scst_cm_dev_unregister(dev); + scst_cm_dev_unregister(dev, true); TRACE_EXIT(); return; } +/* scst_mutex supposed to be held and activities suspended */ +int scst_cm_on_add_acg(struct scst_acg *acg) +{ + int res = 0; + + TRACE_ENTRY(); + + if (scst_cm_tgt == NULL) + goto out; + + if (acg->tgt != scst_cm_tgt) + goto out; + + if (acg != scst_cm_tgt->default_acg) { + PRINT_ERROR("Copy Manager does not support security groups"); + res = -EINVAL; + goto out; + } + +out: + TRACE_EXIT_RES(res); + return res; +} + +/* scst_mutex supposed to be held and activities suspended */ +void scst_cm_on_del_acg(struct scst_acg *acg) +{ + /* Nothing to do */ +} + +/* scst_mutex supposed to be held and activities suspended */ +int scst_cm_on_add_lun(struct scst_acg_dev *acg_dev, uint64_t lun, + unsigned int *flags) +{ + int res = 0; + + TRACE_ENTRY(); + + if (acg_dev->acg != scst_cm_tgt->default_acg) + goto out; + + if (acg_dev->acg_dev_rd_only || acg_dev->dev->dev_rd_only) { + PRINT_ERROR("Copy Manager does not support read only devices"); + res = -EINVAL; + goto out; + } + + *flags &= ~SCST_ADD_LUN_GEN_UA; + + res = scst_cm_dev_register(acg_dev->dev, lun); + +out: + TRACE_EXIT_RES(res); + return res; +} + +/* scst_mutex supposed to be held and activities suspended */ +bool scst_cm_on_del_lun(struct scst_acg_dev *acg_dev, bool gen_report_luns_changed) +{ + bool res = gen_report_luns_changed; + + TRACE_ENTRY(); + + if (acg_dev->acg != scst_cm_tgt->default_acg) + goto out; + + scst_cm_dev_unregister(acg_dev->dev, false); + + res = false; + +out: + TRACE_EXIT_RES(res); + return res; +} + /* scst_mutex supposed to be locked */ static bool scst_cm_check_access_acg(const char *initiator_name, const struct scst_device *dev, const struct scst_acg *acg, @@ -3480,148 +3570,8 @@ static struct kobj_attribute scst_cm_allow_not_conn_copy_attr = scst_cm_allow_not_conn_copy_show, scst_cm_allow_not_conn_copy_store); -static ssize_t scst_cm_mgmt_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - static const char help[] = - "Usage: echo \"add H:C:I:L\" >mgmt\n" - " echo \"add VNAME\" >mgmt\n" - " echo \"del H:C:I:L\" >mgmt\n" - " echo \"del VNAME\" >mgmt\n"; - - return sprintf(buf, "%s", help); -} - -static int scst_cm_mgmt(struct scst_sysfs_work_item *work) -{ - int res = 0; - char *pp, *action, *devstr; - unsigned int host, channel, id, lun; - char *buf = work->buf; - bool vdev; - struct scst_device *d, *dev = NULL; - - TRACE_ENTRY(); - - TRACE_DBG("buffer %s", buf); - - pp = buf; - action = scst_get_next_lexem(&pp); - devstr = scst_get_next_lexem(&pp); - if (*devstr == '\0') { - PRINT_ERROR("%s", "Device required"); - res = -EINVAL; - goto out; - } - - if (*scst_get_next_lexem(&pp) != '\0') { - PRINT_ERROR("%s", "Too many parameters"); - res = -EINVAL; - goto out_syntax_err; - } - - if (sscanf(devstr, "%u:%u:%u:%u", &host, &channel, &id, &lun) != 4) { - vdev = true; - TRACE_DBG("Virt dev %s", devstr); - } else { - vdev = false; - TRACE_DBG("Pass-through dev %d:%d:%d:%d", host, channel, id, lun); - } - - res = scst_suspend_activity(SCST_SUSPEND_TIMEOUT_USER); - if (res != 0) - goto out; - - res = mutex_lock_interruptible(&scst_mutex); - if (res != 0) - goto out_resume; - - list_for_each_entry(d, &scst_dev_list, dev_list_entry) { - if (vdev) { - if ((d->scsi_dev == NULL) && - (strcmp(d->virt_name, devstr) == 0)) { - dev = d; - break; - } - } else if (d->scsi_dev != NULL && - d->scsi_dev->host->host_no == host && - d->scsi_dev->channel == channel && - d->scsi_dev->id == id && - d->scsi_dev->lun == lun) { - dev = d; - break; - } - } - if (dev == NULL) { - PRINT_ERROR("Device %s not found", devstr); - res = -EINVAL; - goto out_unlock; - } else - TRACE_DBG("Dev %p (%s) found", dev, dev->virt_name); - - if (strcasecmp("add", action) == 0) - res = scst_cm_dev_register(dev); - else if (strcasecmp("del", action) == 0) - scst_cm_dev_unregister(dev); - else { - PRINT_ERROR("Action %s not understood", action); - res = -EINVAL; - } - -out_unlock: - mutex_unlock(&scst_mutex); - -out_resume: - scst_resume_activity(); - -out: - TRACE_EXIT_RES(res); - return res; - -out_syntax_err: - PRINT_ERROR("Syntax error on \"%s\"", buf); - res = -EINVAL; - goto out; -} - -static ssize_t scst_cm_mgmt_store(struct kobject *kobj, - struct kobj_attribute *attr, const char *buffer, size_t size) -{ - int res; - struct scst_sysfs_work_item *work; - char *i_buf; - - TRACE_ENTRY(); - - i_buf = kasprintf(GFP_KERNEL, "%.*s", (int)size, buffer); - if (i_buf == NULL) { - PRINT_ERROR("Unable to alloc intermediate buffer with size %zd", - size+1); - res = -ENOMEM; - goto out; - } - - res = scst_alloc_sysfs_work(scst_cm_mgmt, false, &work); - if (res != 0) - goto out; - - work->buf = i_buf; - - res = scst_sysfs_queue_wait_work(work); - if (res == 0) - res = size; - -out: - TRACE_EXIT_RES(res); - return res; -} - -static struct kobj_attribute scst_cm_mgmt_attr = - __ATTR(mgmt, S_IRUGO|S_IWUSR, scst_cm_mgmt_show, scst_cm_mgmt_store); - -static const struct attribute *scst_cm_attrs[] = { +static const struct attribute *scst_cm_tgtt_attrs[] = { &scst_cm_allow_not_conn_copy_attr.attr, - &scst_cm_mgmt_attr.attr, NULL, }; @@ -3693,6 +3643,12 @@ static void scst_cm_task_mgmt_fn_done(struct scst_mgmt_cmd *scst_mcmd) return; } +static int scst_cm_report_aen(struct scst_aen *aen) +{ + /* Nothing to do */ + return 0; +} + static struct scst_tgt_template scst_cm_tgtt = { .name = SCST_CM_NAME, #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) @@ -3710,9 +3666,10 @@ static struct scst_tgt_template scst_cm_tgtt = { .release = scst_cm_release, .xmit_response = scst_cm_xmit_response, .task_mgmt_fn_done = scst_cm_task_mgmt_fn_done, + .report_aen = scst_cm_report_aen, .get_initiator_port_transport_id = scst_cm_get_initiator_port_transport_id, #ifndef CONFIG_SCST_PROC - .tgtt_attrs = scst_cm_attrs, + .tgtt_attrs = scst_cm_tgtt_attrs, #endif }; diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 8cd269cc7..2a5599948 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4373,8 +4373,8 @@ out: /* The activity supposed to be suspended and scst_mutex held */ int scst_acg_add_lun(struct scst_acg *acg, struct kobject *parent, - struct scst_device *dev, uint64_t lun, int read_only, - bool gen_scst_report_luns_changed, struct scst_acg_dev **out_acg_dev) + struct scst_device *dev, uint64_t lun, unsigned int flags, + struct scst_acg_dev **out_acg_dev) { int res; struct scst_acg_dev *acg_dev; @@ -4395,7 +4395,7 @@ int scst_acg_add_lun(struct scst_acg *acg, struct kobject *parent, res = -ENOMEM; goto out; } - acg_dev->acg_dev_rd_only = read_only; + acg_dev->acg_dev_rd_only = ((flags & SCST_ADD_LUN_READ_ONLY) != 0); if (dev->dev_dif_mode & SCST_DIF_MODE_DEV_STORE) { /* Devices are allowed to store only CRCs */ acg_dev->acg_dev_dif_guard_format = SCST_DIF_GUARD_FORMAT_CRC; @@ -4410,6 +4410,12 @@ int scst_acg_add_lun(struct scst_acg *acg, struct kobject *parent, list_add_tail(&acg_dev->acg_dev_list_entry, &acg->acg_dev_list); list_add_tail(&acg_dev->dev_acg_dev_list_entry, &dev->dev_acg_dev_list); + if (!(flags & SCST_ADD_LUN_CM)) { + res = scst_cm_on_add_lun(acg_dev, lun, &flags); + if (res != 0) + goto out_free; + } + list_for_each_entry(sess, &acg->acg_sess_list, acg_sess_list_entry) { res = scst_alloc_add_tgt_dev(sess, acg_dev, &tgt_dev); if (res == -EPERM) @@ -4423,14 +4429,14 @@ int scst_acg_add_lun(struct scst_acg *acg, struct kobject *parent, res = scst_acg_dev_sysfs_create(acg_dev, parent); if (res != 0) - goto out_free; + goto out_on_del; - if (gen_scst_report_luns_changed) + if (flags & SCST_ADD_LUN_GEN_UA) scst_report_luns_changed(acg); PRINT_INFO("Added device %s to group %s (LUN %lld, " - "rd_only %d) to target %s", dev->virt_name, acg->acg_name, - lun, read_only, acg->tgt ? acg->tgt->tgt_name : "?"); + "flags 0x%x) to target %s", dev->virt_name, acg->acg_name, + lun, flags, acg->tgt ? acg->tgt->tgt_name : "?"); if (out_acg_dev != NULL) *out_acg_dev = acg_dev; @@ -4439,6 +4445,10 @@ out: TRACE_EXIT_RES(res); return res; +out_on_del: + if (!(flags & SCST_ADD_LUN_CM)) + scst_cm_on_del_lun(acg_dev, false); + out_free: list_for_each_entry_safe(tgt_dev, tt, &tmp_tgt_dev_list, extra_tgt_dev_list_entry) { @@ -4450,7 +4460,7 @@ out_free: /* The activity supposed to be suspended and scst_mutex held */ int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, - bool gen_scst_report_luns_changed) + bool gen_report_luns_changed) { int res = 0; struct scst_acg_dev *acg_dev = NULL, *a; @@ -4470,6 +4480,8 @@ int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, goto out; } + gen_report_luns_changed = scst_cm_on_del_lun(acg_dev, gen_report_luns_changed); + list_for_each_entry_safe(tgt_dev, tt, &acg_dev->dev->dev_tgt_dev_list, dev_tgt_dev_list_entry) { if (tgt_dev->acg_dev == acg_dev) @@ -4478,7 +4490,7 @@ int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, scst_del_free_acg_dev(acg_dev, true); - if (gen_scst_report_luns_changed) + if (gen_report_luns_changed) scst_report_luns_changed(acg); PRINT_INFO("Removed LUN %lld from group %s (target %s)", @@ -4490,16 +4502,18 @@ out: } /* The activity supposed to be suspended and scst_mutex held */ -struct scst_acg *scst_alloc_add_acg(struct scst_tgt *tgt, - const char *acg_name, bool tgt_acg) +int scst_alloc_add_acg(struct scst_tgt *tgt, const char *acg_name, + bool tgt_acg, struct scst_acg **out_acg) { struct scst_acg *acg; + int res; TRACE_ENTRY(); acg = kzalloc(sizeof(*acg), GFP_KERNEL); if (acg == NULL) { PRINT_ERROR("%s", "Allocation of acg failed"); + res = -ENOMEM; goto out; } @@ -4512,9 +4526,14 @@ struct scst_acg *scst_alloc_add_acg(struct scst_tgt *tgt, acg->acg_name = kstrdup(acg_name, GFP_KERNEL); if (acg->acg_name == NULL) { PRINT_ERROR("%s", "Allocation of acg_name failed"); + res = -ENOMEM; goto out_free; } + res = scst_cm_on_add_acg(acg); + if (res != 0) + goto out_undup; + #ifdef CONFIG_SCST_PROC acg->addr_method = tgt && tgt->tgtt ? tgt->tgtt->preferred_addr_method : SCST_LUN_ADDR_METHOD_PERIPHERAL; @@ -4527,30 +4546,35 @@ struct scst_acg *scst_alloc_add_acg(struct scst_tgt *tgt, acg->addr_method = tgt->tgtt->preferred_addr_method; if (tgt_acg) { - int rc; - TRACE_DBG("Adding acg '%s' to device '%s' acg_list", acg_name, tgt->tgt_name); list_add_tail(&acg->acg_list_entry, &tgt->tgt_acg_list); acg->tgt_acg = 1; - rc = scst_acg_sysfs_create(tgt, acg); - if (rc != 0) + res = scst_acg_sysfs_create(tgt, acg); + if (res != 0) goto out_del; } kobject_get(&tgt->tgt_kobj); #endif + res = 0; + out: - TRACE_EXIT_HRES(acg); - return acg; + *out_acg = acg; + + TRACE_EXIT_RES(res); + return res; #ifndef CONFIG_SCST_PROC out_del: list_del(&acg->acg_list_entry); #endif +out_undup: + kfree(acg->acg_name); + out_free: kfree(acg); acg = NULL; @@ -4573,6 +4597,8 @@ static void scst_del_acg(struct scst_acg *acg) scst_assert_activity_suspended(); lockdep_assert_held(&scst_mutex); + scst_cm_on_del_acg(acg); + list_for_each_entry_safe(acg_dev, acg_dev_tmp, &acg->acg_dev_list, acg_dev_list_entry) scst_del_acg_dev(acg_dev, true); diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 4bfde9df1..b5b3851e9 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -550,8 +550,8 @@ struct scst_tgt *scst_register_target(struct scst_tgt_template *vtt, if (rc < 0) goto out_unlock; - tgt->default_acg = scst_alloc_add_acg(tgt, tgt->tgt_name, false); - if (tgt->default_acg == NULL) + rc = scst_alloc_add_acg(tgt, tgt->tgt_name, false, &tgt->default_acg); + if (rc != 0) goto out_sysfs_del; #endif @@ -2650,11 +2650,9 @@ static int __init init_scst(void) goto out_sysfs_cleanup; #ifdef CONFIG_SCST_PROC - scst_default_acg = scst_alloc_add_acg(NULL, SCST_DEFAULT_ACG_NAME, false); - if (scst_default_acg == NULL) { - res = -ENOMEM; + res = scst_alloc_add_acg(NULL, SCST_DEFAULT_ACG_NAME, false, &scst_default_acg); + if (res != 0) goto out_destroy_sgv_pool; - } #endif res = scsi_register_interface(&scst_interface); diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 6740845c6..ae1157d36 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -347,8 +347,8 @@ int scst_alloc_device(gfp_t gfp_mask, struct scst_device **out_dev); void scst_free_device(struct scst_device *dev); bool scst_device_is_exported(struct scst_device *dev); -struct scst_acg *scst_alloc_add_acg(struct scst_tgt *tgt, - const char *acg_name, bool tgt_acg); +int scst_alloc_add_acg(struct scst_tgt *tgt, const char *acg_name, + bool tgt_acg, struct scst_acg **out_acg); int scst_del_free_acg(struct scst_acg *acg, bool close_sessions); void scst_get_acg(struct scst_acg *acg); void scst_put_acg(struct scst_acg *acg); @@ -363,11 +363,14 @@ void scst_sess_free_tgt_devs(struct scst_session *sess); struct scst_tgt_dev *scst_lookup_tgt_dev(struct scst_session *sess, u64 lun); void scst_nexus_loss(struct scst_tgt_dev *tgt_dev, bool queue_UA); +#define SCST_ADD_LUN_READ_ONLY 1 +#define SCST_ADD_LUN_GEN_UA 2 +#define SCST_ADD_LUN_CM 4 int scst_acg_add_lun(struct scst_acg *acg, struct kobject *parent, - struct scst_device *dev, uint64_t lun, int read_only, - bool gen_scst_report_luns_changed, struct scst_acg_dev **out_acg_dev); + struct scst_device *dev, uint64_t lun, unsigned int flags, + struct scst_acg_dev **out_acg_dev); int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, - bool gen_scst_report_luns_changed); + bool gen_report_luns_changed); int scst_acg_add_acn(struct scst_acg *acg, const char *name); #ifdef CONFIG_SCST_PROC @@ -857,6 +860,13 @@ static inline bool scst_lba1_inside_lba2(int64_t lba1, int scst_cm_on_dev_register(struct scst_device *dev); void scst_cm_on_dev_unregister(struct scst_device *dev); +int scst_cm_on_add_acg(struct scst_acg *acg); +void scst_cm_on_del_acg(struct scst_acg *acg); +int scst_cm_on_add_lun(struct scst_acg_dev *acg_dev, uint64_t lun, + unsigned int *flags); +bool scst_cm_on_del_lun(struct scst_acg_dev *acg_dev, + bool gen_report_luns_changed); + int scst_cm_parse_descriptors(struct scst_cmd *cmd); void scst_cm_free_descriptors(struct scst_cmd *cmd); diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index 1d4dc3c25..26b99c3fe 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -948,8 +948,8 @@ static int scst_proc_group_add(const char *p, unsigned int addr_method) } strlcpy(name, p, len); - acg = scst_alloc_add_acg(NULL, name, false); - if (acg == NULL) { + res = scst_alloc_add_acg(NULL, name, false, &acg); + if (res != 0) { PRINT_ERROR("scst_alloc_add_acg() (name %s) failed", name); goto out_free; } @@ -969,6 +969,7 @@ out_free_acg: out_free: kfree(name); + goto out; out_nomem: res = -ENOMEM; @@ -2069,7 +2070,8 @@ static ssize_t scst_proc_groups_devices_write(struct file *file, } } - rc = scst_acg_add_lun(acg, NULL, dev, virt_lun, read_only, + rc = scst_acg_add_lun(acg, NULL, dev, virt_lun, + read_only ? SCST_ADD_LUN_READ_ONLY : 0, false, NULL); if (rc) { res = rc; diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 62497ecdc..cc939175e 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1327,6 +1327,7 @@ static int __scst_process_luns_mgmt_store(char *buffer, case SCST_LUN_ACTION_REPLACE: { bool dev_replaced = false; + unsigned int flags = 0; e = scst_get_next_lexem(&pp); res = kstrtoul(e, 0, &virt_lun); @@ -1414,9 +1415,13 @@ static int __scst_process_luns_mgmt_store(char *buffer, } } + if (read_only) + flags |= SCST_ADD_LUN_READ_ONLY; + if (!dev_replaced) + flags |= SCST_ADD_LUN_GEN_UA; res = scst_acg_add_lun(acg, tgt_kobj ? tgt->tgt_luns_kobj : acg->luns_kobj, - dev, virt_lun, read_only, !dev_replaced, NULL); + dev, virt_lun, flags, NULL); if (res != 0) goto out_unlock; @@ -2174,8 +2179,8 @@ static int scst_process_ini_group_mgmt_store(char *buffer, res = -EINVAL; goto out_unlock; } - acg = scst_alloc_add_acg(tgt, p, true); - if (acg == NULL) + res = scst_alloc_add_acg(tgt, p, true, &acg); + if (res != 0) goto out_unlock; break; case SCST_INI_GROUP_ACTION_DEL: From 96bdede086c3cfd2bca0ba0f98e728de01928e92 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 18 Nov 2015 19:36:01 +0000 Subject: [PATCH 003/121] scst: Make it easier to build without DLM support With this change all that is required to build without DLM support is to add the following in scst_priv.h: #undef CONFIG_DLM #undef CONFIG_DLM_MODULE git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6695 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/Makefile | 5 ----- scst/src/scst_dlm.c | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scst/src/Makefile b/scst/src/Makefile index 51d83b986..ee1501fd0 100644 --- a/scst/src/Makefile +++ b/scst/src/Makefile @@ -49,12 +49,7 @@ scst-y += scst_mem.o scst-y += scst_debug.o scst-y += scst_pres.o scst-y += scst_no_dlm.o -ifdef CONFIG_DLM scst-y += scst_dlm.o -endif -ifdef CONFIG_DLM_MODULE -scst-y += scst_dlm.o -endif scst-y += scst_tg.o scst-y += scst_event.o scst-y += scst_copy_mgr.o diff --git a/scst/src/scst_dlm.c b/scst/src/scst_dlm.c index 0aa1372ea..8e9bdc4f5 100644 --- a/scst/src/scst_dlm.c +++ b/scst/src/scst_dlm.c @@ -30,6 +30,8 @@ #include "scst_pres.h" #include "scst_dlm.h" +#if defined(CONFIG_DLM) || defined(CONFIG_DLM_MODULE) + static void scst_pr_dlm_cleanup(struct scst_device *dev); static void scst_dlm_pre_bast(void *bastarg, int mode); static void scst_dlm_post_bast(void *bastarg, int mode); @@ -1493,3 +1495,5 @@ const struct scst_cl_ops scst_dlm_cl_ops = { .is_not_rsv_holder = scst_dlm_is_not_rsv_holder, .reserve = scst_dlm_reserve, }; + +#endif From 1c349edbc0a742ecc5bca618be93573c99ff75de Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 18 Nov 2015 22:10:03 +0000 Subject: [PATCH 004/121] scst_pres: Suppress a compiler warning when building against a kernel with no DLM support git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6696 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_pres.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 8ce467d6e..63e9b3f7a 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -1192,11 +1192,12 @@ int scst_pr_set_cluster_mode(struct scst_device *dev, bool cluster_mode, dev->virt_name, cluster_mode, res); dev->cl_ops = &scst_no_dlm_cl_ops; } + +out: #else res = cluster_mode ? -ENOTSUPP : 0; #endif -out: return res; } EXPORT_SYMBOL(scst_pr_set_cluster_mode); From 337fe08a72bcc98e3c7924b688dfb2792a9f3521 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 18 Nov 2015 22:10:33 +0000 Subject: [PATCH 005/121] scst_vdisk: Kernel v4.4 build fix git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6697 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index b53a2b312..cb428fe52 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1407,6 +1407,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev) struct inode *inode; struct file *fd; struct blk_integrity *bi; + const char *bi_profile_name; TRACE_ENTRY(); @@ -1430,9 +1431,14 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev) goto out_no_bi; } - TRACE_DBG("BI name %s", bi->name); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) + bi_profile_name = bi->name; +#else + bi_profile_name = bi->profile->name; +#endif + TRACE_DBG("BI name %s", bi_profile_name); - if (!strcmp(bi->name, "T10-DIF-TYPE1-CRC")) { + if (!strcmp(bi_profile_name, "T10-DIF-TYPE1-CRC")) { dev->dev_dif_ip_not_supported = 1; if (virt_dev->dif_type != 1) { PRINT_ERROR("Integrity type mismatch, %d expected, " @@ -1441,7 +1447,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev) res = -EINVAL; goto out_close; } - } else if (!strcmp(bi->name, "T10-DIF-TYPE1-IP")) { + } else if (!strcmp(bi_profile_name, "T10-DIF-TYPE1-IP")) { if (virt_dev->dif_type != 1) { PRINT_ERROR("Integrity type mismatch, %d expected, " "but block device has 1 (dev %s)", @@ -1449,7 +1455,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev) res = -EINVAL; goto out_close; } - } else if (!strcmp(bi->name, "T10-DIF-TYPE3-CRC")) { + } else if (!strcmp(bi_profile_name, "T10-DIF-TYPE3-CRC")) { dev->dev_dif_ip_not_supported = 1; if (virt_dev->dif_type != 3) { PRINT_ERROR("Integrity type mismatch, %d expected, " @@ -1458,7 +1464,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev) res = -EINVAL; goto out_close; } - } else if (!strcmp(bi->name, "T10-DIF-TYPE3-IP")) { + } else if (!strcmp(bi_profile_name, "T10-DIF-TYPE3-IP")) { if (virt_dev->dif_type != 3) { PRINT_ERROR("Integrity type mismatch, %d expected, " "but block device has 3 (dev %s)", @@ -1468,7 +1474,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev) } } else { PRINT_ERROR("Unable to understand integrity name %s" - "(dev %s)", bi->name, dev->virt_name); + "(dev %s)", bi_profile_name, dev->virt_name); res = -EINVAL; goto out_close; } From 098f6bd1c5da8f19397be2263956a3cc796afc7d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 18 Nov 2015 22:10:54 +0000 Subject: [PATCH 006/121] ib_srpt: Kernel v4.4 build fix git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6698 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 64 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 8a8e09389..6015f29fa 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -3356,7 +3356,11 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, struct srpt_send_ioctx *ioctx, scst_data_direction dir) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) struct ib_send_wr wr; +#else + struct ib_rdma_wr wr; +#endif struct ib_send_wr *bad_wr; struct rdma_iu *riu; int i; @@ -3377,6 +3381,7 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, memset(&wr, 0, sizeof(wr)); for (i = 0; i < n_rdma; ++i, ++riu) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) if (dir == SCST_DATA_READ) { wr.opcode = IB_WR_RDMA_WRITE; wr.wr_id = encode_wr_id(i == n_rdma - 1 ? @@ -3401,6 +3406,32 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, wr.send_flags = IB_SEND_SIGNALED; ret = ib_post_send(ch->qp, &wr, &bad_wr); +#else + if (dir == SCST_DATA_READ) { + wr.wr.opcode = IB_WR_RDMA_WRITE; + wr.wr.wr_id = encode_wr_id(i == n_rdma - 1 ? + SRPT_RDMA_WRITE_LAST : + SRPT_RDMA_MID, + ioctx->ioctx.index); + } else { + wr.wr.opcode = IB_WR_RDMA_READ; + wr.wr.wr_id = encode_wr_id(i == n_rdma - 1 ? + SRPT_RDMA_READ_LAST : + SRPT_RDMA_MID, + ioctx->ioctx.index); + } + wr.wr.next = NULL; + wr.remote_addr = riu->raddr; + wr.rkey = riu->rkey; + wr.wr.num_sge = riu->sge_cnt; + wr.wr.sg_list = riu->sge; + + /* only get completion event for the last rdma wr */ + if (i == (n_rdma - 1) && dir == SCST_DATA_WRITE) + wr.wr.send_flags = IB_SEND_SIGNALED; + + ret = ib_post_send(ch->qp, &wr.wr, &bad_wr); +#endif if (ret) break; } @@ -3409,6 +3440,7 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, pr_err("%s: ib_post_send() returned %d for %d/%d\n", __func__, ret, i, n_rdma); if (ret && i > 0) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) wr.num_sge = 0; wr.wr_id = encode_wr_id(SRPT_RDMA_ABORT, ioctx->ioctx.index); wr.send_flags = IB_SEND_SIGNALED; @@ -3420,13 +3452,34 @@ static int srpt_perform_rdmas(struct srpt_rdma_ch *ch, ioctx->ioctx.index); msleep(1000); } +#else + wr.wr.num_sge = 0; + wr.wr.wr_id = encode_wr_id(SRPT_RDMA_ABORT, ioctx->ioctx.index); + wr.wr.send_flags = IB_SEND_SIGNALED; + pr_info("Trying to abort failed RDMA transfer [%d]\n", + ioctx->ioctx.index); + while (ch->state == CH_LIVE && + ib_post_send(ch->qp, &wr.wr, &bad_wr) != 0) { + pr_info("Trying to abort failed RDMA transfer [%d]\n", + ioctx->ioctx.index); + msleep(1000); + } +#endif pr_info("Waiting until RDMA abort finished [%d]\n", ioctx->ioctx.index); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) while (ch->state < CH_DISCONNECTED && !ioctx->rdma_aborted) { pr_info("Waiting until RDMA abort finished [%d]\n", ioctx->ioctx.index); msleep(1000); } +#else + while (ch->state < CH_DISCONNECTED && !ioctx->rdma_aborted) { + pr_info("Waiting until RDMA abort finished [%d]\n", + ioctx->ioctx.index); + msleep(1000); + } +#endif pr_info("%s[%d]: done\n", __func__, __LINE__); } @@ -4480,13 +4533,16 @@ static int __init srpt_init_module(void) if (rdma_cm_port) { struct sockaddr_in addr; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) || \ - defined(RHEL_MAJOR) && RHEL_MAJOR -0 >= 6 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) && \ + (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 6) + rdma_cm_id = rdma_create_id(srpt_rdma_cm_handler, NULL, + RDMA_PS_TCP); +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) rdma_cm_id = rdma_create_id(srpt_rdma_cm_handler, NULL, RDMA_PS_TCP, IB_QPT_RC); #else - rdma_cm_id = rdma_create_id(srpt_rdma_cm_handler, NULL, - RDMA_PS_TCP); + rdma_cm_id = rdma_create_id(&init_net, srpt_rdma_cm_handler, + NULL, RDMA_PS_TCP, IB_QPT_RC); #endif if (IS_ERR(rdma_cm_id)) { rdma_cm_id = NULL; From 87347442fdca8b599f2a69fa9f9219a0edea985c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 18 Nov 2015 22:11:37 +0000 Subject: [PATCH 007/121] isert-scst: Port to Linux kernel v4.4 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6699 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/isert-scst/iser.h | 4 +++ iscsi-scst/kernel/isert-scst/iser_buf.c | 19 +++++++++++++++ iscsi-scst/kernel/isert-scst/iser_pdu.c | 23 ++++++++++++++++++ iscsi-scst/kernel/isert-scst/iser_rdma.c | 31 +++++++++++++++++++++--- 4 files changed, 73 insertions(+), 4 deletions(-) diff --git a/iscsi-scst/kernel/isert-scst/iser.h b/iscsi-scst/kernel/isert-scst/iser.h index 90fa056a2..eeb8040fc 100644 --- a/iscsi-scst/kernel/isert-scst/iser.h +++ b/iscsi-scst/kernel/isert-scst/iser.h @@ -98,7 +98,11 @@ struct isert_wr { struct ib_sge *sge_list; union { struct ib_recv_wr recv_wr; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) struct ib_send_wr send_wr; +#else + struct ib_rdma_wr send_wr; +#endif }; } ____cacheline_aligned; diff --git a/iscsi-scst/kernel/isert-scst/iser_buf.c b/iscsi-scst/kernel/isert-scst/iser_buf.c index daa78c72a..7bd34c9a2 100644 --- a/iscsi-scst/kernel/isert-scst/iser_buf.c +++ b/iscsi-scst/kernel/isert-scst/iser_buf.c @@ -238,9 +238,14 @@ int isert_wr_init(struct isert_wr *wr, buff_offset = -EFAULT; goto out; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) wr->send_wr.wr.rdma.remote_addr = pdu->rem_write_va + buff_offset; wr->send_wr.wr.rdma.rkey = pdu->rem_write_stag; +#else + wr->send_wr.remote_addr = pdu->rem_write_va + buff_offset; + wr->send_wr.rkey = pdu->rem_write_stag; +#endif break; case ISER_WR_RDMA_WRITE: send_wr_op = IB_WR_RDMA_WRITE; @@ -250,9 +255,14 @@ int isert_wr_init(struct isert_wr *wr, buff_offset = -EFAULT; goto out; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) wr->send_wr.wr.rdma.remote_addr = pdu->rem_read_va + buff_offset; wr->send_wr.wr.rdma.rkey = pdu->rem_read_stag; +#else + wr->send_wr.remote_addr = pdu->rem_read_va + buff_offset; + wr->send_wr.rkey = pdu->rem_read_stag; +#endif break; default: BUG(); @@ -278,12 +288,21 @@ int isert_wr_init(struct isert_wr *wr, wr->recv_wr.sg_list = wr->sge_list; wr->recv_wr.num_sge = sg_cnt; } else { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) wr->send_wr.next = NULL; wr->send_wr.wr_id = _ptr_to_u64(wr); wr->send_wr.sg_list = wr->sge_list; wr->send_wr.num_sge = sg_cnt; wr->send_wr.opcode = send_wr_op; wr->send_wr.send_flags = send_flags; +#else + wr->send_wr.wr.next = NULL; + wr->send_wr.wr.wr_id = _ptr_to_u64(wr); + wr->send_wr.wr.sg_list = wr->sge_list; + wr->send_wr.wr.num_sge = sg_cnt; + wr->send_wr.wr.opcode = send_wr_op; + wr->send_wr.wr.send_flags = send_flags; +#endif } out: diff --git a/iscsi-scst/kernel/isert-scst/iser_pdu.c b/iscsi-scst/kernel/isert-scst/iser_pdu.c index 0c6e81b32..cf30db258 100644 --- a/iscsi-scst/kernel/isert-scst/iser_pdu.c +++ b/iscsi-scst/kernel/isert-scst/iser_pdu.c @@ -214,7 +214,11 @@ out: static inline void isert_link_send_wrs(struct isert_wr *from_wr, struct isert_wr *to_wr) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) from_wr->send_wr.next = &to_wr->send_wr; +#else + from_wr->send_wr.wr.next = &to_wr->send_wr.wr; +#endif } static inline void isert_link_send_pdu_wrs(struct isert_cmnd *from_pdu, @@ -222,7 +226,11 @@ static inline void isert_link_send_pdu_wrs(struct isert_cmnd *from_pdu, int wr_cnt) { isert_link_send_wrs(&from_pdu->wr[wr_cnt - 1], &to_pdu->wr[0]); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) to_pdu->wr[0].send_wr.next = NULL; +#else + to_pdu->wr[0].send_wr.wr.next = NULL; +#endif } int isert_prepare_rdma(struct isert_cmnd *isert_pdu, @@ -281,8 +289,14 @@ int isert_prepare_rdma(struct isert_cmnd *isert_pdu, isert_link_send_wrs(&isert_pdu->wr[i - 1], &isert_pdu->wr[i]); if (op == ISER_WR_RDMA_READ) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) isert_pdu->wr[wr_cnt - 1].send_wr.send_flags = IB_SEND_SIGNALED; isert_pdu->wr[wr_cnt - 1].send_wr.next = NULL; +#else + isert_pdu->wr[wr_cnt - 1].send_wr.wr.send_flags = + IB_SEND_SIGNALED; + isert_pdu->wr[wr_cnt - 1].send_wr.wr.next = NULL; +#endif } out: @@ -574,7 +588,11 @@ int isert_pdu_send(struct isert_connection *isert_conn, #endif wr = &tx_pdu->wr[0]; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) wr->send_wr.num_sge = isert_pdu_prepare_send(isert_conn, tx_pdu); +#else + wr->send_wr.wr.num_sge = isert_pdu_prepare_send(isert_conn, tx_pdu); +#endif err = isert_post_send(isert_conn, wr, 1); if (unlikely(err)) { @@ -595,8 +613,13 @@ int isert_pdu_post_rdma_write(struct isert_connection *isert_conn, TRACE_ENTRY(); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) isert_rsp->wr[0].send_wr.num_sge = isert_pdu_prepare_send(isert_conn, isert_rsp); +#else + isert_rsp->wr[0].send_wr.wr.num_sge = isert_pdu_prepare_send(isert_conn, + isert_rsp); +#endif isert_link_send_pdu_wrs(isert_cmd, isert_rsp, wr_cnt); err = isert_post_send(isert_conn, &isert_cmd->wr[0], wr_cnt + 1); if (unlikely(err)) { diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index 8fd02ab4a..08050a221 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -103,7 +103,11 @@ int isert_post_send(struct isert_connection *isert_conn, struct isert_wr *first_wr, int num_wr) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) struct ib_send_wr *first_ib_wr = &first_wr->send_wr; +#else + struct ib_send_wr *first_ib_wr = &first_wr->send_wr.wr; +#endif struct ib_send_wr *bad_wr; int num_posted; int err; @@ -131,9 +135,19 @@ void isert_post_drain(struct isert_connection *isert_conn) isert_wr_set_fields(&isert_conn->drain_wr, isert_conn, NULL); isert_conn->drain_wr.wr_op = ISER_WR_SEND; - isert_conn->drain_wr.send_wr.wr_id = _ptr_to_u64(&isert_conn->drain_wr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) + isert_conn->drain_wr.send_wr.wr_id = + _ptr_to_u64(&isert_conn->drain_wr); isert_conn->drain_wr.send_wr.opcode = IB_WR_SEND; - err = ib_post_send(isert_conn->qp, &isert_conn->drain_wr.send_wr, &bad_wr); + err = ib_post_send(isert_conn->qp, + &isert_conn->drain_wr.send_wr, &bad_wr); +#else + isert_conn->drain_wr.send_wr.wr.wr_id = + _ptr_to_u64(&isert_conn->drain_wr); + isert_conn->drain_wr.send_wr.wr.opcode = IB_WR_SEND; + err = ib_post_send(isert_conn->qp, + &isert_conn->drain_wr.send_wr.wr, &bad_wr); +#endif if (unlikely(err)) { pr_err("Failed to post drain wr, err:%d\n", err); /* @@ -601,6 +615,7 @@ static void isert_handle_wc_error(struct ib_wc *wc) struct isert_buf *isert_buf = wr->buf; struct isert_device *isert_dev = wr->isert_dev; struct ib_device *ib_dev = isert_dev->ib_dev; + u32 num_sge; TRACE_ENTRY(); @@ -615,7 +630,12 @@ static void isert_handle_wc_error(struct ib_wc *wc) switch (wr->wr_op) { case ISER_WR_SEND: - if (unlikely(wr->send_wr.num_sge == 0)) /* Drain WR */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) + num_sge = wr->send_wr.num_sge; +#else + num_sge = wr->send_wr.wr.num_sge; +#endif + if (unlikely(num_sge == 0)) /* Drain WR */ isert_sched_conn_drained(isert_conn); else isert_pdu_err(&isert_pdu->iscsi); @@ -1648,9 +1668,12 @@ struct isert_portal *isert_portal_create(void) #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) && \ (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 <= 5) cm_id = rdma_create_id(isert_cm_evt_handler, portal, RDMA_PS_TCP); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) cm_id = rdma_create_id(isert_cm_evt_handler, portal, RDMA_PS_TCP, IB_QPT_RC); +#else + cm_id = rdma_create_id(&init_net, isert_cm_evt_handler, portal, + RDMA_PS_TCP, IB_QPT_RC); #endif if (unlikely(IS_ERR(cm_id))) { err = PTR_ERR(cm_id); From 032f4fd73305260c179a222d571d4a35a580f0f5 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 18 Nov 2015 22:44:29 +0000 Subject: [PATCH 008/121] scst: Do not build cluster PR support if CONFIG_SCST_NO_DLM has been set git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6700 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/Makefile | 3 ++- scst/src/scst_dlm.c | 3 ++- scst/src/scst_pres.c | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scst/src/Makefile b/scst/src/Makefile index ee1501fd0..7e1209cc9 100644 --- a/scst/src/Makefile +++ b/scst/src/Makefile @@ -155,7 +155,8 @@ INSTALL_DIR_H := $(DESTDIR)$(PREFIX)/include/scst enable-Wextra = $(shell uname_r="$$(uname -r)"; if [ "$${uname_r%.el5}" = "$${uname_r}" ]; then echo "$(1)"; fi) EXTRA_CFLAGS += -I$(SCST_INC_DIR) $(call enable-Wextra,-Wextra \ - -Wno-unused-parameter -Wno-missing-field-initializers) + -Wno-unused-parameter -Wno-missing-field-initializers) \ + $(shell [ -n "${CONFIG_SCST_NO_DLM}" ] && echo -DCONFIG_SCST_NO_DLM) #EXTRA_CFLAGS += -DCONFIG_SCST_STRICT_SERIALIZING diff --git a/scst/src/scst_dlm.c b/scst/src/scst_dlm.c index 8e9bdc4f5..342941d96 100644 --- a/scst/src/scst_dlm.c +++ b/scst/src/scst_dlm.c @@ -30,7 +30,8 @@ #include "scst_pres.h" #include "scst_dlm.h" -#if defined(CONFIG_DLM) || defined(CONFIG_DLM_MODULE) +#if (defined(CONFIG_DLM) || defined(CONFIG_DLM_MODULE)) && \ + !defined(CONFIG_SCST_NO_DLM) static void scst_pr_dlm_cleanup(struct scst_device *dev); static void scst_dlm_pre_bast(void *bastarg, int mode); diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 63e9b3f7a..dff5620e1 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -1173,10 +1173,12 @@ void scst_pr_cleanup(struct scst_device *dev) int scst_pr_set_cluster_mode(struct scst_device *dev, bool cluster_mode, const char *cl_dev_id) { - bool cluster_mode_enabled = false; int res = 0; -#if defined(CONFIG_DLM) || defined(CONFIG_DLM_MODULE) +#if defined(CONFIG_DLM) || defined(CONFIG_DLM_MODULE) && \ + !defined(CONFIG_SCST_NO_DLM) + bool cluster_mode_enabled = false; + cluster_mode_enabled = dev->cl_ops == &scst_dlm_cl_ops; if (cluster_mode_enabled == cluster_mode) From f5d73fa9ed4b9e785095128b7ad90443f03b1742 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 19 Nov 2015 05:20:43 +0000 Subject: [PATCH 009/121] scst: fix explicit ALUA disabled DIF type 2 handling git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6701 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index cb428fe52..8a471ce1f 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -2796,6 +2796,7 @@ static const struct scst_opcode_descriptor *vdisk_opcode_descriptors_type2[] = { &scst_op_descr_write_verify32, &scst_op_descr_write_same32, SCST_OPCODE_DESCRIPTORS + &scst_op_descr_stpg, /* must be last, see vdisk_get_supported_opcodes()! */ }; static const struct scst_opcode_descriptor *vcdrom_opcode_descriptors[] = { From c2283e427155f1255cf771d52f6a497b7076f11f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 19 Nov 2015 16:53:18 +0000 Subject: [PATCH 010/121] scst_sysfs: Introduce scst_parse_add_repl_param() This makes the __scst_process_luns_mgmt_store() source code slightly easier to read. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6703 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_sysfs.c | 142 ++++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 60 deletions(-) diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index cc939175e..11f0f2663 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1253,11 +1253,88 @@ static void scst_tgt_release(struct kobject *kobj) return; } +static int scst_parse_add_repl_param(struct scst_acg *acg, + struct scst_device *dev, char *pp, + unsigned long *virt_lun, + bool *read_only) +{ + int res; + char *e; + + *read_only = false; + e = scst_get_next_lexem(&pp); + res = kstrtoul(e, 0, virt_lun); + if (res != 0) { + PRINT_ERROR("Valid LUN required for dev %s (res %d)", + dev->virt_name, res); + goto out; + } else if (*virt_lun > SCST_MAX_LUN) { + PRINT_ERROR("Too big LUN %ld (max %d)", *virt_lun, SCST_MAX_LUN); + res = -EINVAL; + goto out; + } + + while (1) { + unsigned long val; + char *param = scst_get_next_token_str(&pp); + char *p, *pp; + + if (param == NULL) + break; + + p = scst_get_next_lexem(¶m); + if (*p == '\0') { + PRINT_ERROR("Syntax error at %s (device %s)", param, + dev->virt_name); + res = -EINVAL; + goto out; + } + + pp = scst_get_next_lexem(¶m); + if (*pp == '\0') { + PRINT_ERROR("Parameter %s value missed for device %s", + p, dev->virt_name); + res = -EINVAL; + goto out; + } + + if (scst_get_next_lexem(¶m)[0] != '\0') { + PRINT_ERROR("Too many parameter %s values (device %s)", + p, dev->virt_name); + res = -EINVAL; + goto out; + } + + res = kstrtoul(pp, 0, &val); + if (res != 0) { + PRINT_ERROR("kstrtoul() for %s failed: %d " + "(device %s)", pp, res, dev->virt_name); + goto out; + } + + if (strcasecmp("read_only", p) == 0) { + *read_only = !!val; + TRACE_DBG("READ ONLY %d", *read_only); + } else { + PRINT_ERROR("Unknown parameter %s (device %s)", p, + dev->virt_name); + res = -EINVAL; + goto out; + } + } + + res = 0; + +out: + return res; +} + static int __scst_process_luns_mgmt_store(char *buffer, struct scst_tgt *tgt, struct scst_acg *acg, bool tgt_kobj) { - int res, read_only = 0, action; - char *p, *pp, *e; + int res, action; + bool read_only; + char *p, *pp; unsigned long virt_lun; struct scst_acg_dev *acg_dev = NULL, *acg_dev_tmp; struct scst_device *d, *dev = NULL; @@ -1329,65 +1406,10 @@ static int __scst_process_luns_mgmt_store(char *buffer, bool dev_replaced = false; unsigned int flags = 0; - e = scst_get_next_lexem(&pp); - res = kstrtoul(e, 0, &virt_lun); - if (res != 0) { - PRINT_ERROR("Valid LUN required for dev %s (res %d)", p, res); + res = scst_parse_add_repl_param(acg, dev, pp, &virt_lun, + &read_only); + if (res != 0) goto out_unlock; - } else if (virt_lun > SCST_MAX_LUN) { - PRINT_ERROR("Too big LUN %ld (max %d)", virt_lun, SCST_MAX_LUN); - res = -EINVAL; - goto out_unlock; - } - - while (1) { - unsigned long val; - char *param = scst_get_next_token_str(&pp); - char *pp; - - if (param == NULL) - break; - - p = scst_get_next_lexem(¶m); - if (*p == '\0') { - PRINT_ERROR("Syntax error at %s (device %s)", - param, dev->virt_name); - res = -EINVAL; - goto out_unlock; - } - - pp = scst_get_next_lexem(¶m); - if (*pp == '\0') { - PRINT_ERROR("Parameter %s value missed for device %s", - p, dev->virt_name); - res = -EINVAL; - goto out_unlock; - } - - if (scst_get_next_lexem(¶m)[0] != '\0') { - PRINT_ERROR("Too many parameter's %s values (device %s)", - p, dev->virt_name); - res = -EINVAL; - goto out_unlock; - } - - res = kstrtoul(pp, 0, &val); - if (res != 0) { - PRINT_ERROR("kstrtoul() for %s failed: %d " - "(device %s)", pp, res, dev->virt_name); - goto out_unlock; - } - - if (!strcasecmp("read_only", p)) { - read_only = val; - TRACE_DBG("READ ONLY %d", read_only); - } else { - PRINT_ERROR("Unknown parameter %s (device %s)", - p, dev->virt_name); - res = -EINVAL; - goto out_unlock; - } - } acg_dev = NULL; list_for_each_entry(acg_dev_tmp, &acg->acg_dev_list, From a2d86af17f886980dab2f5bbe2dd22d1cfde3272 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 19 Nov 2015 17:30:24 +0000 Subject: [PATCH 011/121] scripts/run-regression-tests: Also test no-DLM build git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6704 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/run-regression-tests | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/run-regression-tests b/scripts/run-regression-tests index 745e3d19d..031e73117 100755 --- a/scripts/run-regression-tests +++ b/scripts/run-regression-tests @@ -141,6 +141,26 @@ function compile_scst_unpatched { ) } +# Compile the unpatched SCST source code without DLM. +function compile_scst_no_dlm { + local scst="$PWD" + local outputfile="${outputdir}/compilation-output-no-dlm.txt" + local workingdirectory="${outputdir}/scst-no-dlm" + + echo "Testing whether the SCST tree compiles fine without DLM support ..." + ( + if mkdir -p "${workingdirectory}" \ + && cd "${workingdirectory}" \ + && duplicate_scst_source_tree "${scst}" \ + && CONFIG_SCST_NO_DLM=y compile_scst &> "${outputfile}" + then + echo "OK" + else + echo "FAILED" + fi + ) +} + # Test out-of-tree compilation agains the kernel header files in # /lib/modules/$(uname -r)/build. function compile_scst_patched { @@ -558,6 +578,7 @@ fi test_scst_tree_patches || exit $? if [ "${run_local_compilation}" = "true" ]; then compile_scst_unpatched || exit $? + compile_scst_no_dlm || exit $? compile_scst_patched 2release || exit $? compile_scst_patched 2perf || exit $? compile_scst_patched enable_proc || exit $? From c07e1ef0efafa0df0084653b22319c8be7f45596 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 19 Nov 2015 17:31:02 +0000 Subject: [PATCH 012/121] scst: Fix procfs build git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6705 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 2 ++ scst/src/dev_handlers/scst_user.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index a88f6cce1..34314dc78 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -5675,8 +5675,10 @@ struct scst_ext_copy_seg_descr { int tgt_descr_offs; }; +#ifndef CONFIG_SCST_PROC void scst_ext_copy_remap_done(struct scst_cmd *ec_cmd, struct scst_ext_copy_data_descr *dds, int dds_cnt); int scst_ext_copy_get_cur_seg_data_len(struct scst_cmd *ec_cmd); +#endif #endif /* __SCST_H */ diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index caf33d27c..a319a9382 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -955,6 +955,7 @@ static int dev_user_exec(struct scst_cmd *cmd) return res; } +#ifndef CONFIG_SCST_PROC static void dev_user_ext_copy_remap(struct scst_cmd *cmd, struct scst_ext_copy_seg_descr *seg) { @@ -985,6 +986,7 @@ static void dev_user_ext_copy_remap(struct scst_cmd *cmd, TRACE_EXIT(); return; } +#endif static void dev_user_free_sgv(struct scst_user_cmd *ucmd) { @@ -1485,6 +1487,7 @@ static int dev_user_process_reply_on_cache_free(struct scst_user_cmd *ucmd) return res; } +#ifndef CONFIG_SCST_PROC static int dev_user_process_reply_ext_copy_remap(struct scst_user_cmd *ucmd, struct scst_user_reply_cmd *reply) { @@ -1628,6 +1631,7 @@ out_status: scst_set_cmd_error_status(cmd, rreply->status); goto out_done; } +#endif static int dev_user_process_ws_reply(struct scst_user_cmd *ucmd, struct scst_user_scsi_cmd_reply_exec *ereply) @@ -1950,9 +1954,11 @@ unlock_process: res = dev_user_process_reply_on_cache_free(ucmd); break; +#ifndef CONFIG_SCST_PROC case UCMD_STATE_EXT_COPY_REMAPPING: res = dev_user_process_reply_ext_copy_remap(ucmd, reply); break; +#endif case UCMD_STATE_TM_RECEIVED_EXECING: case UCMD_STATE_TM_DONE_EXECING: @@ -2677,7 +2683,11 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, SCST_CONTEXT_THREAD); else { sBUG_ON(state != UCMD_STATE_EXT_COPY_REMAPPING); +#ifndef CONFIG_SCST_PROC scst_ext_copy_remap_done(ucmd->cmd, NULL, 0); +#else + sBUG(); +#endif } /* !! At this point cmd and ucmd can be already freed !! */ @@ -3217,10 +3227,11 @@ static void dev_user_setup_functions(struct scst_user_dev *dev) dev->devtype.dev_alloc_data_buf = dev_user_alloc_data_buf; dev->devtype.dev_done = NULL; + dev->devtype.ext_copy_remap = NULL; +#ifndef CONFIG_SCST_PROC if (dev->ext_copy_remap_supported) dev->devtype.ext_copy_remap = dev_user_ext_copy_remap; - else - dev->devtype.ext_copy_remap = NULL; +#endif if (dev->parse_type != SCST_USER_PARSE_CALL) { switch (dev->devtype.type) { From 82564f30ab34c8630190aabed810f1e6e5e171c3 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 19 Nov 2015 17:48:18 +0000 Subject: [PATCH 013/121] scst: More procfs build fixes. See also r6694. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6706 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_priv.h | 21 +++++++++++++++++++++ scst/src/scst_proc.c | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index ae1157d36..f0f87d8e3 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -893,6 +893,27 @@ void scst_cm_exit(void); static inline int scst_cm_on_dev_register(struct scst_device *dev) { return 0; } static inline void scst_cm_on_dev_unregister(struct scst_device *dev) {} +static inline int scst_cm_on_add_acg(struct scst_acg *acg) +{ + return 0; +} + +static inline void scst_cm_on_del_acg(struct scst_acg *acg) +{ +} + +static inline int scst_cm_on_add_lun(struct scst_acg_dev *acg_dev, uint64_t lun, + unsigned int *flags) +{ + return 0; +} + +static inline bool scst_cm_on_del_lun(struct scst_acg_dev *acg_dev, + bool gen_report_luns_changed) +{ + return gen_report_luns_changed; +} + static inline int scst_cm_parse_descriptors(struct scst_cmd *cmd) { scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_opcode)); diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index 26b99c3fe..0ade29717 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -2072,7 +2072,7 @@ static ssize_t scst_proc_groups_devices_write(struct file *file, rc = scst_acg_add_lun(acg, NULL, dev, virt_lun, read_only ? SCST_ADD_LUN_READ_ONLY : 0, - false, NULL); + NULL); if (rc) { res = rc; goto out_free_up; From ce479e0b01724cded1f4f6139ce068372411e31d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 20 Nov 2015 21:47:57 +0000 Subject: [PATCH 014/121] scst_local: Linux kernel v4.4 build fix Signed-off-by: Sebastian Herbszt [ bvanassche: Merged the two #if-statements into a single #if-statement ] git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6707 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst_local/scst_local.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index cf1cd8e31..45fe9c111 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -1619,7 +1619,8 @@ static struct scsi_host_template scst_lcl_ini_driver_template = { #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 25)) .eh_target_reset_handler = scst_local_target_reset, #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) .use_blk_tags = true, #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33) || \ From 2f455b29d1e26c073b35d232d8d129db5bbd96a5 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 20 Nov 2015 23:23:48 +0000 Subject: [PATCH 015/121] /etc/init.d/scst: Suppress rmmod error messages git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6708 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/init.d/scst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scstadmin/init.d/scst b/scstadmin/init.d/scst index ba5ce6f19..1366920f0 100755 --- a/scstadmin/init.d/scst +++ b/scstadmin/init.d/scst @@ -171,7 +171,9 @@ unload_kmod() { m="$1" t="$2" i=0 - while [ -e "/sys/module/$m/refcnt" ] && ! rmmod "$m" && [ $i -lt "$t" ]; do + while [ -e "/sys/module/$m/refcnt" ] && ! rmmod "$m" 2>/dev/null && + [ $i -lt "$t" ] + do sleep 1 i=$((i+1)) done From 0f3bcea86db1ca6b5d7b1064bbbd129984a80f02 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 21 Nov 2015 00:19:04 +0000 Subject: [PATCH 016/121] scstadmin: Improve copy manager support Add support for saving and restoring copy manager attributes. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6709 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/init.d/scst | 1 + scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm | 5 ++--- scstadmin/scstadmin.sysfs/scstadmin | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scstadmin/init.d/scst b/scstadmin/init.d/scst index 1366920f0..5e609c26f 100755 --- a/scstadmin/init.d/scst +++ b/scstadmin/init.d/scst @@ -149,6 +149,7 @@ parse_scst_conf() { case "$d" in iscsi) echo iscsi_scst;; qla2x00t) echo qla2x00tgt;; + copy_manager) ;; *) echo "$d";; esac done | sort -u` \ diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm index 4aa497f98..3e5ab798b 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm @@ -5,7 +5,7 @@ package SCST::SCST; # Author: Mark R. Buechler # License: GPLv2 # Copyright (c) 2005-2011 Mark R. Buechler -# Copyright (c) 2011 Bart Van Assche . +# Copyright (c) 2011-2015 Bart Van Assche . use 5.005; use Fcntl ':mode'; @@ -550,8 +550,7 @@ sub drivers { if (opendir($dHandle, $_path)) { foreach my $driver (readdir($dHandle)) { - next if ($driver eq '.' || $driver eq '..' || - $driver eq 'copy_manager'); + next if ($driver eq '.' || $driver eq '..'); if (-d make_path(SCST_TARGETS_DIR(), $driver)) { push @drivers, $driver; diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 60d609717..39c478e4b 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -7,7 +7,7 @@ $Version = 'SCST Configurator v3.1.0-pre1'; # Author: Mark R. Buechler # License: GPLv2 # Copyright (c) 2005-2011 Mark R. Buechler -# Copyright (C) 2011 Bart Van Assche +# Copyright (C) 2011-2015 Bart Van Assche sub usage { @@ -1462,6 +1462,9 @@ sub writeConfiguration { my $t_lun_buff; foreach my $lun (sort numerically keys %{$luns}) { + # Do not save copy_manager LUN definitions. + next if ($driver eq 'copy_manager'); + my $lun_dev = $$luns{$lun}; $t_lun_buff .= "\t\tLUN $lun $lun_dev"; @@ -2614,6 +2617,11 @@ sub applyLunAssignments { my $c_luns; my $changes = 0; + # Do not restore copy_manager LUN definitions. + if ($driver eq 'copy_manager') { + return 0; + } + if (defined($group)) { $c_luns = $CURRENT{'assign'}->{$driver}->{$target}->{'GROUP'}->{$group}->{'LUN'}; } else { From d6b116c46d9d75df7027ce41052c8c5ffc4b1977 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 22 Nov 2015 19:49:18 +0000 Subject: [PATCH 017/121] qla2x00t: Fix a few typos Signed-off-by: Sebastian Herbszt git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6710 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla_isr.c | 6 +++--- qla2x00t/qla_os.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/qla2x00t/qla_isr.c b/qla2x00t/qla_isr.c index 5f2923dbe..83714a603 100644 --- a/qla2x00t/qla_isr.c +++ b/qla2x00t/qla_isr.c @@ -261,7 +261,7 @@ qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) /* Read all mbox registers? */ mboxes = (1 << ha->mbx_count) - 1; if (!ha->mcp) - ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERRROR.\n"); + ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n"); else mboxes = ha->mcp->in_mb; @@ -1516,7 +1516,7 @@ qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len, struct scsi_dif_tuple { __be16 guard; /* Checksum */ - __be16 app_tag; /* APPL identifer */ + __be16 app_tag; /* APPL identifier */ __be32 ref_tag; /* Target LBA or indirect LBA */ }; @@ -2073,7 +2073,7 @@ qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0) /* Read all mbox registers? */ mboxes = (1 << ha->mbx_count) - 1; if (!ha->mcp) - ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERRROR.\n"); + ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n"); else mboxes = ha->mcp->in_mb; diff --git a/qla2x00t/qla_os.c b/qla2x00t/qla_os.c index bbaad3885..eb40c5405 100644 --- a/qla2x00t/qla_os.c +++ b/qla2x00t/qla_os.c @@ -1171,7 +1171,7 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, cmd->device->lun, type) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800d, - "wait for peding cmds failed for cmd=%p.\n", cmd); + "wait for pending cmds failed for cmd=%p.\n", cmd); goto eh_reset_failed; } @@ -1274,7 +1274,7 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) eh_bus_reset_done: ql_log(ql_log_warn, vha, 0x802b, "BUS RESET %s nexus=%ld:%d:%d.\n", - (ret == FAILED) ? "FAILED" : "SUCCEDED", vha->host_no, id, lun); + (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); return ret; } From 3047ca75fdda0ba80410265ba0c0b7b4246a46f1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 22 Nov 2015 20:03:29 +0000 Subject: [PATCH 018/121] mpt: Include header file mptbase.h without path Allow include path modification with LSI_INC_DIR. Signed-off-by: Sebastian Herbszt git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6711 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- mpt/mpt_scst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpt/mpt_scst.h b/mpt/mpt_scst.h index 98d11fcab..51dd1c55f 100644 --- a/mpt/mpt_scst.h +++ b/mpt/mpt_scst.h @@ -37,7 +37,7 @@ #define MPT_STM_64_BIT_DMA 1 #endif -#include "../drivers/message/fusion/mptbase.h" +#include "mptbase.h" #ifndef MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED #define MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED 0x24000002 From 949aa31053721ec04e7570862e80f269e980ac2c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 23 Nov 2015 23:04:57 +0000 Subject: [PATCH 019/121] scstadmin: Improve copy manager support further Also restore pass-through LUNs git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6712 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- .../scst-0.9.10/lib/SCST/SCST.pm | 6 ++- .../scst-0.9.10/t/01-start-scst.t | 2 + scstadmin/scstadmin.sysfs/scstadmin | 43 ++++++++++++++----- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm index 3e5ab798b..2eb5055e2 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm @@ -3930,7 +3930,11 @@ sub handlerAttributes { } } - next if ($attribute eq SCST_MGMT_IO); + if ($attribute eq SCST_MGMT_IO) { + $attributes{$attribute}->{'static'} = TRUE; + $attributes{$attribute}->{'value'} = $value; + next; + } if (!(($mode & S_IRUSR) >> 6)) { $attributes{$attribute}->{'static'} = FALSE; diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t index b30abe46a..703756e0f 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t @@ -9,6 +9,8 @@ BEGIN { if ($> == 0) { ok(system("killall iscsi-scstd >/dev/null 2>&1; " . + "modprobe -r scst_cdrom; " . + "modprobe -r scst_disk; " . "modprobe -r scst_local; " . "modprobe -r isert-scst; " . "modprobe -r iscsi-scst; " . diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 39c478e4b..81fec91cc 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -1334,6 +1334,25 @@ sub serializeNkAttr { return $result; } +# Return TRUE if and only if $1 is an SCST pass-through device. +sub isPassthroughDev { + my $dev = shift; + my $pt = FALSE; + + foreach my $handler (keys %{$CURRENT{'handler'}}) { + my ($ha, $errorString) = $SCST->handlerAttributes($handler); + next if ($ha->{'mgmt'} !~ 'echo "add_device H:C:I:L"'); + my @devs = @{$CURRENT{'handler'}->{$handler}}; + for my $i (0 .. $#devs) { + if ($dev eq @devs[$i]) { + $pt = TRUE; + last; + } + } + last if $pt; + } +} + # Returns 0 upon success and 1 upon error. sub writeConfiguration { my $nonkey = shift; @@ -1462,11 +1481,14 @@ sub writeConfiguration { my $t_lun_buff; foreach my $lun (sort numerically keys %{$luns}) { - # Do not save copy_manager LUN definitions. - next if ($driver eq 'copy_manager'); - my $lun_dev = $$luns{$lun}; + # Do not save copy_manager LUN definitions + # for LUNs associated with an SCST device + # handler. + next if ($driver eq 'copy_manager' && + isPassthroughDev($lun_dev)); + $t_lun_buff .= "\t\tLUN $lun $lun_dev"; my ($attributes, $errorString) = $SCST->lunAttributes($driver, $target, $lun); @@ -1895,7 +1917,7 @@ sub checkConfiguration { } } - if (!defined($$tgt{'LUN'}->{'0'})) { + if ($driver ne 'copy_manager' && !defined($$tgt{'LUN'}->{'0'})) { print "\t-> WARNING: No LUN 0 defined for driver/target '$driver/$target'. ". "Many initiators require a LUN 0 to be defined.\n\n"; $warnings++; @@ -2107,7 +2129,7 @@ sub applyConfigAssignments { if ($deletions) { removeLun($driver, $target, $lun); $changes++; - } else { + } elsif ($driver ne 'copy_manager') { print "\t-> Device '$device' at LUN '$lun' is not in configuration ". "for driver/target '$driver/$target'. ". "Use -force to remove it.\n"; @@ -2617,11 +2639,6 @@ sub applyLunAssignments { my $c_luns; my $changes = 0; - # Do not restore copy_manager LUN definitions. - if ($driver eq 'copy_manager') { - return 0; - } - if (defined($group)) { $c_luns = $CURRENT{'assign'}->{$driver}->{$target}->{'GROUP'}->{$group}->{'LUN'}; } else { @@ -4888,6 +4905,12 @@ sub addLun { my $attributes = shift; my $group = shift; + # Do not complain about existing copy manager LUNs. + if ($driver eq 'copy_manager' && + $SCST->lunExists($driver, $target, $lun, $group)) { + return FALSE; + } + if (defined($group)) { print "\t-> Adding device '$device' at LUN $lun to driver/target/group ". "'$driver/$target/$group': "; From 3353e47e28783cdf6b14f5917945d0f471517826 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 23 Nov 2015 23:05:24 +0000 Subject: [PATCH 020/121] scstadmin: Make regression test 6 pass git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6713 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- .../scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t | 4 +++- .../scstadmin.sysfs/scst-0.9.10/t/after-restore.conf | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t index 883f020f3..ada3d17a4 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t @@ -41,13 +41,15 @@ sub testRestoreConfig { "scstadmin-test-06-$$-1"); my $tmpfilename2 = File::Spec->catfile(File::Spec->tmpdir(), "scstadmin-test-06-$$-2"); + my $diff = File::Spec->catfile(File::Spec->tmpdir(), + "scstadmin-test-06-$$-diff"); system("$scstadmin -clear_config -force -noprompt -no_lip >/dev/null"); system("$scstadmin -cont_on_err -no_lip -config $to_be_restored" . " >/dev/null"); system("$scstadmin -write_config $tmpfilename1 >/dev/null"); system("awk 'BEGIN {t = 0 } /^# Automatically generated by SCST Configurator v/ { \$0 = \"# Automatically generated by SCST Configurator v...\" } /^TARGET_DRIVER.*{\$/ { if (\$0 != \"TARGET_DRIVER scst_local {\") t = 1 } /^}\$/ { if (t == 1) t = 2 } /^\$/ { if (t == 2) { t = 3 } } /^./ { if (t == 3) { t = 0 } } { if (t == 0) print }' <$tmpfilename1 >$tmpfilename2"); - my $compare_result = system("diff -u $tmpfilename2 $expected"); + my $compare_result = system("diff -u $tmpfilename2 $expected >$diff"); ok($compare_result, 0); if ($compare_result == 0) { unlink($tmpfilename2); diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf index f0c5264f2..8f5291be5 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf @@ -14,6 +14,11 @@ TARGET_DRIVER scst_local { LUN 0 disk01 LUN 1 disk01 + GROUP group_without_luns_with_attrs { + + addr_method FLAT + } + GROUP initiator_group { LUN 0 disk01 LUN 1 disk01 { @@ -27,11 +32,6 @@ TARGET_DRIVER scst_local { INITIATOR ini3 } - - GROUP group_without_luns_with_attrs { - - addr_method FLAT - } } } From c86027404ad18575cfc921363accf3c5dd2627ad Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 25 Nov 2015 17:28:02 +0000 Subject: [PATCH 021/121] usr/fileio: Build fix for Ubuntu 15.10 Ubuntu 15.10 includes Linux kernel 4.2 but does not define SERVICE_ACTION_IN_16 in the glibc header. Hence provide a definition in scst_const.h. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6714 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst_const.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index b0a2fc51b..cd213cbee 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -466,10 +466,10 @@ static inline int scst_sense_response_code(const uint8_t *sense) #endif #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) +#ifndef GENERATING_UPSTREAM_PATCH /* * See also patch "scsi: rename SERVICE_ACTION_IN_16 to SERVICE_ACTION_IN_16" - * (commit eb846d9f147455e4e5e1863bfb5e31974bb69b7c). + * (commit eb846d9f147455e4e5e1863bfb5e31974bb69b7c; kernel 3.19.0). */ #ifndef SERVICE_ACTION_IN_16 #define SERVICE_ACTION_IN_16 0x9e From 3136f99a8692566212f2cc8ee419c63c5358e561 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 28 Nov 2015 04:39:57 +0000 Subject: [PATCH 022/121] scst-const.h: Follow-up for r6714 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6715 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst_const.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index cd213cbee..caa54728c 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -466,7 +466,7 @@ static inline int scst_sense_response_code(const uint8_t *sense) #endif #endif -#ifndef GENERATING_UPSTREAM_PATCH +#if !defined(__KERNEL__) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) /* * See also patch "scsi: rename SERVICE_ACTION_IN_16 to SERVICE_ACTION_IN_16" * (commit eb846d9f147455e4e5e1863bfb5e31974bb69b7c; kernel 3.19.0). From edfd19ee7e2698d252333e915161f2d7087ae061 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 2 Dec 2015 16:57:45 +0000 Subject: [PATCH 023/121] scst: Rename the PR-sync document to avoid filenames with spaces in the SCST tree git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6716 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- ...the-DLM-as-a-Distributed-In-Memory-Database.pdf} | Bin 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/{Using the DLM as a Distributed In-Memory Database.pdf => Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf} (100%) diff --git a/doc/Using the DLM as a Distributed In-Memory Database.pdf b/doc/Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf similarity index 100% rename from doc/Using the DLM as a Distributed In-Memory Database.pdf rename to doc/Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf From ad812fedb644eb942f0c8481ba2e8596655a0875 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 2 Dec 2015 22:59:33 +0000 Subject: [PATCH 024/121] scstadmin: Ensure that -no_lip takes effect for all SCST configuration commands git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6717 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/scstadmin.sysfs/scstadmin | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 81fec91cc..4a5b4556c 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -1051,7 +1051,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeVirtualTarget($driver, $removeTarget); - $rc = issueLip($driver) if (!$rc); + $rc = issueLip($driver) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1071,7 +1071,7 @@ sub main { defined($addInitiator) && do { print "\n-> Making requested changes.\n"; $rc = addInitiator($driver, $target, $group, $addInitiator); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1079,7 +1079,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeInitiator($driver, $target, $group, $removeInitiator); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1087,7 +1087,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = moveInitiator($driver, $target, $group, $moveInitiator, $to); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1095,14 +1095,14 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = clearInitiators($driver, $target, $group); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; defined($addLun) && do { print "\n-> Making requested changes.\n"; $rc = addLun($driver, $target, $device, $addLun, $attributes, $group); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1110,7 +1110,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeLun($driver, $target, $removeLun, $group); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1118,7 +1118,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = replaceLun($driver, $target, $group, $replaceLun, $device, $attributes); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1126,7 +1126,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = clearLuns($driver, $target, $group); - $rc = issueLip($driver, $target) if (!$rc); + $rc = issueLip($driver, $target) if (!$rc && !$noLip); print "\t-> Done.\n"; last SWITCH; }; @@ -1145,7 +1145,7 @@ sub main { }; defined($issueLip) && do { print "\n-> Making requested changes.\n"; - $rc = issueLip($driver, $issueLip, TRUE); + $rc = issueLip($driver, $issueLip, TRUE) if (!$noLip); print "\t-> Done.\n"; last SWITCH; }; From d31e5bd373ccde66a9916d748b6f88e6d79de421 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 4 Dec 2015 00:31:40 +0000 Subject: [PATCH 025/121] nightly build: Update kernel versions git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6718 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- nightly/conf/nightly.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 6b79841c8..67abb86e4 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -8,13 +8,13 @@ ABT_KERNELS=" \ 4.1.13-nc \ 4.0.9-nc \ 3.19.7-nc \ -3.18.19-nc \ +3.18.24-nc \ 3.17.8-nc \ 3.16.7-nc \ 3.15.10-nc \ 3.14.57-nc \ 3.13.11-nc \ -3.12.44-nc \ +3.12.51-nc \ 3.11.10-nc \ 3.10.93-nc \ 3.9.11-nc \ @@ -24,7 +24,7 @@ ABT_KERNELS=" \ 3.5.7-nc \ 3.4.108-nc \ 3.3.8-nc \ -3.2.67-nc \ +3.2.74-nc \ 3.1.10-nc \ 3.0.101-nc \ 2.6.39.4-nc \ From 0b8cb936d3896db94fc9496d085b55998381045b Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Tue, 8 Dec 2015 03:44:51 +0000 Subject: [PATCH 026/121] docs: fix (extra)clean brocken by r6716 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6720 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- doc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index c1b59b8cc..de55e58a8 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -36,9 +36,9 @@ rtf: $(RTFS) $(COMMAND)rtf $(<) clean: - mv "Using the DLM as a Distributed In-Memory Database.pdf" "Using the DLM as a Distributed In-Memory Database.pdf_" + -mv "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf" "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf_" rm -f *.txt *.html *.tex *.dvi *.ps *.pdf *.info *.lyx *.rtf - mv "Using the DLM as a Distributed In-Memory Database.pdf_" "Using the DLM as a Distributed In-Memory Database.pdf" + -mv "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf_" "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf" extraclean: clean rm -f *.orig *.rej From a195aee513403737a261c13c1658449e66060d60 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Tue, 8 Dec 2015 03:51:01 +0000 Subject: [PATCH 027/121] Cleanup git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6721 d57e44dd-8a1f-0410-8b47-8ef2f437770f From 82d831be8080bc36c3567378d67ec34608571e28 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Tue, 8 Dec 2015 04:16:01 +0000 Subject: [PATCH 028/121] scst_event: fix forgotten corner case module_put git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6723 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_event.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index 3b36b8e50..c7af51a4f 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -866,7 +866,7 @@ static int scst_event_create_priv(struct file *file) PRINT_ERROR("Unable to allocate priv (size %zd)", sizeof(*priv)); res = -ENOMEM; - goto out; + goto out_put; } TRACE_MEM("priv %p allocated", priv); @@ -891,6 +891,10 @@ static int scst_event_create_priv(struct file *file) out: TRACE_EXIT_RES(res); return res; + +out_put: + module_put(THIS_MODULE); + goto out; } static long scst_event_ioctl(struct file *file, unsigned int cmd, From 08b774f6439fa115d511a15dc9dd9313943b6301 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 9 Dec 2015 19:18:01 +0000 Subject: [PATCH 029/121] scst_main: Fix wait_event() call in scst_unregister_target() Avoid that the following kernel warning gets triggered: WARNING: CPU: 3 PID: 12967 at kernel/sched/core.c:7287 __might_sleep+0x7a/0x90() do not call blocking ops when !TASK_RUNNING; state=2 set at [] prepare_to_wait_event+0x5e/0xf0 CPU: 3 PID: 12967 Comm: scst_uid Tainted: G O 4.0.0-debug+ #1 Call Trace: [] dump_stack+0x4c/0x65 [] warn_slowpath_common+0x80/0xc0 [] warn_slowpath_fmt+0x41/0x50 [] __might_sleep+0x7a/0x90 [] mutex_lock_nested+0x2a/0x4d0 [] test_sess_list+0x1a/0x40 [scst] [] scst_unregister_target+0x26e/0x380 [scst] [] __scst_local_remove_target+0xc6/0x160 [scst_local] [] scst_local_sysfs_del_target+0xbc/0x1b0 [scst_local] [] scst_process_tgtt_mgmt_store+0x205/0x300 [scst] [] scst_tgtt_mgmt_store_work_fn+0x14/0x20 [scst] [] scst_process_sysfs_works+0xbd/0x1f0 [scst] [] sysfs_work_thread_fn+0xbd/0x310 [scst] [] kthread+0xf3/0x110 [] ret_from_fork+0x58/0x90 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6724 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_main.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index b5b3851e9..512d0bae1 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -593,16 +593,6 @@ out_free_tgt: } EXPORT_SYMBOL(scst_register_target); -static inline int test_sess_list(struct scst_tgt *tgt) -{ - int res; - - mutex_lock(&scst_mutex); - res = list_empty(&tgt->sysfs_sess_list); - mutex_unlock(&scst_mutex); - return res; -} - /** * scst_unregister_target() - unregister target. * @@ -655,8 +645,15 @@ again: mutex_unlock(&scst_mutex); #endif + /* + * Testing tgt->sysfs_sess_list below without holding scst_mutex + * is safe because 'tgt' won't disappear until scst_free_tgt() is + * called below and because the mutex_lock(&scst_mutex) call below + * waits until scst_free_session() has finished accessing the 'tgt' + * object. + */ TRACE_DBG("%s", "Waiting for sessions shutdown"); - wait_event(tgt->unreg_waitQ, test_sess_list(tgt)); + wait_event(tgt->unreg_waitQ, list_empty(&tgt->sysfs_sess_list)); TRACE_DBG("%s", "wait_event() returned"); scst_suspend_activity(SCST_SUSPEND_TIMEOUT_UNLIMITED); From d13b730d6df72a5362db43e299ecd636d79a0ce2 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 01:38:46 +0000 Subject: [PATCH 030/121] ib_srpt: Improve robustness of "make clean" git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6725 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srpt/Makefile b/srpt/Makefile index 370b308b2..e224c4be4 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -139,8 +139,8 @@ src/$(MODULE_SYMVERS): $(SCST_SYMVERS_DIR)/$(MODULE_SYMVERS) \ clean: rm -rf conftest/pre_cflags conftest/kcflags - for d in conftest/* src; do \ - $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/$$d clean; \ + for d in conftest/* src; do \ + [ -d "$$d" ] && $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/$$d clean; \ done rm -f src/$(MODULE_SYMVERS) src/Module.markers src/modules.order From 8aae2413b38dbbb4da1f816a673748551ca21c34 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 01:39:46 +0000 Subject: [PATCH 031/121] ib_srpt: Convert srpt_ch_list_empty() to RCU This patch avoids that the following warning is reported when unloading the ib_srpt kernel module: WARNING: CPU: 9 PID: 33739 at kernel/sched/core.c:7533 __might_sleep+0x82/0x90() do not call blocking ops when !TASK_RUNNING; state=2 set at [] prepare_to_wait_event+0x63/0x110 Call Trace: [] dump_stack+0x4f/0x74 [] warn_slowpath_common+0x8b/0xd0 [] warn_slowpath_fmt+0x41/0x70 [] __might_sleep+0x82/0x90 [] mutex_lock_nested+0x33/0x380 [] srpt_ch_list_empty+0x2b/0x80 [ib_srpt] [] srpt_release_sport+0xcc/0x2a0 [ib_srpt] [] srpt_release+0x35/0x80 [ib_srpt] [] scst_unregister_target+0x70/0x380 [scst] [] srpt_remove_one+0xb1/0x150 [ib_srpt] [] ib_unregister_client+0xe5/0x190 [ib_core] [] srpt_cleanup_module+0x21/0x2f [ib_srpt] [] SyS_delete_module+0x17b/0x1c0 [] entry_SYSCALL_64_fastpath+0x12/0x6f git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6726 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 21 ++++++++++++--------- srpt/src/ib_srpt.h | 2 ++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 6015f29fa..2d2895335 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2098,7 +2098,7 @@ static void srpt_free_ch(struct kref *kref) srpt_destroy_ch_ib(ch); - kfree(ch); + kfree_rcu(ch, rcu); } static void srpt_unreg_ch(struct srpt_rdma_ch *ch) @@ -2127,7 +2127,7 @@ static void srpt_unreg_ch(struct srpt_rdma_ch *ch) * after list_del() and before wake_up() has been invoked. */ mutex_lock(&sport->mutex); - list_del(&ch->list); + list_del_rcu(&ch->list); wake_up(&sport->ch_releaseQ); mutex_unlock(&sport->mutex); @@ -2397,7 +2397,8 @@ static struct srpt_nexus *srpt_get_nexus(struct srpt_port *sport, } } if (!nexus && tmp_nexus) { - list_add_tail(&tmp_nexus->entry, &sport->nexus_list); + list_add_tail_rcu(&tmp_nexus->entry, + &sport->nexus_list); swap(nexus, tmp_nexus); } mutex_unlock(&sport->mutex); @@ -2695,7 +2696,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, rsp->rsp_flags = SRP_LOGIN_RSP_MULTICHAN_MAINTAINED; } - list_add_tail(&ch->list, &nexus->ch_list); + list_add_tail_rcu(&ch->list, &nexus->ch_list); ch->thread = thread; if (!sport->enabled) { @@ -3841,11 +3842,11 @@ static bool srpt_ch_list_empty(struct srpt_port *sport) struct srpt_nexus *nexus; bool res = true; - mutex_lock(&sport->mutex); - list_for_each_entry(nexus, &sport->nexus_list, entry) + rcu_read_lock(); + list_for_each_entry_rcu(nexus, &sport->nexus_list, entry) if (!list_empty(&nexus->ch_list)) res = false; - mutex_unlock(&sport->mutex); + rcu_read_unlock(); return res; } @@ -3885,8 +3886,8 @@ static int srpt_release_sport(struct srpt_port *sport) mutex_lock(&sport->mutex); list_for_each_entry_safe(nexus, next_n, &sport->nexus_list, entry) { - list_del(&nexus->entry); - kfree(nexus); + list_del_rcu(&nexus->entry); + kfree_rcu(nexus, rcu); } mutex_unlock(&sport->mutex); @@ -4590,6 +4591,8 @@ out: static void __exit srpt_cleanup_module(void) { + rcu_barrier(); + if (rdma_cm_id) rdma_destroy_id(rdma_cm_id); ib_unregister_client(&srpt_client); diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index bbe52c011..fdf57791f 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -361,6 +361,7 @@ struct srpt_rdma_ch { }; struct ib_cq *cq; struct kref kref; + struct rcu_head rcu; int rq_size; int max_sge; int max_rsp_size; @@ -397,6 +398,7 @@ struct srpt_rdma_ch { struct srpt_nexus { struct list_head entry; struct list_head ch_list; + struct rcu_head rcu; u8 i_port_id[16]; u8 t_port_id[16]; }; From 53a9829a45d4939829a0719eaa10a3fa46ea8e06 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 01:40:41 +0000 Subject: [PATCH 032/121] ib_srpt: Fix a runtime warning Avoid that the following warning is reported: WARNING: CPU: 7 PID: 32692 at kernel/sched/core.c:7533 __might_sleep+0x82/0x90() do not call blocking ops when !TASK_RUNNING; state=1 set at [] srpt_compl_thread+0xab/0x1c0 [ib_srpt] Call Trace: [] dump_stack+0x4f/0x74 [] warn_slowpath_common+0x8b/0xd0 [] warn_slowpath_fmt+0x41/0x70 [] __might_sleep+0x82/0x90 [] mempool_alloc+0x94/0x180 [] scst_alloc_mgmt_cmd+0x4c/0x120 [scst] [] scst_pre_rx_mgmt_cmd+0x84/0x1e0 [scst] [] scst_rx_mgmt_fn+0x8a/0x3e0 [scst] [] scst_rx_mgmt_fn_lun+0x6e/0x90 [ib_srpt] [] srpt_handle_tsk_mgmt+0x1c1/0x2f0 [ib_srpt] [] srpt_handle_new_iu+0x1c0/0x230 [ib_srpt] [] srpt_process_rcv_completion+0x89/0xd0 [ib_srpt] [] srpt_process_one_compl+0x54/0x70 [ib_srpt] [] srpt_poll+0x69/0x90 [ib_srpt] [] srpt_process_completion+0x1e/0x40 [ib_srpt] [] srpt_compl_thread+0xdc/0x1c0 [ib_srpt] git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6727 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 2d2895335..115175845 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2068,13 +2068,18 @@ static int srpt_poll(struct srpt_rdma_ch *ch, int budget) return processed; } -static int srpt_process_completion(struct srpt_rdma_ch *ch, int budget) +static int srpt_process_completion(struct srpt_rdma_ch *ch, int budget, + bool thread_context) { struct ib_cq *const cq = ch->cq; int processed = 0, n = budget; do { + if (thread_context) + set_current_state(TASK_RUNNING); processed += srpt_poll(ch, n); + if (thread_context) + set_current_state(TASK_INTERRUPTIBLE); n = ib_req_notify_cq(cq, IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS); } while (n > 0); @@ -2143,6 +2148,7 @@ static int srpt_compl_thread(void *arg) { enum { poll_budget = 65536 }; struct srpt_rdma_ch *ch; + int n; /* Hibernation / freezing of the SRPT kernel thread is not supported. */ current->flags |= PF_NOFREEZE; @@ -2151,8 +2157,10 @@ static int srpt_compl_thread(void *arg) BUG_ON(!ch); while (ch->state < CH_LIVE) { - set_current_state(TASK_INTERRUPTIBLE); - if (srpt_process_completion(ch, poll_budget) >= poll_budget) + n = srpt_process_completion(ch, poll_budget, true); + if (ch->state >= CH_LIVE) + break; + if (n >= poll_budget) cond_resched(); else schedule(); @@ -2161,8 +2169,10 @@ static int srpt_compl_thread(void *arg) srpt_process_wait_list(ch); while (ch->state < CH_DISCONNECTED) { - set_current_state(TASK_INTERRUPTIBLE); - if (srpt_process_completion(ch, poll_budget) >= poll_budget) + n = srpt_process_completion(ch, poll_budget, true); + if (ch->state >= CH_DISCONNECTED) + break; + if (n >= poll_budget) cond_resched(); else schedule(); From 10998483979d9b2d2297e57ee9430b69522849b3 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 11 Dec 2015 01:51:31 +0000 Subject: [PATCH 033/121] scst: small addition to r6724 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6728 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 512d0bae1..6bd731c80 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -647,8 +647,13 @@ again: /* * Testing tgt->sysfs_sess_list below without holding scst_mutex - * is safe because 'tgt' won't disappear until scst_free_tgt() is - * called below and because the mutex_lock(&scst_mutex) call below + * is safe, because: + * + * - On the init path no attempts to create new sessions for this + * target can be done in a race with this function (see above) + * + * - On the shutdown path 'tgt' won't disappear until scst_free_tgt() + * is called below and because the mutex_lock(&scst_mutex) call below * waits until scst_free_session() has finished accessing the 'tgt' * object. */ From 2b4abe603a50a29230022f7852f3fd57e246c974 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 05:52:45 +0000 Subject: [PATCH 034/121] scst/include/backport.h: Add kfree_rcu() definition for kernels < 3.0 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6730 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scst/include/backport.h b/scst/include/backport.h index 480b13e3c..8f7c53478 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -365,6 +365,21 @@ static inline __attribute__ ((format (printf, 1, 2))) int no_printk(const char *s, ...) { return 0; } #endif +/* */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) +typedef void (*rcu_callback_t)(struct rcu_head *); +#define __is_kfree_rcu_offset(offset) ((offset) < 4096) +#define kfree_call_rcu(head, rcb) call_rcu(head, rcb) +#define __kfree_rcu(head, offset) \ + do { \ + BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \ + kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \ + } while (0) +#define kfree_rcu(ptr, rcu_head) \ + __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head)) +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) && \ From e4a852e599ca8827304c21ea9c32bfc757d23e56 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 17:39:55 +0000 Subject: [PATCH 035/121] scstadmin regression tests: Rename two files git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6731 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- .../t/{after-restore.conf => 06-after-restore.conf} | 0 scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t | 4 ++-- .../t/{to-be-restored.conf => 06-to-be-restored.conf} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename scstadmin/scstadmin.sysfs/scst-0.9.10/t/{after-restore.conf => 06-after-restore.conf} (100%) rename scstadmin/scstadmin.sysfs/scst-0.9.10/t/{to-be-restored.conf => 06-to-be-restored.conf} (100%) diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-after-restore.conf similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf rename to scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-after-restore.conf diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t index ada3d17a4..c91b85c7e 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t @@ -64,6 +64,6 @@ die("Creation of SCST object failed") if (!defined($SCST)); setup($SCST); -testRestoreConfig(File::Spec->catfile($testdir, "to-be-restored.conf"), - File::Spec->catfile($testdir, "after-restore.conf")); +testRestoreConfig(File::Spec->catfile($testdir, "06-to-be-restored.conf"), + File::Spec->catfile($testdir, "06-after-restore.conf")); diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-to-be-restored.conf similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf rename to scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-to-be-restored.conf From 9484c62c419e757e28a0e77a86d83e27e482bb18 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 18:31:49 +0000 Subject: [PATCH 036/121] scstadmin.sysfs/Makefile: Add and comment out TEST_VERBOSE=1 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6732 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/scstadmin.sysfs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scstadmin/scstadmin.sysfs/Makefile b/scstadmin/scstadmin.sysfs/Makefile index 3a41eeb89..e9c01f486 100644 --- a/scstadmin/scstadmin.sysfs/Makefile +++ b/scstadmin/scstadmin.sysfs/Makefile @@ -24,7 +24,7 @@ perl-module: $(MAKE) -C scst-$(MODULE_VERSION) test: - $(MAKE) -C scst-$(MODULE_VERSION) test + $(MAKE) -C scst-$(MODULE_VERSION) test #TEST_VERBOSE=1 clean: -$(MAKE) -C scst-$(MODULE_VERSION) clean From 094a6be70db37ea64308d9a7a3b841ed75b688da Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 18:33:17 +0000 Subject: [PATCH 037/121] scstadmin: Add a seventh regression test git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6733 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- .../scst-0.9.10/t/07-result.conf | 14 +++ .../scst-0.9.10/t/07-scstadmin-args.t | 85 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-result.conf create mode 100644 scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-scstadmin-args.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-result.conf b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-result.conf new file mode 100644 index 000000000..d11c5f262 --- /dev/null +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-result.conf @@ -0,0 +1,14 @@ +# Automatically generated by SCST Configurator v... + + +TARGET_DRIVER scst_local { + TARGET local { + GROUP ig { + + INITIATOR ini1 + + INITIATOR ini2 + } + } +} + diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-scstadmin-args.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-scstadmin-args.t new file mode 100644 index 000000000..accea98f5 --- /dev/null +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-scstadmin-args.t @@ -0,0 +1,85 @@ +#!perl + +use strict; +use Cwd qw(abs_path); +use File::Basename; +use File::Spec; +use Test; + +my $testdir; +my $scstadmin_pm_dir; +my $scstadmin_dir; +my $scstadmin; +my $redirect_file = "/tmp/07-output.txt"; +my $redirect = ">>$redirect_file"; +my $redirect = ">/dev/null"; + +BEGIN { + unlink($redirect_file); + $testdir = dirname(abs_path($0)); + $scstadmin_pm_dir = dirname($testdir); + $scstadmin_dir = dirname($scstadmin_pm_dir); + $scstadmin = File::Spec->catfile($scstadmin_dir, "scstadmin"); + unless(grep /blib/, @INC) { + unshift(@INC, File::Spec->catdir($scstadmin_pm_dir, "lib")); + } + plan tests => 2; +} + +use Data::Dumper; +use SCST::SCST; +use File::Temp qw/tempfile/; + +sub setup { + my $SCST = shift; + + my ($drivers, $errorString) = $SCST->drivers(); + my %drivers = map { $_ => 1 } @{$drivers}; + ok(exists($drivers{'scst_local'})); +} + +sub attributeTest { + my $expected = shift; + my $tmpfilename1 = File::Spec->catfile(File::Spec->tmpdir(), + "scstadmin-test-07-$$-1"); + my $tmpfilename2 = File::Spec->catfile(File::Spec->tmpdir(), + "scstadmin-test-07-$$-2"); + my $diff = File::Spec->catfile(File::Spec->tmpdir(), + "scstadmin-test-07-$$-diff"); + + system("$scstadmin -clear_config -force -noprompt -no_lip $redirect"); + system("$scstadmin -open_dev nodev -handler vdisk_nullio -attributes dummy=1,read_zero=1 $redirect"); + system("$scstadmin -open_dev disk0 -handler vdisk_fileio -attributes filename=/dev/zero,read_only=1 $redirect"); + system("$scstadmin -open_dev disk1 -handler vdisk_fileio -attributes filename=/dev/zero,nv_cache=1 $redirect"); + system("$scstadmin -driver scst_local -add_target local $redirect"); + system("$scstadmin -driver scst_local -target local " . + "-add_lun 0 -device nodev $redirect"); + system("$scstadmin -driver scst_local -target local -add_group ig " . + "$redirect"); + system("$scstadmin -driver scst_local -target local -group ig " . + "-add_init ini1 $redirect"); + system("$scstadmin -driver scst_local -target local -group ig " . + "-add_init ini2 $redirect"); + system("$scstadmin -driver scst_local -target local -group ig " . + "-add_lun 0 -device disk0 $redirect"); + system("$scstadmin -driver scst_local -target local -group ig " . + "-add_lun 1 -device disk1 $redirect"); + system("$scstadmin -write_config $tmpfilename1 >/dev/null"); + system("awk 'BEGIN { t = 0 } /^# Automatically generated by SCST Configurator v/ { \$0 = \"# Automatically generated by SCST Configurator v...\" } /^TARGET_DRIVER.*{\$/ { if (\$0 != \"TARGET_DRIVER scst_local {\") t = 1 } /^}\$/ { if (t == 1) t = 2 } /^\$/ { if (t == 2) { t = 3 } } /^./ { if (t == 3) { t = 0 } } { if (t == 0) print }' <$tmpfilename1 >$tmpfilename2"); + my $compare_result = system("diff -u $tmpfilename2 $expected >$diff"); + ok($compare_result, 0); + if ($compare_result == 0) { + unlink($tmpfilename2); + unlink($tmpfilename1); + } +} + +my $_DEBUG_ = 0; + +my $SCST = eval { new SCST::SCST($_DEBUG_) }; +die("Creation of SCST object failed") if (!defined($SCST)); + +setup($SCST); + +attributeTest(File::Spec->catfile($testdir, "07-result.conf")); + From 749c8a3e75a910520a5eae3baa82b24ba232875c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 18:34:39 +0000 Subject: [PATCH 038/121] scstadmin: Fix -attributes behavior for multiple attributes git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6734 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm index 2eb5055e2..e5c8a2d55 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm @@ -2224,7 +2224,7 @@ sub addLun { my $o_string = ""; foreach my $attribute (keys %{$attributes}) { my $value = $$attributes{$attribute}; - $o_string .= "$attribute=$value; "; + $o_string .= "$attribute=$value;"; } $o_string =~ s/\s$//; @@ -2415,7 +2415,7 @@ sub replaceLun { my $o_string = ""; foreach my $attribute (keys %{$attributes}) { my $value = $$attributes{$attribute}; - $o_string .= "$attribute=$value; "; + $o_string .= "$attribute=$value;"; } $o_string =~ s/\s$//; @@ -4135,7 +4135,7 @@ sub openDevice { my $o_string = ""; foreach my $attribute (keys %{$attributes}) { my $value = $$attributes{$attribute}; - $o_string .= "$attribute=$value; "; + $o_string .= "$attribute=$value;"; } $o_string =~ s/\s$//; From 957b51a997d424e4c670f2677a73d152c6308cf7 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 18:35:34 +0000 Subject: [PATCH 039/121] scstadmin, FC: By default, do not issue LIP. Add option -lip. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6735 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/scstadmin.sysfs/scstadmin | 278 ++++++++++++++++++++++------ 1 file changed, 220 insertions(+), 58 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 4a5b4556c..fc908f6c7 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -204,8 +204,10 @@ Target Driver Operations -issue_lip [] [-driver ] : Issue a LIP for a specific driver/target or for all drivers and targets. - -no_lip : Don\'t automatically issue a LIP after applying + -lip : Issue a LIP after having applied FC configuration changes. + -no_lip : Don\'t automatically issue a LIP after having + applied FC configuration changes. Options -nonkey : When writing a config file or listing attributes, @@ -349,6 +351,7 @@ sub getArgs { my $enableTarget; my $disableTarget; my $issueLip; + my $lip; my $noLip; my $handler; @@ -444,6 +447,7 @@ sub getArgs { 'enable_target=s' => \$enableTarget, 'disable_target=s' => \$disableTarget, 'issue_lip:s' => \$issueLip, + 'lip' => \$lip, 'no_lip' => \$noLip, 'handler=s' => \$handler, @@ -478,9 +482,10 @@ sub getArgs { $_NOPROMPT_ = TRUE if (defined($_NOPROMPT_)); $_CONT_ON_ERR_ = TRUE if (defined($_CONT_ON_ERR_)); - $force = TRUE if (defined($force)); + $force = TRUE if (defined($force)); $nonkey = TRUE if (defined($nonkey)); - $noLip = TRUE if (defined($noLip)); + $lip = TRUE if (defined($lip)); + $noLip = TRUE if (defined($noLip)); my $query_mode = defined($listHandler) || defined($listDevice) || defined($listDeviceGroup) || defined($listTargetGroup) || defined($listDriver) || defined($listTarget) || defined($listGroup) || defined($listSessions) || @@ -707,25 +712,104 @@ sub getArgs { } } - return ($applyConfig, $clearConfig, $writeConfig, $checkConfig, - $listScstAttr, $listHandler, $listDevice, $listDeviceGroup, $listTargetGroup, $listDriver, $listTarget, $listGroup, - $listSessions, $listHandlerAttr, $listDeviceAttr, $listDriverAttr, $listTargetAttr, - $listDeviceGroupAttr, $listTargetGroupAttr, $listTargetGroupTargetAttr, - $listGroupAttr, $listLunAttr, $listInitiatorAttr, $setScstAttr, $setHandlerAttr, - $setDeviceAttr, $setDriverAttr, $setTargetAttr, $setGroupAttr, $setLunAttr, $setInitiatorAttr, - $setDeviceGroupAttr, $setTargetGroupAttr, $setTargetGroupTargetAttr, - $addDriverAttr, $addTargetAttr, $remDriverAttr, $remTargetAttr, - $openDev, $closeDev, $resyncDev, - $addDevGroup, $removeDevGroup, $addDevGroupDevice, $removeDevGroupDevice, - $addTargetGroup, $removeTargetGroup, $addTargetGroupTarget, $removeTargetGroupTarget, - $addTarget, $removeTarget, - $addGroup, $removeGroup, - $addInitiator, $removeInitiator, $moveInitiator, $clearInitiators, - $addLun, $removeLun, $replaceLun, $clearLuns, - $enableTarget, $disableTarget, $issueLip, $noLip, - $handler, \%_attributes, - $driver, $target, $group, $to, $device,, $deviceGroup, $targetGroup, - $nonkey, $force); + my %args = ( + applyConfig => $applyConfig, + clearConfig => $clearConfig, + writeConfig => $writeConfig, + checkConfig => $checkConfig, + + listScstAttr => $listScstAttr, + listHandler => $listHandler, + listDevice => $listDevice, + listDeviceGroup => $listDeviceGroup, + listTargetGroup => $listTargetGroup, + listDriver => $listDriver, + listTarget => $listTarget, + listGroup => $listGroup, + + listSessions => $listSessions, + listHandlerAttr => $listHandlerAttr, + listDeviceAttr => $listDeviceAttr, + listDriverAttr => $listDriverAttr, + listTargetAttr => $listTargetAttr, + + listDeviceGroupAttr => $listDeviceGroupAttr, + listTargetGroupAttr => $listTargetGroupAttr, + listTargetGroupTargetAttr => $listTargetGroupTargetAttr, + + listGroupAttr => $listGroupAttr, + listLunAttr => $listLunAttr, + listInitiatorAttr => $listInitiatorAttr, + setScstAttr => $setScstAttr, + setHandlerAttr => $setHandlerAttr, + + setDeviceAttr => $setDeviceAttr, + setDriverAttr => $setDriverAttr, + setTargetAttr => $setTargetAttr, + setGroupAttr => $setGroupAttr, + setLunAttr => $setLunAttr, + setInitiatorAttr => $setInitiatorAttr, + + setDeviceGroupAttr => $setDeviceGroupAttr, + setTargetGroupAttr => $setTargetGroupAttr, + setTargetGroupTargetAttr => $setTargetGroupTargetAttr, + + addDriverAttr => $addDriverAttr, + addTargetAttr => $addTargetAttr, + remDriverAttr => $remDriverAttr, + remTargetAttr => $remTargetAttr, + + openDev => $openDev, + closeDev => $closeDev, + resyncDev => $resyncDev, + + addDevGroup => $addDevGroup, + removeDevGroup => $removeDevGroup, + addDevGroupDevice => $addDevGroupDevice, + removeDevGroupDevice => $removeDevGroupDevice, + + addTargetGroup => $addTargetGroup, + removeTargetGroup => $removeTargetGroup, + addTargetGroupTarget => $addTargetGroupTarget, + removeTargetGroupTarget => $removeTargetGroupTarget, + + addTarget => $addTarget, + removeTarget => $removeTarget, + + addGroup => $addGroup, + removeGroup => $removeGroup, + + addInitiator => $addInitiator, + removeInitiator => $removeInitiator, + moveInitiator => $moveInitiator, + clearInitiators => $clearInitiators, + + addLun => $addLun, + removeLun => $removeLun, + replaceLun => $replaceLun, + clearLuns => $clearLuns, + + enableTarget => $enableTarget, + disableTarget => $disableTarget, + issueLip => $issueLip, + lip => $lip, + noLip => $noLip, + + handler => $handler, + attributes => \%_attributes, + + driver => $driver, + target => $target, + group => $group, + to => $to, + device => $device, + deviceGroup => $deviceGroup, + targetGroup => $targetGroup, + + nonkey => $nonkey, + force => $force, + ); + return \%args; } sub main { @@ -736,25 +820,103 @@ sub main { # We need to run as root if ( $> ) {die("This program must run as root.\n");} - my ($applyConfig, $clearConfig, $writeConfig, $checkConfig, - $listScstAttr, $listHandler, $listDevice, $listDeviceGroup, $listTargetGroup, $listDriver, $listTarget, $listGroup, - $listSessions, $listHandlerAttr, $listDeviceAttr, $listDriverAttr, $listTargetAttr, - $listDeviceGroupAttr, $listTargetGroupAttr, $listTargetGroupTargetAttr, - $listGroupAttr, $listLunAttr, $listInitiatorAttr, $setScstAttr, $setHandlerAttr, - $setDeviceAttr, $setDriverAttr, $setTargetAttr, $setGroupAttr, $setLunAttr, $setInitiatorAttr, - $setDeviceGroupAttr, $setTargetGroupAttr, $setTargetGroupTargetAttr, - $addDriverAttr, $addTargetAttr, $remDriverAttr, $remTargetAttr, - $openDev, $closeDev, $resyncDev, - $addDevGroup, $removeDevGroup, $addDevGroupDevice, $removeDevGroupDevice, - $addTargetGroup, $removeTargetGroup, $addTargetGroupTarget, $removeTargetGroupTarget, - $addTarget, $removeTarget, - $addGroup, $removeGroup, - $addInitiator, $removeInitiator, $moveInitiator, $clearInitiators, - $addLun, $removeLun, $replaceLun, $clearLuns, - $enableTarget, $disableTarget, $issueLip, $noLip, - $handler, $attributes, - $driver, $target, $group, $to, $device, $deviceGroup, $targetGroup, - $nonkey, $force) = getArgs(); + my $args = getArgs(); + + my $applyConfig = $args->{applyConfig}; + my $clearConfig = $args->{clearConfig}; + my $writeConfig = $args->{writeConfig}; + my $checkConfig = $args->{checkConfig}; + + my $listScstAttr = $args->{listScstAttr}; + my $listHandler = $args->{listHandler}; + my $listDevice = $args->{listDevice}; + my $listDeviceGroup = $args->{listDeviceGroup}; + my $listTargetGroup = $args->{listTargetGroup}; + my $listDriver = $args->{listDriver}; + my $listTarget = $args->{listTarget}; + my $listGroup = $args->{listGroup}; + + my $listSessions = $args->{listSessions}; + my $listHandlerAttr = $args->{listHandlerAttr}; + my $listDeviceAttr = $args->{listDeviceAttr}; + my $listDriverAttr = $args->{listDriverAttr}; + my $listTargetAttr = $args->{listTargetAttr}; + + my $listDeviceGroupAttr = $args->{listDeviceGroupAttr}; + my $listTargetGroupAttr = $args->{listTargetGroupAttr}; + my $listTargetGroupTargetAttr = $args->{listTargetGroupTargetAttr}; + + my $listGroupAttr = $args->{listGroupAttr}; + my $listLunAttr = $args->{listLunAttr}; + my $listInitiatorAttr = $args->{listInitiatorAttr}; + my $setScstAttr = $args->{setScstAttr}; + my $setHandlerAttr = $args->{setHandlerAttr}; + + my $setDeviceAttr = $args->{setDeviceAttr}; + my $setDriverAttr = $args->{setDriverAttr}; + my $setTargetAttr = $args->{setTargetAttr}; + my $setGroupAttr = $args->{setGroupAttr}; + my $setLunAttr = $args->{setLunAttr}; + my $setInitiatorAttr = $args->{setInitiatorAttr}; + + my $setDeviceGroupAttr = $args->{setDeviceGroupAttr}; + my $setTargetGroupAttr = $args->{setTargetGroupAttr}; + my $setTargetGroupTargetAttr = $args->{setTargetGroupTargetAttr}; + + my $addDriverAttr = $args->{addDriverAttr}; + my $addTargetAttr = $args->{addTargetAttr}; + my $remDriverAttr = $args->{remDriverAttr}; + my $remTargetAttr = $args->{remTargetAttr}; + + my $openDev = $args->{openDev}; + my $closeDev = $args->{closeDev}; + my $resyncDev = $args->{resyncDev}; + + my $addDevGroup = $args->{addDevGroup}; + my $removeDevGroup = $args->{removeDevGroup}; + my $addDevGroupDevice = $args->{addDevGroupDevice}; + my $removeDevGroupDevice = $args->{removeDevGroupDevice}; + + my $addTargetGroup = $args->{addTargetGroup}; + my $removeTargetGroup = $args->{removeTargetGroup}; + my $addTargetGroupTarget = $args->{addTargetGroupTarget}; + my $removeTargetGroupTarget = $args->{removeTargetGroupTarget}; + + my $addTarget = $args->{addTarget}; + my $removeTarget = $args->{removeTarget}; + + my $addGroup = $args->{addGroup}; + my $removeGroup = $args->{removeGroup}; + + my $addInitiator = $args->{addInitiator}; + my $removeInitiator = $args->{removeInitiator}; + my $moveInitiator = $args->{moveInitiator}; + my $clearInitiators = $args->{clearInitiators}; + + my $addLun = $args->{addLun}; + my $removeLun = $args->{removeLun}; + my $replaceLun = $args->{replaceLun}; + my $clearLuns = $args->{clearLuns}; + + my $enableTarget = $args->{enableTarget}; + my $disableTarget = $args->{disableTarget}; + my $issueLip = $args->{issueLip}; + my $lip = $args->{lip}; + my $noLip = $args->{noLip}; + + my $handler = $args->{handler}; + my $attributes = $args->{attributes}; + + my $driver = $args->{driver}; + my $target = $args->{target}; + my $group = $args->{group}; + my $to = $args->{to}; + my $device = $args->{device}; + my $deviceGroup = $args->{deviceGroup}; + my $targetGroup = $args->{targetGroup}; + + my $nonkey = $args->{nonkey}; + my $force = $args->{force}; $SCST = new SCST::SCST($_DEBUG_); @@ -770,7 +932,7 @@ sub main { condExit("Configuration has errors, aborting.") if ($rc); last if ($force && prompt()); my $changes = applyConfiguration($force); - $rc = issueLip() if ($changes && !$noLip); + $rc = issueLip() if ($changes && $lip); last SWITCH; }; defined($checkConfig) && do { @@ -786,7 +948,7 @@ sub main { defined($clearConfig) && do { last if (prompt()); $rc = clearConfiguration(); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); last SWITCH; }; defined($listHandler) && do { @@ -945,14 +1107,14 @@ sub main { defined($addDriverAttr) && do { print "\n-> Making requested changes.\n"; $rc = addDriverDynamicAttributes($addDriverAttr, $attributes); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; defined($addTargetAttr) && do { print "\n-> Making requested changes.\n"; $rc = addTargetDynamicAttributes($driver, $addTargetAttr, $attributes); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -960,7 +1122,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeDriverDynamicAttributes($remDriverAttr, $attributes); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -968,7 +1130,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeTargetDynamicAttributes($driver, $remTargetAttr, $attributes); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -982,14 +1144,14 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = closeDevice($handler, $closeDev, $force); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; defined($resyncDev) && do { print "\n-> Making requested changes.\n"; $rc = resyncDevice($resyncDev); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1051,7 +1213,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeVirtualTarget($driver, $removeTarget); - $rc = issueLip($driver) if (!$rc && !$noLip); + $rc = issueLip($driver) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1071,7 +1233,7 @@ sub main { defined($addInitiator) && do { print "\n-> Making requested changes.\n"; $rc = addInitiator($driver, $target, $group, $addInitiator); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1079,7 +1241,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeInitiator($driver, $target, $group, $removeInitiator); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1087,7 +1249,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = moveInitiator($driver, $target, $group, $moveInitiator, $to); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1095,14 +1257,14 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = clearInitiators($driver, $target, $group); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; defined($addLun) && do { print "\n-> Making requested changes.\n"; $rc = addLun($driver, $target, $device, $addLun, $attributes, $group); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1110,7 +1272,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeLun($driver, $target, $removeLun, $group); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1118,7 +1280,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = replaceLun($driver, $target, $group, $replaceLun, $device, $attributes); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1126,7 +1288,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = clearLuns($driver, $target, $group); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; From d25d044b3f1f82fa97c6af9c7190ed395d9b6edf Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 20:03:09 +0000 Subject: [PATCH 040/121] scstadmin: Fix SCST/SCST.pm path git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6736 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/scstadmin.sysfs/Makefile | 6 ++++-- scstadmin/scstadmin.sysfs/scstadmin | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/Makefile b/scstadmin/scstadmin.sysfs/Makefile index e9c01f486..d86e3df78 100644 --- a/scstadmin/scstadmin.sysfs/Makefile +++ b/scstadmin/scstadmin.sysfs/Makefile @@ -13,14 +13,16 @@ install install_vendor: all $(MAKE) -C scst-$(MODULE_VERSION) $@ DESTDIR=$(DESTDIR) install -d $(DESTDIR)$(SBINDIR) install -m 755 $(TOOL) $(DESTDIR)$(SBINDIR) + regex="s|%INSTALLSITELIB%|$$(make -sC scst-$(MODULE_VERSION) print-INSTALLSITELIB | grep -v ^make)|"; echo "$${regex}"; sed -i "$${regex}" $(DESTDIR)$(SBINDIR)/$(TOOL) uninstall: -rm -f $(DESTDIR)$(SBINDIR)/$(TOOL) $(MAKE) -C scst-$(MODULE_VERSION) uninstall perl-module: - @cd ./scst-$(MODULE_VERSION); \ - perl Makefile.PL PREFIX=$(PREFIX); + @cd ./scst-$(MODULE_VERSION) && \ + perl Makefile.PL PREFIX=$(PREFIX) && \ + printf '\nprint-%%:\n\t@echo '"'"'$$($$*)'"'"'\n' >> Makefile $(MAKE) -C scst-$(MODULE_VERSION) test: diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index fc908f6c7..fc5b1b3c1 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -242,12 +242,27 @@ Examples: EndUsage } +use strict; +use Cwd qw(abs_path); +use File::Basename; +use File::Spec; +use Test; + +BEGIN { + my $site_lib = '%INSTALLSITELIB%'; + if ($site_lib =~ '^%') { + my $scstadmindir = dirname(abs_path($0)); + $site_lib = File::Spec->catdir($scstadmindir, "scst-0.9.10", + "blib", "lib"); + } + unshift(@INC, $site_lib); +} + use SCST::SCST 0.9.10; use Getopt::Long; use IO::File; use IO::Dir; use POSIX; -use strict; my $_DEF_CONFIG_ = '/etc/scst.conf'; From ed118eb69e9ffeb50db561503d25255315f6a31e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 22:39:55 +0000 Subject: [PATCH 041/121] scstadmin: Fix regression test 7 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6737 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- .../scst-0.9.10/t/07-result.conf | 24 +++++++++++++++++++ .../scst-0.9.10/t/07-scstadmin-args.t | 22 +++++++++++++---- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-result.conf b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-result.conf index d11c5f262..8bee55a95 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-result.conf +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-result.conf @@ -1,9 +1,33 @@ # Automatically generated by SCST Configurator v... +HANDLER vdisk_fileio { + DEVICE disk0 { + filename /dev/scstadmin-regression-test-vdisk + read_only 1 + } + + DEVICE disk1 { + filename /dev/scstadmin-regression-test-vdisk + nv_cache 1 + } +} + +HANDLER vdisk_nullio { + DEVICE nodev { + dummy 1 + } +} + TARGET_DRIVER scst_local { TARGET local { + LUN 0 nodev + GROUP ig { + LUN 0 disk0 { + read_only 1 + } + LUN 1 disk1 INITIATOR ini1 diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-scstadmin-args.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-scstadmin-args.t index accea98f5..352481b90 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-scstadmin-args.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-scstadmin-args.t @@ -11,8 +11,7 @@ my $scstadmin_pm_dir; my $scstadmin_dir; my $scstadmin; my $redirect_file = "/tmp/07-output.txt"; -my $redirect = ">>$redirect_file"; -my $redirect = ">/dev/null"; +my $redirect; BEGIN { unlink($redirect_file); @@ -36,6 +35,11 @@ sub setup { my ($drivers, $errorString) = $SCST->drivers(); my %drivers = map { $_ => 1 } @{$drivers}; ok(exists($drivers{'scst_local'})); + system("dd if=/dev/zero of=/dev/scstadmin-regression-test-vdisk bs=1M count=1 >/dev/null 2>&1"); +} + +sub teardown { + system("rm -f /dev/scstadmin-regression-test-vdisk"); } sub attributeTest { @@ -48,9 +52,9 @@ sub attributeTest { "scstadmin-test-07-$$-diff"); system("$scstadmin -clear_config -force -noprompt -no_lip $redirect"); - system("$scstadmin -open_dev nodev -handler vdisk_nullio -attributes dummy=1,read_zero=1 $redirect"); - system("$scstadmin -open_dev disk0 -handler vdisk_fileio -attributes filename=/dev/zero,read_only=1 $redirect"); - system("$scstadmin -open_dev disk1 -handler vdisk_fileio -attributes filename=/dev/zero,nv_cache=1 $redirect"); + system("$scstadmin -open_dev nodev -handler vdisk_nullio -attributes dummy=1 $redirect"); + system("$scstadmin -open_dev disk0 -handler vdisk_fileio -attributes filename=/dev/scstadmin-regression-test-vdisk,read_only=1 $redirect"); + system("$scstadmin -open_dev disk1 -handler vdisk_fileio -attributes filename=/dev/scstadmin-regression-test-vdisk,nv_cache=1 $redirect"); system("$scstadmin -driver scst_local -add_target local $redirect"); system("$scstadmin -driver scst_local -target local " . "-add_lun 0 -device nodev $redirect"); @@ -75,6 +79,13 @@ sub attributeTest { } my $_DEBUG_ = 0; +if ($_DEBUG_) { + $redirect = ">>$redirect_file"; + open(my $logfile, '>>', $redirect_file); + select $logfile; +} else { + $redirect = ">/dev/null"; +} my $SCST = eval { new SCST::SCST($_DEBUG_) }; die("Creation of SCST object failed") if (!defined($SCST)); @@ -83,3 +94,4 @@ setup($SCST); attributeTest(File::Spec->catfile($testdir, "07-result.conf")); +teardown(); From b3dcab787a53df3c2d78ad08d7417e3777642f21 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 22:44:23 +0000 Subject: [PATCH 042/121] scstadmin: Bump SCST.pm version number from 0.9.10 to 1.0.0 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6738 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/scstadmin.sysfs/Makefile | 2 +- .../scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/MANIFEST | 0 .../scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/Makefile.PL | 0 scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/README | 0 .../{scst-0.9.10 => scst-1.0.0}/lib/SCST/SCST.pm | 2 +- .../{scst-0.9.10 => scst-1.0.0}/t/01-start-scst.t | 0 .../{scst-0.9.10 => scst-1.0.0}/t/02-scst-attr.t | 0 .../{scst-0.9.10 => scst-1.0.0}/t/03-targets.t | 0 .../scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/04-alua.t | 0 .../{scst-0.9.10 => scst-1.0.0}/t/05-dynattr.t | 0 .../{scst-0.9.10 => scst-1.0.0}/t/06-after-restore.conf | 0 .../{scst-0.9.10 => scst-1.0.0}/t/06-cont-on-err.t | 0 .../{scst-0.9.10 => scst-1.0.0}/t/06-to-be-restored.conf | 0 .../{scst-0.9.10 => scst-1.0.0}/t/07-result.conf | 0 .../{scst-0.9.10 => scst-1.0.0}/t/07-scstadmin-args.t | 0 .../{scst-0.9.10 => scst-1.0.0}/t/99-stop-scst.t | 0 scstadmin/scstadmin.sysfs/scstadmin | 4 ++-- 17 files changed, 4 insertions(+), 4 deletions(-) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/MANIFEST (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/Makefile.PL (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/README (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/lib/SCST/SCST.pm (99%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/01-start-scst.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/02-scst-attr.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/03-targets.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/04-alua.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/05-dynattr.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/06-after-restore.conf (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/06-cont-on-err.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/06-to-be-restored.conf (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/07-result.conf (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/07-scstadmin-args.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/99-stop-scst.t (100%) diff --git a/scstadmin/scstadmin.sysfs/Makefile b/scstadmin/scstadmin.sysfs/Makefile index d86e3df78..c728831ec 100644 --- a/scstadmin/scstadmin.sysfs/Makefile +++ b/scstadmin/scstadmin.sysfs/Makefile @@ -2,7 +2,7 @@ ifndef PREFIX PREFIX=/usr/local endif -MODULE_VERSION = 0.9.10 +MODULE_VERSION = 1.0.0 TOOL = scstadmin SBINDIR := $(PREFIX)/sbin diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/MANIFEST b/scstadmin/scstadmin.sysfs/scst-1.0.0/MANIFEST similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/MANIFEST rename to scstadmin/scstadmin.sysfs/scst-1.0.0/MANIFEST diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/Makefile.PL b/scstadmin/scstadmin.sysfs/scst-1.0.0/Makefile.PL similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/Makefile.PL rename to scstadmin/scstadmin.sysfs/scst-1.0.0/Makefile.PL diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/README b/scstadmin/scstadmin.sysfs/scst-1.0.0/README similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/README rename to scstadmin/scstadmin.sysfs/scst-1.0.0/README diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm similarity index 99% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm rename to scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm index e5c8a2d55..6bef8619b 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm @@ -289,7 +289,7 @@ use vars qw(@ISA @EXPORT $VERSION); use vars qw($TGT_TYPE_HARDWARE $TGT_TYPE_VIRTUAL); -$VERSION = '0.9.10'; +$VERSION = '1.0.0'; $TGT_TYPE_HARDWARE = 1; $TGT_TYPE_VIRTUAL = 2; diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/01-start-scst.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/01-start-scst.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/02-scst-attr.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/02-scst-attr.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/02-scst-attr.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/02-scst-attr.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/03-targets.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/03-targets.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/04-alua.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/04-alua.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/05-dynattr.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/05-dynattr.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-after-restore.conf b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-after-restore.conf similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-after-restore.conf rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-after-restore.conf diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-cont-on-err.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-cont-on-err.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-to-be-restored.conf b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-to-be-restored.conf similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-to-be-restored.conf rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-to-be-restored.conf diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-result.conf b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-result.conf similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-result.conf rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-result.conf diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-scstadmin-args.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/07-scstadmin-args.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/99-stop-scst.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/99-stop-scst.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/99-stop-scst.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/99-stop-scst.t diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index fc5b1b3c1..b6bac0e8d 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -252,13 +252,13 @@ BEGIN { my $site_lib = '%INSTALLSITELIB%'; if ($site_lib =~ '^%') { my $scstadmindir = dirname(abs_path($0)); - $site_lib = File::Spec->catdir($scstadmindir, "scst-0.9.10", + $site_lib = File::Spec->catdir($scstadmindir, "scst-1.0.0", "blib", "lib"); } unshift(@INC, $site_lib); } -use SCST::SCST 0.9.10; +use SCST::SCST 1.0.0; use Getopt::Long; use IO::File; use IO::Dir; From 7eb874c3bafa3cca1945d6f40a5d3b3c7f86c48e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 23:44:27 +0000 Subject: [PATCH 043/121] isert-scst: RHEL 7.2 build fix git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6739 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/Makefile | 5 ++++- iscsi-scst/conftest/create_cq/Makefile | 3 +++ iscsi-scst/conftest/create_cq/create_cq.c | 13 +++++++++++++ iscsi-scst/kernel/isert-scst/iser_rdma.c | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 iscsi-scst/conftest/create_cq/Makefile create mode 100644 iscsi-scst/conftest/create_cq/create_cq.c diff --git a/iscsi-scst/Makefile b/iscsi-scst/Makefile index 1df57d882..d1969de05 100644 --- a/iscsi-scst/Makefile +++ b/iscsi-scst/Makefile @@ -100,12 +100,15 @@ else endif endif +CREATE_CQ_FLAG = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/create_cq PRE_CFLAGS="$(OFED_CFLAGS) -Werror" >/dev/null 2>&1 && echo -DIB_CREATE_CQ_HAS_INIT_ATTR) +PRE_CFLAGS=$(OFED_CFLAGS) $(CREATE_CQ_FLAG) -DOFED_FLAVOR=$(OFED_FLAVOR) + mods: Modules.symvers Module.symvers $(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(KMOD) modules if $(INFINIBAND_ENABLED); then \ echo " Building against $(OFED_FLAVOR) InfiniBand kernel headers."; \ $(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(ISERTMOD) \ - PRE_CFLAGS="$(OFED_CFLAGS) -DOFED_FLAVOR=$(OFED_FLAVOR)" \ + PRE_CFLAGS="$(PRE_CFLAGS)" \ KBUILD_EXTRA_SYMBOLS=$(ISER_SYMVERS) modules; \ fi diff --git a/iscsi-scst/conftest/create_cq/Makefile b/iscsi-scst/conftest/create_cq/Makefile new file mode 100644 index 000000000..d7ada9b0a --- /dev/null +++ b/iscsi-scst/conftest/create_cq/Makefile @@ -0,0 +1,3 @@ +LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE) + +obj-m += create_cq.o diff --git a/iscsi-scst/conftest/create_cq/create_cq.c b/iscsi-scst/conftest/create_cq/create_cq.c new file mode 100644 index 000000000..86fce929e --- /dev/null +++ b/iscsi-scst/conftest/create_cq/create_cq.c @@ -0,0 +1,13 @@ +#include +#include + +static int modinit(void) +{ + struct ib_cq *q; + + q = ib_create_cq(NULL, NULL, NULL, NULL, NULL); + + return q != 0; +} + +module_init(modinit); diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index 08050a221..3b48f5bea 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -963,7 +963,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev) goto fail_cq; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) +#ifndef IB_CREATE_CQ_HAS_INIT_ATTR cq = ib_create_cq(ib_dev, isert_cq_comp_handler, isert_async_evt_handler, From 034f8bc3f1755b30f8c79ff2471f564b0c659a92 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 12 Dec 2015 16:02:37 +0000 Subject: [PATCH 044/121] isert-scst: Unbreak nightly build git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6740 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/isert-scst/iser_rdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index 3b48f5bea..499a941fe 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -963,7 +963,8 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev) goto fail_cq; } -#ifndef IB_CREATE_CQ_HAS_INIT_ATTR +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) && \ + !defined(IB_CREATE_CQ_HAS_INIT_ATTR) cq = ib_create_cq(ib_dev, isert_cq_comp_handler, isert_async_evt_handler, From fa45db4caf6ed6bcc94788b0d2117f3ae3125765 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 16 Dec 2015 08:41:09 +0000 Subject: [PATCH 045/121] scst, procfs: Fix two section mismatches git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6741 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index 0ade29717..f6415bcee 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -1110,7 +1110,7 @@ static int __init scst_proc_init_sgv(void) return res; } -static void __exit scst_proc_cleanup_sgv(void) +static void scst_proc_cleanup_sgv(void) { TRACE_ENTRY(); remove_proc_entry("sgv", scst_proc_scsi_tgt); @@ -1217,7 +1217,7 @@ out_nomem: goto out; } -void __exit scst_proc_cleanup_module(void) +void scst_proc_cleanup_module(void) { TRACE_ENTRY(); From df2a2ac1ab12d61309b82624966df8e529624499 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 16 Dec 2015 08:44:04 +0000 Subject: [PATCH 046/121] iscsi-scst, procfs: Fix a compiler warning Avoid that the compiler warns that attr_info is not used in the procfs build. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6742 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/target.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iscsi-scst/kernel/target.c b/iscsi-scst/kernel/target.c index 7a3e0a546..b246e0d7a 100644 --- a/iscsi-scst/kernel/target.c +++ b/iscsi-scst/kernel/target.c @@ -128,7 +128,6 @@ int __add_target(struct iscsi_kern_target_info *info) int err; u32 tid = info->tid; struct iscsi_target *target = NULL; /* to calm down sparse */ - struct iscsi_kern_attr *attr_info; union add_info_union { struct iscsi_kern_params_info params_info; struct iscsi_kern_attr attr_info; @@ -165,7 +164,6 @@ int __add_target(struct iscsi_kern_target_info *info) err = -ENOMEM; goto out; } - attr_info = (struct iscsi_kern_attr *)add_info; if (tid == 0) { do { @@ -183,6 +181,9 @@ int __add_target(struct iscsi_kern_target_info *info) nr_targets++; #ifndef CONFIG_SCST_PROC + { + struct iscsi_kern_attr *attr_info = &add_info->attr_info; + mutex_lock(&target->target_mutex); attrs_ptr_long = info->attrs_ptr; @@ -208,6 +209,7 @@ int __add_target(struct iscsi_kern_target_info *info) } mutex_unlock(&target->target_mutex); + } #endif err = tid; From 44901a0a11508242d27f08bcf46619d61eae36fa Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 17 Dec 2015 07:07:01 +0000 Subject: [PATCH 047/121] scst: Fix write-protected response From SBC-4: "If present, any write protection shall cause otherwise valid logical block access commands that request alteration of the medium to be terminated by the device server with CHECK CONDITION status with the sense key set to DATA PROTECT and the appropriate additional sense code for the condition." Hence set the additional sense code in responses to SCSI commands sent to read-only LUNs. Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6743 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst_const.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index caa54728c..a1e93f602 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -341,7 +341,7 @@ static inline int scst_sense_response_code(const uint8_t *sense) #define scst_sense_reported_luns_data_changed UNIT_ATTENTION, 0x3F, 0xE /* DATA_PROTECT is 7 */ -#define scst_sense_data_protect DATA_PROTECT, 0x00, 0 +#define scst_sense_data_protect DATA_PROTECT, 0x27, 0 /* ABORTED_COMMAND is 0xb */ #define scst_sense_aborted_command ABORTED_COMMAND, 0x00, 0 From 0553954a79b08a0c3c98c6e09755a16eb6ed0954 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 17 Dec 2015 16:10:53 +0000 Subject: [PATCH 048/121] nightly build: Update kernel versions git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6763 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- nightly/conf/nightly.conf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 67abb86e4..00b881921 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -3,26 +3,26 @@ ABT_DETAILS="x86_64" ABT_JOBS=5 ABT_KERNELS=" \ -4.3 \ -4.2.6-nc \ -4.1.13-nc \ +4.3.3 \ +4.2.8-nc \ +4.1.15-nc \ 4.0.9-nc \ -3.19.7-nc \ -3.18.24-nc \ +3.19.8-nc \ +3.18.25-nc \ 3.17.8-nc \ 3.16.7-nc \ 3.15.10-nc \ -3.14.57-nc \ +3.14.58-nc \ 3.13.11-nc \ 3.12.51-nc \ 3.11.10-nc \ -3.10.93-nc \ +3.10.94-nc \ 3.9.11-nc \ 3.8.13-nc \ 3.7.10-nc \ 3.6.11-nc \ 3.5.7-nc \ -3.4.108-nc \ +3.4.110-nc \ 3.3.8-nc \ 3.2.74-nc \ 3.1.10-nc \ From 41434a99054eb7f0b72194543cf84fc554aa4ae8 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Dec 2015 11:05:20 +0000 Subject: [PATCH 049/121] scstadmin: Suppress warnings about the use of an undefined value in numeric ne (!=) git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6768 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm index 6bef8619b..5fca60f2e 100644 --- a/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm @@ -929,7 +929,7 @@ sub driverExists { opendir($dHandle, make_path(SCST_TARGETS_DIR(), $driver)); close $dHandle if ($result); - return $result; + return $result ? TRUE : FALSE; } sub driverDynamicAttributes { From 39c3b7949799a5a92e07b6fa5cce6b5d352d0530 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Dec 2015 11:39:19 +0000 Subject: [PATCH 050/121] scst regression test 7: Fix $redirect_file initialization git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6769 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- .../scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t index 352481b90..58e149049 100644 --- a/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t @@ -7,17 +7,16 @@ use File::Spec; use Test; my $testdir; -my $scstadmin_pm_dir; -my $scstadmin_dir; my $scstadmin; -my $redirect_file = "/tmp/07-output.txt"; +my $redirect_file; my $redirect; BEGIN { + $redirect_file = "/tmp/07-output.txt"; unlink($redirect_file); $testdir = dirname(abs_path($0)); - $scstadmin_pm_dir = dirname($testdir); - $scstadmin_dir = dirname($scstadmin_pm_dir); + my $scstadmin_pm_dir = dirname($testdir); + my $scstadmin_dir = dirname($scstadmin_pm_dir); $scstadmin = File::Spec->catfile($scstadmin_dir, "scstadmin"); unless(grep /blib/, @INC) { unshift(@INC, File::Spec->catdir($scstadmin_pm_dir, "lib")); From 9294102efe5f528676c59a9c9d4816ed4eae691b Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Dec 2015 12:11:18 +0000 Subject: [PATCH 051/121] scst: Fix a RHEL 6 compiler warning git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6771 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index 8f7c53478..d379b735b 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -367,7 +367,7 @@ int no_printk(const char *s, ...) { return 0; } /* */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) && !defined(kfree_rcu) typedef void (*rcu_callback_t)(struct rcu_head *); #define __is_kfree_rcu_offset(offset) ((offset) < 4096) #define kfree_call_rcu(head, rcb) call_rcu(head, rcb) From 10bc776195c4a1d6fe99741811483d264e12971c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Dec 2015 12:39:16 +0000 Subject: [PATCH 052/121] scst: Fix a procfs compiler warning git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6773 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_priv.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index f0f87d8e3..df240b1fc 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -931,7 +931,11 @@ static inline int scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd) return SCST_EXEC_NOT_COMPLETED; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) +static inline void sess_cm_list_id_cleanup_work_fn(void *p) {} +#else static inline void sess_cm_list_id_cleanup_work_fn(struct work_struct *work) {} +#endif static inline void scst_cm_free_pending_list_ids(struct scst_session *sess) {} static inline bool scst_cm_check_block_all_devs(struct scst_cmd *cmd) { return false; } From 71f004f44c20ddcf1077d78f3b8af187c60fc7ba Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 20 Dec 2015 12:46:16 +0000 Subject: [PATCH 053/121] scst: SLES 12 build fix git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6775 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 2a5599948..4c752e342 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -14401,7 +14401,9 @@ void scst_vfs_unlink_and_put(struct nameidata *nd) void scst_vfs_unlink_and_put(struct path *path) { #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0) && \ - (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 7) + (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 7) && \ + (!defined(CONFIG_SUSE_KERNEL) || \ + LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)) vfs_unlink(path->dentry->d_parent->d_inode, path->dentry); #else vfs_unlink(path->dentry->d_parent->d_inode, path->dentry, NULL); From a06cae9fe6fd4c5200bacbfaf7ff49bca20f9d0b Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 5 Jan 2016 15:27:11 +0000 Subject: [PATCH 054/121] scst_tg: Report that SCST supports the ALUA state "transitioning" Reported-by: Consus git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6777 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_tg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_tg.c b/scst/src/scst_tg.c index 4029fcefb..4c49a7ee9 100644 --- a/scst/src/scst_tg.c +++ b/scst/src/scst_tg.c @@ -1540,7 +1540,8 @@ int scst_tg_get_group_info(void **buf, uint32_t *length, *p++ = SCST_TG_SUP_OPTIMIZED | SCST_TG_SUP_NONOPTIMIZED | SCST_TG_SUP_STANDBY - | SCST_TG_SUP_UNAVAILABLE; + | SCST_TG_SUP_UNAVAILABLE + | SCST_TG_SUP_TRANSITION; put_unaligned_be16(tg->group_id, p); p += 2; p++; /* reserved */ From cf28155105d019b46819131bf3c21d9b597bc532 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 16 Jan 2016 02:42:17 +0000 Subject: [PATCH 055/121] nightly build: Update kernel versions git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6778 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- nightly/conf/nightly.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 00b881921..72756f294 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -3,7 +3,8 @@ ABT_DETAILS="x86_64" ABT_JOBS=5 ABT_KERNELS=" \ -4.3.3 \ +4.4 \ +4.3.3-nc \ 4.2.8-nc \ 4.1.15-nc \ 4.0.9-nc \ From 120e5fb78b32f46e376e5fb06818f19c14a7a3aa Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Jan 2016 18:08:04 +0000 Subject: [PATCH 056/121] nightly build: Add kernel 4.4 support files git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6779 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla2x00-target/Makefile_in-tree-4.4 | 5 +++++ .../in-tree/Kconfig.drivers.Linux-4.4.patch | 13 +++++++++++++ scst/kernel/in-tree/Makefile.dev_handlers-4.4 | 14 ++++++++++++++ .../in-tree/Makefile.drivers.Linux-4.4.patch | 12 ++++++++++++ scst/kernel/in-tree/Makefile.scst-4.4 | 17 +++++++++++++++++ scst_local/in-tree/Makefile-4.4 | 2 ++ 6 files changed, 63 insertions(+) create mode 100644 qla2x00t/qla2x00-target/Makefile_in-tree-4.4 create mode 100644 scst/kernel/in-tree/Kconfig.drivers.Linux-4.4.patch create mode 100644 scst/kernel/in-tree/Makefile.dev_handlers-4.4 create mode 100644 scst/kernel/in-tree/Makefile.drivers.Linux-4.4.patch create mode 100644 scst/kernel/in-tree/Makefile.scst-4.4 create mode 100644 scst_local/in-tree/Makefile-4.4 diff --git a/qla2x00t/qla2x00-target/Makefile_in-tree-4.4 b/qla2x00t/qla2x00-target/Makefile_in-tree-4.4 new file mode 100644 index 000000000..9657aee84 --- /dev/null +++ b/qla2x00t/qla2x00-target/Makefile_in-tree-4.4 @@ -0,0 +1,5 @@ +ccflags-y += -Idrivers/scsi/qla2xxx + +qla2x00tgt-y := qla2x00t.o + +obj-$(CONFIG_SCST_QLA_TGT_ADDON) += qla2x00tgt.o diff --git a/scst/kernel/in-tree/Kconfig.drivers.Linux-4.4.patch b/scst/kernel/in-tree/Kconfig.drivers.Linux-4.4.patch new file mode 100644 index 000000000..39d30a55e --- /dev/null +++ b/scst/kernel/in-tree/Kconfig.drivers.Linux-4.4.patch @@ -0,0 +1,13 @@ +diff --git a/drivers/Kconfig b/drivers/Kconfig +index c70d6e4..0a4ed1b 100644 +--- a/drivers/Kconfig ++++ b/drivers/Kconfig +@@ -26,6 +26,8 @@ source "drivers/ide/Kconfig" + + source "drivers/scsi/Kconfig" + ++source "drivers/scst/Kconfig" ++ + source "drivers/ata/Kconfig" + + source "drivers/md/Kconfig" diff --git a/scst/kernel/in-tree/Makefile.dev_handlers-4.4 b/scst/kernel/in-tree/Makefile.dev_handlers-4.4 new file mode 100644 index 000000000..f933b36f7 --- /dev/null +++ b/scst/kernel/in-tree/Makefile.dev_handlers-4.4 @@ -0,0 +1,14 @@ +ccflags-y += -Wno-unused-parameter + +obj-m := scst_cdrom.o scst_changer.o scst_disk.o scst_modisk.o scst_tape.o \ + scst_vdisk.o scst_raid.o scst_processor.o scst_user.o + +obj-$(CONFIG_SCST_DISK) += scst_disk.o +obj-$(CONFIG_SCST_TAPE) += scst_tape.o +obj-$(CONFIG_SCST_CDROM) += scst_cdrom.o +obj-$(CONFIG_SCST_MODISK) += scst_modisk.o +obj-$(CONFIG_SCST_CHANGER) += scst_changer.o +obj-$(CONFIG_SCST_RAID) += scst_raid.o +obj-$(CONFIG_SCST_PROCESSOR) += scst_processor.o +obj-$(CONFIG_SCST_VDISK) += scst_vdisk.o +obj-$(CONFIG_SCST_USER) += scst_user.o diff --git a/scst/kernel/in-tree/Makefile.drivers.Linux-4.4.patch b/scst/kernel/in-tree/Makefile.drivers.Linux-4.4.patch new file mode 100644 index 000000000..6bbacd12f --- /dev/null +++ b/scst/kernel/in-tree/Makefile.drivers.Linux-4.4.patch @@ -0,0 +1,12 @@ +diff --git a/drivers/Makefile b/drivers/Makefile +index 527a6da..db2c24f 100644 +--- a/drivers/Makefile ++++ b/drivers/Makefile +@@ -137,6 +137,7 @@ obj-$(CONFIG_SSB) += ssb/ + obj-$(CONFIG_BCMA) += bcma/ + obj-$(CONFIG_VHOST_RING) += vhost/ + obj-$(CONFIG_VLYNQ) += vlynq/ ++obj-$(CONFIG_SCST) += scst/ + obj-$(CONFIG_STAGING) += staging/ + obj-y += platform/ + #common clk code diff --git a/scst/kernel/in-tree/Makefile.scst-4.4 b/scst/kernel/in-tree/Makefile.scst-4.4 new file mode 100644 index 000000000..f4e0cc985 --- /dev/null +++ b/scst/kernel/in-tree/Makefile.scst-4.4 @@ -0,0 +1,17 @@ +ccflags-y += -Wno-unused-parameter + +scst-y += scst_copy_mgr.o +scst-y += scst_debug.o +scst-y += scst_dlm.o +scst-y += scst_event.o +scst-y += scst_lib.o +scst-y += scst_main.o +scst-y += scst_mem.o +scst-y += scst_no_dlm.o +scst-y += scst_pres.o +scst-y += scst_sysfs.o +scst-y += scst_targ.o +scst-y += scst_tg.o + +obj-$(CONFIG_SCST) += scst.o dev_handlers/ fcst/ iscsi-scst/ qla2xxx-target/ \ + srpt/ scst_local/ diff --git a/scst_local/in-tree/Makefile-4.4 b/scst_local/in-tree/Makefile-4.4 new file mode 100644 index 000000000..8cbbbff63 --- /dev/null +++ b/scst_local/in-tree/Makefile-4.4 @@ -0,0 +1,2 @@ +obj-$(CONFIG_SCST_LOCAL) += scst_local.o + From 76b1344cd3b706428c2c7c3c482e9c583fbd7a37 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Jan 2016 18:08:36 +0000 Subject: [PATCH 057/121] ib_srpt: Fix in-tree build for kernel v4.4 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6780 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 115175845..eda399d6c 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -694,7 +694,8 @@ static int srpt_refresh_port(struct srpt_port *sport) sport->lid = port_attr.lid; ret = ib_query_gid(sport->sdev->device, sport->port, 0, &sport->gid -#ifdef IB_QUERY_GID_HAS_ATTR_ARG +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) || \ + defined(IB_QUERY_GID_HAS_ATTR_ARG) , NULL #endif ); From c7ed845936e9fe7aa088400e869692c32238176d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 20 Jan 2016 00:35:29 +0000 Subject: [PATCH 058/121] user space code: Fix the code for generating a release archive git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6782 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- usr/events/Makefile | 2 +- usr/fileio/Makefile | 2 +- usr/stpgd/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usr/events/Makefile b/usr/events/Makefile index ffce7d2d7..fa01f6b7f 100644 --- a/usr/events/Makefile +++ b/usr/events/Makefile @@ -97,6 +97,6 @@ extraclean: clean rm Makefile.aa release-archive: - ../../scripts/generate-release-archive events "$$(sed -n 's/^#define[[:blank:]]VERSION_STR[[:blank:]]*\"\([^\"]*\)\".*/\1/p' events.c)" + ../../scripts/generate-release-archive events "$$(sed -n 's/^#define[[:blank:]]VERSION_STR[[:blank:]]*\"\([^\"]*\)\".*/\1/p' ../include/version.h)" .PHONY: all install uninstall clean extraclean 2release 2debug 2perf diff --git a/usr/fileio/Makefile b/usr/fileio/Makefile index b91948369..5daa63b10 100644 --- a/usr/fileio/Makefile +++ b/usr/fileio/Makefile @@ -118,6 +118,6 @@ extraclean: clean rm Makefile.aa release-archive: - ../../scripts/generate-release-archive fileio_tgt "$$(sed -n 's/^#define[[:blank:]]VERSION_STR[[:blank:]]*\"\([^\"]*\)\".*/\1/p' fileio.c)" + ../../scripts/generate-release-archive fileio_tgt "$$(sed -n 's/^#define[[:blank:]]VERSION_STR[[:blank:]]*\"\([^\"]*\)\".*/\1/p' ../include/version.h)" .PHONY: all install uninstall clean extraclean 2release 2debug 2perf diff --git a/usr/stpgd/Makefile b/usr/stpgd/Makefile index 0f8336c95..3fa1e9bc7 100644 --- a/usr/stpgd/Makefile +++ b/usr/stpgd/Makefile @@ -99,6 +99,6 @@ extraclean: clean rm Makefile.aa release-archive: - ../../scripts/generate-release-archive stpgd "$$(sed -n 's/^#define[[:blank:]]VERSION_STR[[:blank:]]*\"\([^\"]*\)\".*/\1/p' stpgd_main.c)" + ../../scripts/generate-release-archive stpgd "$$(sed -n 's/^#define[[:blank:]]VERSION_STR[[:blank:]]*\"\([^\"]*\)\".*/\1/p' ../include/version.h)" .PHONY: all install uninstall clean extraclean 2release 2debug 2perf From 1d3f1ada5af61ddbb82b0e75c2b35a7c1cffa6b8 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 20 Jan 2016 16:40:19 +0000 Subject: [PATCH 059/121] nightly build: Update kernel versions git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6784 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- nightly/conf/nightly.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 72756f294..44ec207ac 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -15,7 +15,7 @@ ABT_KERNELS=" \ 3.15.10-nc \ 3.14.58-nc \ 3.13.11-nc \ -3.12.51-nc \ +3.12.52-nc \ 3.11.10-nc \ 3.10.94-nc \ 3.9.11-nc \ @@ -25,7 +25,7 @@ ABT_KERNELS=" \ 3.5.7-nc \ 3.4.110-nc \ 3.3.8-nc \ -3.2.74-nc \ +3.2.75-nc \ 3.1.10-nc \ 3.0.101-nc \ 2.6.39.4-nc \ From 5968cb4567f1f25a53ed9e001248c337f2c096ab Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 22 Jan 2016 03:08:44 +0000 Subject: [PATCH 060/121] docs: version updated git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6785 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- doc/scst_user_spec.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/scst_user_spec.sgml b/doc/scst_user_spec.sgml index 121e4df97..75f601928 100644 --- a/doc/scst_user_spec.sgml +++ b/doc/scst_user_spec.sgml @@ -10,7 +10,7 @@ SCST user space device handler interface description Vladislav Bolkhovitin -Version 3.0.0 +Version 3.2.0 From 1e75da42890cb1023d62cf9a81f7294f6c97a2df Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 22 Jan 2016 03:54:38 +0000 Subject: [PATCH 061/121] 3.1 release web updates git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6786 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- www/downloads.html | 10 ++-------- www/handler_fileio_tgt.html | 2 +- www/scst_admin.html | 2 +- www/target_fcoe.html | 2 +- www/target_iscsi.html | 2 +- www/target_local.html | 2 +- www/target_qla2x00t.html | 19 ++++++++----------- www/target_srp.html | 4 ++-- 8 files changed, 17 insertions(+), 26 deletions(-) diff --git a/www/downloads.html b/www/downloads.html index 1b842330f..0e40e1772 100644 --- a/www/downloads.html +++ b/www/downloads.html @@ -35,8 +35,8 @@

SCST Downloads

-

The latest stable version of SCST is 3.0.1. The latest updates for it - you can find it in the SVN branch 3.0.x.

+

The latest stable version of SCST is 3.1. The latest updates for it + you can find it in the SVN branch 3.1.x.

You can also download prebuilt SCST modules for Scientific Linux CERN 5 (RHEL5-based), @@ -57,8 +57,6 @@

svn checkout svn://svn.code.sf.net/p/scst/svn/trunk scst-trunk

-

Version 3.1 is currently in the RC features freeze phase and going to be released in the next few weeks. You can download it from 3.1.x branch.

-

Also you can find in the SCST SVN the latest updates for the stable branches. More information about accessing SVN repository may be found here. Or, alternatively, you can download it as a GNU tarball from here.

@@ -86,10 +84,6 @@

fcoe

scst_local

- -

fileio_tgt

- -

doc-src

diff --git a/www/handler_fileio_tgt.html b/www/handler_fileio_tgt.html index b38091767..932d878c3 100644 --- a/www/handler_fileio_tgt.html +++ b/www/handler_fileio_tgt.html @@ -66,7 +66,7 @@ All the words about BLOCKIO mode from SCST's README file apply to O_DIRECT mode as well.

-

The latest stable version is 3.0.1. Requires SCST version 3.0.1 or higher.

+

The latest stable version is 3.1 (as part of the SCST package). Requires SCST version 3.1 or higher.

You can find the latest development version of this handler in the SCST SVN. See the download page how to setup access to it.

-

The latest stable version is 3.0.1.

+

The latest stable version is 3.1.

-

The latest stable version is 3.0.1. You can download the latest development version from the SCST SVN repository. See the download +

The latest stable version is 3.1. You can download the latest development version from the SCST SVN repository. See the download page how to setup access to it.





-

The latest stable version is 3.0.1. Requires Linux kernel version 2.6.18.x or higher and SCST version 3.0.1 or higher. +

The latest stable version is 3.1. Requires Linux kernel version 2.6.18.x or higher and SCST version 3.1 or higher. Tested mostly on i386 and x86_64, but should work on any other supported by Linux platform.

You can find the latest development version of this driver in the SCST SVN. See the download page how to setup access to it.

diff --git a/www/target_local.html b/www/target_local.html index 8ca542423..056ae0726 100644 --- a/www/target_local.html +++ b/www/target_local.html @@ -68,7 +68,7 @@

This driver was made by Richard Sharpe.

-

It is on the beta stage. The latest stabe version is 3.0.1. You can download +

It is on the beta stage. The latest stabe version is 3.1. You can download the latest development version from the SCST SVN repository. See the download page how to setup access to it.




SCST QLogic This is target driver for QLogic qla2xxx (22xx++) Fibre Channel adapters.

-

There are 2 latest stable versions of this driver:

-
    -
  • The first one is 3.0.1. It requires Linux kernel version 2.6.26.x or higher and - SCST version 3.0.1 or higher. Driver in qla2x00t subdirectory is the old one, forked from - qla2xxx from kernel 2.6.26. It does not support 16G QLogic adapters and is not maintained anymore.
  • -
  • Another version you can find in the SVN trunk. This driver supports 16G Hilda QLogic +

    This driver in version 3.1 supports 16G Hilda QLogic chip based adapters (post-Hilda QLogic chips not supported) and has many other important improvements. This driver should also support FCoE, but that has never been verified. It has passed intensive internal SanDisk tests. It is stable and production ready. This driver is in stable maintenance mode in favor of the - QLogic git tree driver (see below). This is the recommended driver to use in production at the moment.

  • -
-

- The latest version of this driver with full support of the latest QLogic chips for both FC and FCoE you can find in - git://git.qlogic.com/scst-qla2xxx.git. This driver also supports T10-PI functionality. + QLogic git tree driver (see below). This is the recommended driver to use in production at the moment. +

+ +

You can find the latest updates for this driver in the SVN trunk.

+ +

The latest QLogic maintained version of this driver with full support of the latest QLogic chips for both FC and FCoE you can find in + git://git.qlogic.com/scst-qla2xxx.git. That version also supports T10-PI functionality. It is maintained by QLogic, hence located in the QLogic's git. See SVN root README for instructions how to integrate it into the SCST build tree. However, not all improvements from the SVN trunk target driver have been integrated in this driver yet, diff --git a/www/target_srp.html b/www/target_srp.html index 09636b6dc..6587678a9 100644 --- a/www/target_srp.html +++ b/www/target_srp.html @@ -61,8 +61,8 @@ It is maintained by Bart Van Assche.

This driver is mainline Linux kernel ready and going to be pushed to it together with other SCST patches.

-

The latest stable version is 3.0.1.

-




+

The latest stable version is 3.1.

+


diff --git a/www/contributing.html b/www/contributing.html index c287ea3ac..e22ba2fbe 100644 --- a/www/contributing.html +++ b/www/contributing.html @@ -209,7 +209,7 @@ diff --git a/www/downloads.html b/www/downloads.html index 0e40e1772..dfcdb0b8d 100644 --- a/www/downloads.html +++ b/www/downloads.html @@ -89,7 +89,7 @@ diff --git a/www/handler_fileio_tgt.html b/www/handler_fileio_tgt.html index 932d878c3..466a9577b 100644 --- a/www/handler_fileio_tgt.html +++ b/www/handler_fileio_tgt.html @@ -78,7 +78,7 @@ diff --git a/www/index.html b/www/index.html index c2444e950..eb7ed83f2 100644 --- a/www/index.html +++ b/www/index.html @@ -185,7 +185,7 @@ diff --git a/www/mc_s.html b/www/mc_s.html index f3b6924ab..ecd2c9510 100644 --- a/www/mc_s.html +++ b/www/mc_s.html @@ -246,7 +246,7 @@ and here. diff --git a/www/scst_admin.html b/www/scst_admin.html index 659a61528..6635cf77f 100644 --- a/www/scst_admin.html +++ b/www/scst_admin.html @@ -77,7 +77,7 @@ diff --git a/www/scstvslio.html b/www/scstvslio.html index c3297b447..734b252c3 100644 --- a/www/scstvslio.html +++ b/www/scstvslio.html @@ -99,7 +99,7 @@ diff --git a/www/scstvsstgt.html b/www/scstvsstgt.html index eaecf1e10..750a9c995 100644 --- a/www/scstvsstgt.html +++ b/www/scstvsstgt.html @@ -79,7 +79,7 @@ diff --git a/www/target_emulex.html b/www/target_emulex.html index f2a908042..cb6d9db99 100644 --- a/www/target_emulex.html +++ b/www/target_emulex.html @@ -80,7 +80,7 @@ diff --git a/www/target_fcoe.html b/www/target_fcoe.html index f49b18fa2..dfcafceb5 100644 --- a/www/target_fcoe.html +++ b/www/target_fcoe.html @@ -75,7 +75,7 @@ diff --git a/www/target_ibmvscsi.html b/www/target_ibmvscsi.html index db9fd1223..b2e04297e 100644 --- a/www/target_ibmvscsi.html +++ b/www/target_ibmvscsi.html @@ -76,7 +76,7 @@ diff --git a/www/target_iscsi.html b/www/target_iscsi.html index c3e929fa8..d0a140385 100644 --- a/www/target_iscsi.html +++ b/www/target_iscsi.html @@ -91,7 +91,7 @@ diff --git a/www/target_local.html b/www/target_local.html index 056ae0726..3ad8add68 100644 --- a/www/target_local.html +++ b/www/target_local.html @@ -84,7 +84,7 @@ diff --git a/www/target_lsi.html b/www/target_lsi.html index f086d30ac..1c7ab6597 100644 --- a/www/target_lsi.html +++ b/www/target_lsi.html @@ -79,7 +79,7 @@ diff --git a/www/target_mvsas.html b/www/target_mvsas.html index 5c552aeb5..967188e6b 100644 --- a/www/target_mvsas.html +++ b/www/target_mvsas.html @@ -73,7 +73,7 @@ diff --git a/www/target_old.html b/www/target_old.html index fec957ddb..fcf09d2fb 100644 --- a/www/target_old.html +++ b/www/target_old.html @@ -109,7 +109,7 @@ diff --git a/www/target_qla2x00t.html b/www/target_qla2x00t.html index 261c15a66..450f17d5f 100644 --- a/www/target_qla2x00t.html +++ b/www/target_qla2x00t.html @@ -89,7 +89,7 @@ diff --git a/www/target_srp.html b/www/target_srp.html index 6587678a9..67aa8b22c 100644 --- a/www/target_srp.html +++ b/www/target_srp.html @@ -76,7 +76,7 @@ diff --git a/www/targets.html b/www/targets.html index b23374e82..2d62d02e1 100644 --- a/www/targets.html +++ b/www/targets.html @@ -76,7 +76,7 @@ diff --git a/www/users.html b/www/users.html index becfc4e4d..16ab12c70 100644 --- a/www/users.html +++ b/www/users.html @@ -159,7 +159,7 @@ From 559d075553457a1661f3be6c6dddd399aaed3420 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 28 Jan 2016 01:21:59 +0000 Subject: [PATCH 063/121] nightly build: Update kernel versions git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6789 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- nightly/conf/nightly.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 44ec207ac..17092a33c 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -4,20 +4,20 @@ ABT_DETAILS="x86_64" ABT_JOBS=5 ABT_KERNELS=" \ 4.4 \ -4.3.3-nc \ +4.3.4-nc \ 4.2.8-nc \ -4.1.15-nc \ +4.1.16-nc \ 4.0.9-nc \ 3.19.8-nc \ 3.18.25-nc \ 3.17.8-nc \ 3.16.7-nc \ 3.15.10-nc \ -3.14.58-nc \ +3.14.59-nc \ 3.13.11-nc \ 3.12.52-nc \ 3.11.10-nc \ -3.10.94-nc \ +3.10.95-nc \ 3.9.11-nc \ 3.8.13-nc \ 3.7.10-nc \ From 8b4a1cc3ff4dd18127160de542c80e721ae1ff3e Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 28 Jan 2016 04:07:06 +0000 Subject: [PATCH 064/121] Web updates git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6790 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- www/users.html | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/www/users.html b/www/users.html index 16ab12c70..b46609c6c 100644 --- a/www/users.html +++ b/www/users.html @@ -98,32 +98,34 @@ Oracle + + Orabuntu-lxc OS NEXUS Pranah Storage Technologies + + Proxmox - - - QStar Technologies + QStar Technologies Scalable Informatics - - Scale Computing + + Scale Computing Small Tree Communications Soul Information Technology Co., Ltd. - - StarWind Software - System Fabric Works, Inc. + StarWind Software + + System Fabric Works, Inc. From 19fb455bc2d32733a835891d4e884dc468e2c730 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 28 Jan 2016 04:11:54 +0000 Subject: [PATCH 065/121] SVN_TAGS: Add 3.1.0 version information git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6791 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- SVN_TAGS | 1 + 1 file changed, 1 insertion(+) diff --git a/SVN_TAGS b/SVN_TAGS index b8fb6f4f4..0e234d912 100644 --- a/SVN_TAGS +++ b/SVN_TAGS @@ -20,3 +20,4 @@ SRPT 1.0.0 450 3.0.x branch start 5534, which is a copy of trunk r5533 3.0.0 5815 on the 3.0.x branch 3.1.x branch start 6591, which is a copy of trunk r6590 +3.1.0 6783 on the 3.1.x branch From adef678432b2c8114d11656e3f100c62241a89e1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 2 Feb 2016 16:33:03 +0000 Subject: [PATCH 066/121] nightly build: Update kernel versions git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6792 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- nightly/conf/nightly.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 17092a33c..c85f18e34 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -3,10 +3,10 @@ ABT_DETAILS="x86_64" ABT_JOBS=5 ABT_KERNELS=" \ -4.4 \ -4.3.4-nc \ +4.4.1 \ +4.3.5-nc \ 4.2.8-nc \ -4.1.16-nc \ +4.1.17-nc \ 4.0.9-nc \ 3.19.8-nc \ 3.18.25-nc \ From afa33c6b394848aa2a2b0c4073099c24e3096761 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 3 Feb 2016 02:58:19 +0000 Subject: [PATCH 067/121] Web updates git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6793 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- www/users.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/users.html b/www/users.html index b46609c6c..3da85cdff 100644 --- a/www/users.html +++ b/www/users.html @@ -126,6 +126,8 @@ StarWind Software System Fabric Works, Inc. + + TechoPhil Ltd From dd79d49ecbf1742415c4c8d7a0921304c9687974 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 7 Feb 2016 03:58:25 +0000 Subject: [PATCH 068/121] nightly build: Update kernel versions git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6794 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- nightly/conf/nightly.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index c85f18e34..14b7649df 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -9,15 +9,15 @@ ABT_KERNELS=" \ 4.1.17-nc \ 4.0.9-nc \ 3.19.8-nc \ -3.18.25-nc \ +3.18.26-nc \ 3.17.8-nc \ 3.16.7-nc \ 3.15.10-nc \ -3.14.59-nc \ +3.14.60-nc \ 3.13.11-nc \ -3.12.52-nc \ +3.12.53-nc \ 3.11.10-nc \ -3.10.95-nc \ +3.10.96-nc \ 3.9.11-nc \ 3.8.13-nc \ 3.7.10-nc \ @@ -25,7 +25,7 @@ ABT_KERNELS=" \ 3.5.7-nc \ 3.4.110-nc \ 3.3.8-nc \ -3.2.75-nc \ +3.2.76-nc \ 3.1.10-nc \ 3.0.101-nc \ 2.6.39.4-nc \ @@ -36,7 +36,7 @@ ABT_KERNELS=" \ 2.6.35.14-u-nc \ 2.6.34.15-nc \ 2.6.33.20-nc \ -2.6.32.67-nc \ +2.6.32.70-nc \ 2.6.31.14-nc \ 2.6.30.10-nc \ 2.6.29.6-nc \ From 970c2c2ed3ae8f87cf4d6cbbb6c7733eba82e55a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 16 Feb 2016 19:19:29 +0000 Subject: [PATCH 069/121] scst_debug.h: Kernel v4.5 build fix git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6795 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst_debug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index 5cb93fe66..18a052c98 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -245,7 +245,7 @@ do { \ #define TRACING_MINOR() (false) #define TRACE(trace, format, args...) \ - ((void)(trace), no_printk(format, ##args)) + do { (void)(trace); no_printk(format, ##args); } while (0) #define PRINT_BUFFER(message, buff, len) \ ((void)(message), (void)(buff), (void)(len)) #define PRINT_BUFF_FLAG(flag, message, buff, len) \ @@ -391,7 +391,7 @@ do { \ #define TRACE_SG(format, args...) no_printk(format, ##args) #define TRACE_DBG(format, args...) no_printk(format, ##args) #define TRACE_DBG_FLAG(flag, format, args...) \ - ((void)(flag), no_printk(format, ##args)) + do { (void)(flag); no_printk(format, ##args); } while (0) #define TRACE_DBG_SPECIAL(format, args...) no_printk(format, ##args) #define TRACE_MGMT_DBG(format, args...) no_printk(format, ##args) #define TRACE_MGMT_DBG_SPECIAL(format, args...) no_printk(format, ##args) From 337b7e372eb74f97b976f8240030bd1b8f19517d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 16 Feb 2016 19:35:02 +0000 Subject: [PATCH 070/121] ib_srpt: Port to Linux kernel v4.5 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6797 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 637878394..d4fdcbe7a 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -593,6 +593,9 @@ static void srpt_mad_send_handler(struct ib_mad_agent *mad_agent, * srpt_mad_recv_handler() - MAD reception callback function. */ static void srpt_mad_recv_handler(struct ib_mad_agent *mad_agent, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) + struct ib_mad_send_buf *send_buf, +#endif struct ib_mad_recv_wc *mad_wc) { struct srpt_port *sport = (struct srpt_port *)mad_agent->context; @@ -4206,11 +4209,15 @@ static void srpt_add_one(struct ib_device *device) sdev->device = device; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) ret = ib_query_device(device, &sdev->dev_attr); if (ret) { pr_err("ib_query_device() failed: %d\n", ret); goto free_dev; } +#else + sdev->dev_attr = device->attrs; +#endif sdev->pd = ib_alloc_pd(device); if (IS_ERR(sdev->pd)) { From 2ce7057d547849db8d21045784f4c9bfde6e16c6 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 16 Feb 2016 19:35:52 +0000 Subject: [PATCH 071/121] isert-scst: Port to Linux kernel v4.5 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6798 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/isert-scst/iser_rdma.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index 499a941fe..59e44dbb3 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -865,7 +865,6 @@ static void isert_async_evt_handler(struct ib_event *async_ev, void *context) static struct isert_device *isert_device_create(struct ib_device *ib_dev) { struct isert_device *isert_dev; - struct ib_device_attr *dev_attr; int cqe_num, err; struct ib_pd *pd; struct ib_mr *mr; @@ -882,12 +881,15 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev) goto out; } - dev_attr = &isert_dev->device_attr; - err = ib_query_device(ib_dev, dev_attr); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) + err = ib_query_device(ib_dev, &isert_dev->device_attr); if (unlikely(err)) { pr_err("Failed to query device, err: %d\n", err); - goto fail_query; + goto free_isert_dev; } +#else + isert_dev->device_attr = ib_dev->attrs; +#endif isert_dev->num_cqs = min_t(int, num_online_cpus(), ib_dev->num_comp_vectors); @@ -898,7 +900,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev) if (unlikely(isert_dev->cq_qps == NULL)) { pr_err("Failed to allocate iser cq_qps\n"); err = -ENOMEM; - goto fail_cq_qps; + goto free_isert_dev; } isert_dev->cq_desc = vmalloc(sizeof(*isert_dev->cq_desc) * isert_dev->num_cqs); @@ -1026,8 +1028,7 @@ fail_pd: vfree(isert_dev->cq_desc); fail_alloc_cq_desc: kfree(isert_dev->cq_qps); -fail_cq_qps: -fail_query: +free_isert_dev: kfree(isert_dev); out: TRACE_EXIT_RES(err); From ab193f3835e4e60769ac77df59e7e118b580e2b7 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 17 Feb 2016 02:08:34 +0000 Subject: [PATCH 072/121] Set SPC-4 confirmance for LUN NOT SUPPORTED INQUIRY Reported-By: dimec lunec git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6801 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index e5d66b458..c5b4250be 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -1950,6 +1950,7 @@ go: memset(buf, 0, len); buf[0] = 0x7F; /* Peripheral qualifier 011b, Peripheral device type 1Fh */ + buf[2] = 6; /* Device complies to SPC-4 */ buf[4] = len - 4; TRACE_BUFFER("INQUIRY for not supported LUN set", buf, len); From edb4607dc58949da9eb5788ff3696a6ba8d0a7c6 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 17 Feb 2016 03:08:01 +0000 Subject: [PATCH 073/121] [ALUA][EXPERIMENTAL]: review and cleanup according to SPC-4 allowed and not allowed commands in various ALUA states Also changes in INQUIRY the peripheral qualifier to 001b for UNAVAILABLE and OFFLINE states as required by SPC-4 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6802 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 1 + scst/src/dev_handlers/scst_vdisk.c | 11 +++++-- scst/src/scst_tg.c | 50 ++++++++++++++++++++++++------ 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index 2ed26ee79..728db0f19 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -3825,6 +3825,7 @@ static inline void scst_sess_set_tgt_priv(struct scst_session *sess, } uint16_t scst_lookup_tg_id(struct scst_device *dev, struct scst_tgt *tgt); +enum scst_tg_state scst_get_alua_state(struct scst_device *dev, struct scst_tgt *tgt); bool scst_alua_configured(struct scst_device *dev); int scst_tg_get_group_info(void **buf, uint32_t *response_length, struct scst_device *dev, uint8_t data_format); diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index a36a3136d..963f08664 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3547,7 +3547,6 @@ static bool vdisk_no_fd_allowed_commands(const struct scst_cmd *cmd) switch (cmd->cdb[0]) { case TEST_UNIT_READY: - case GET_EVENT_STATUS_NOTIFICATION: case INQUIRY: case MODE_SENSE: case MODE_SENSE_10: @@ -4369,6 +4368,7 @@ static enum compl_status_e vdisk_exec_inquiry(struct vdisk_cmd_params *p) uint8_t *buf; struct scst_device *dev = cmd->dev; struct scst_vdisk_dev *virt_dev = dev->dh_priv; + enum scst_tg_state alua_state; TRACE_ENTRY(); @@ -4390,8 +4390,13 @@ static enum compl_status_e vdisk_exec_inquiry(struct vdisk_cmd_params *p) goto out_put; } - buf[0] = virt_dev->dummy ? SCSI_INQ_PQ_NOT_CON << 5 | 0x1f : - SCSI_INQ_PQ_CON << 5 | dev->type; + alua_state = scst_get_alua_state(cmd->dev, cmd->tgt); + if ((alua_state == SCST_TG_STATE_UNAVAILABLE) || + (alua_state == SCST_TG_STATE_OFFLINE)) + buf[0] = SCSI_INQ_PQ_NOT_CON << 5 | dev->type; + else + buf[0] = virt_dev->dummy ? SCSI_INQ_PQ_NOT_CON << 5 | 0x1f : + SCSI_INQ_PQ_CON << 5 | dev->type; /* Vital Product */ if (cmd->cdb[1] & EVPD) { if (cmd->cdb[2] == 0) { diff --git a/scst/src/scst_tg.c b/scst/src/scst_tg.c index 783696316..fae553190 100644 --- a/scst/src/scst_tg.c +++ b/scst/src/scst_tg.c @@ -283,8 +283,6 @@ static int scst_tg_accept_standby(struct scst_cmd *cmd) TRACE_ENTRY(); switch (cmd->cdb[0]) { - case TEST_UNIT_READY: - case GET_EVENT_STATUS_NOTIFICATION: case INQUIRY: case MODE_SENSE: case MODE_SENSE_10: @@ -348,18 +346,10 @@ static int scst_tg_accept_unav(struct scst_cmd *cmd) TRACE_ENTRY(); switch (cmd->cdb[0]) { - case TEST_UNIT_READY: - case GET_EVENT_STATUS_NOTIFICATION: case INQUIRY: - case MODE_SENSE: - case MODE_SENSE_10: case READ_CAPACITY: case REPORT_LUNS: case REQUEST_SENSE: - case RELEASE: - case RELEASE_10: - case RESERVE: - case RESERVE_10: case READ_BUFFER: case WRITE_BUFFER: res = SCST_ALUA_CHECK_OK; @@ -458,6 +448,13 @@ static int scst_tg_accept_transitioning(struct scst_cmd *cmd) goto out; } break; + case MAINTENANCE_IN: + switch (cmd->cdb[1] & 0x1f) { + case MI_REPORT_TARGET_PGS: + res = SCST_ALUA_CHECK_OK; + goto out; + } + break; } if (cmd->already_transitioning) @@ -1443,6 +1440,39 @@ out_unlock: } EXPORT_SYMBOL_GPL(scst_lookup_tg_id); +/** + * scst_get_alua_state() - returns ALUA state the target port group. + * @dev: SCST device. + * @tgt: SCST target. + * + * Returns a valid ALUA state (SCST_TG_STATE_OPTIMIZED is no ALUA configured) + */ +enum scst_tg_state scst_get_alua_state(struct scst_device *dev, struct scst_tgt *tgt) +{ + struct scst_dev_group *dg; + struct scst_target_group *tg; + struct scst_tg_tgt *tg_tgt; + enum scst_tg_state res = SCST_TG_STATE_OPTIMIZED; + + TRACE_ENTRY(); + mutex_lock(&scst_dg_mutex); + dg = __lookup_dg_by_dev(dev); + if (!dg) + goto out_unlock; + tg_tgt = __lookup_dg_tgt(dg, tgt->tgt_name); + if (!tg_tgt) + goto out_unlock; + tg = tg_tgt->tg; + BUG_ON(!tg); + res = tg->state; +out_unlock: + mutex_unlock(&scst_dg_mutex); + + TRACE_EXIT_RES(res); + return res; +} +EXPORT_SYMBOL_GPL(scst_get_alua_state); + /** * scst_alua_configured() - Whether implicit ALUA has been configured. * @dev: Pointer to the SCST device to verify. From 143db85864aea16f131b69cf5cc8ef6cd5557986 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 17 Feb 2016 03:17:08 +0000 Subject: [PATCH 074/121] web: Update references to STGT project Reported-by: Xose Vazquez Perez git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6803 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- www/comparison.html | 2 +- www/scstvsstgt.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/www/comparison.html b/www/comparison.html index 921d50eea..a5a7baf09 100644 --- a/www/comparison.html +++ b/www/comparison.html @@ -60,7 +60,7 @@ SCST -STGT +STGT IET LIO/TCM diff --git a/www/scstvsstgt.html b/www/scstvsstgt.html index 750a9c995..ef128ef6f 100644 --- a/www/scstvsstgt.html +++ b/www/scstvsstgt.html @@ -44,7 +44,7 @@

SCST vs STGT

-

STGT is alternative, independent from SCST implementation +

STGT is alternative, independent from SCST implementation of SCSI target framework for Linux. It has different architecture, where SCSI target state machine is placed in the user space, while in SCST all the processing done in the kernel. Such architecture as STGT has was acknowledged by the Linux SCSI subsystem maintainers as a "right" one, so kernel's part of STGT quickly From e8575e85c32ea37be550d64253658a52ff7d3aa6 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 17 Feb 2016 03:30:17 +0000 Subject: [PATCH 075/121] scst_vdisk: clarify vdisk_no_fd_allowed_commands() comment git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6804 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 963f08664..4b9295d26 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3614,7 +3614,11 @@ static int blockio_exec(struct scst_cmd *cmd) if (unlikely(virt_dev->fd == NULL)) { if (!vdisk_no_fd_allowed_commands(cmd)) { - /* We should not get here */ + /* + * We should not get here, unless the user space + * misconfiguring something, e.g. set optimized + * ALUA state for secondary DRBD device. + */ PRINT_WARNING("Closed FD on exec. Secondary DRBD or not " "blocked dev before ALUA state change? " "(cmd %p, op %s, dev %s)", cmd, cmd->op_name, From e50babee18b9179e9791fd111fb975ddc29a5f38 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 18 Feb 2016 01:27:39 +0000 Subject: [PATCH 076/121] scst: add forwarding pass-through mode git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6805 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/README | 9 +++++++++ scst/README_in-tree | 9 +++++++++ scst/include/scst.h | 1 + scst/src/dev_handlers/scst_disk.c | 32 +++++++++++++++++++++++++++++++ scst/src/scst_main.c | 19 ++++++++++++++++++ scst/src/scst_targ.c | 2 ++ 6 files changed, 72 insertions(+) diff --git a/scst/README b/scst/README index 8da5009cc..f54953803 100644 --- a/scst/README +++ b/scst/README @@ -353,6 +353,15 @@ in/out in Makefile and scst.h: functionality is working only if dif_mode doesn't contain dev_store and dif_type is 1. + - CONFIG_SCST_FORWARD_MODE_PASS_THROUGH - if defined, the pass-through + subsystem starts working in the forwarding mode, where reservation + commands processed locally and not passed to the backend SCSI device, + while COMPARE AND WRITE, EXTENDED COPY and RECEIVE COPY RESULTS + commands, which normally processed locally by the SCST core, not + processed locally, but passed to the backend device. Intended to be + used to implement NON-OPTIMIZED ALUA state together with "forwarding" + target attribute on the remote node. Disabled by default for safety. + HIGHMEM kernel configurations are fully supported, but not recommended for performance reasons, except for scst_user, where they are not supported, because this module deals with user supplied memory on a diff --git a/scst/README_in-tree b/scst/README_in-tree index 669f97f44..defac1e6d 100644 --- a/scst/README_in-tree +++ b/scst/README_in-tree @@ -243,6 +243,15 @@ your favorite kernel configuration Makefile target, e.g. "make xconfig": functionality is working only if dif_mode doesn't contain dev_store and dif_type is 1. + - CONFIG_SCST_FORWARD_MODE_PASS_THROUGH - if defined, the pass-through + subsystem starts working in the forwarding mode, where reservation + commands processed locally and not passed to the backend SCSI device, + while COMPARE AND WRITE, EXTENDED COPY and RECEIVE COPY RESULTS + commands, which normally processed locally by the SCST core, not + processed locally, but passed to the backend device. Intended to be + used to implement NON-OPTIMIZED ALUA state together with "forwarding" + target attribute on the remote node. Disabled by default for safety. + HIGHMEM kernel configurations are fully supported, but not recommended for performance reasons. diff --git a/scst/include/scst.h b/scst/include/scst.h index 728db0f19..4dc8db2ff 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -29,6 +29,7 @@ /** See README for description of those conditional defines **/ #define CONFIG_SCST_DIF_INJECT_CORRUPTED_TAGS +/* #define CONFIG_SCST_FORWARD_MODE_PASS_THROUGH */ #include #ifndef INSIDE_KERNEL_TREE diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index 56ac72903..13edb3528 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -268,6 +268,20 @@ static int disk_parse(struct scst_cmd *cmd) goto out; } +#ifdef CONFIG_SCST_FORWARD_MODE_PASS_THROUGH + if (unlikely(cmd->op_flags & SCST_LOCAL_CMD)) { + switch (cmd->cdb[0]) { + case COMPARE_AND_WRITE: + case EXTENDED_COPY: + case RECEIVE_COPY_RESULTS: + TRACE_DBG("Clearing LOCAL CMD flag for cmd %p " + "(op %s)", cmd, cmd->op_name); + cmd->op_flags &= ~SCST_LOCAL_CMD; + break; + } + } +#endif + cmd->retries = SCST_PASSTHROUGH_RETRIES; out: return res; @@ -398,6 +412,24 @@ static int disk_exec(struct scst_cmd *cmd) TRACE_ENTRY(); +#ifdef CONFIG_SCST_FORWARD_MODE_PASS_THROUGH + if (unlikely(cmd->op_flags & SCST_LOCAL_CMD)) { + switch (cmd->cdb[0]) { + case RESERVE: + case RESERVE_10: + case RELEASE: + case RELEASE_10: + TRACE_DBG("Skipping LOCAL cmd %p (op %s)", + cmd, cmd->op_name); + goto out_done; + case PERSISTENT_RESERVE_IN: + case PERSISTENT_RESERVE_OUT: + sBUG(); + break; + } + } +#endif + /* * For PC requests we are going to submit max_hw_sectors used instead * of max_sectors. diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 47e458f9e..d52fe3f42 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -1178,6 +1178,17 @@ static int scst_register_device(struct scsi_device *scsidp) dev->scsi_dev = scsidp; +#ifdef CONFIG_SCST_FORWARD_MODE_PASS_THROUGH + res = scst_pr_set_file_name(dev, NULL, "%s/%s", SCST_PR_DIR, + dev->virt_name); + if (res != 0) + goto out_free_dev; + + res = scst_pr_init_dev(dev); + if (res != 0) + goto out_free_dev; +#endif + list_add_tail(&dev->dev_list_entry, &scst_dev_list); #ifdef CONFIG_SCST_PROC @@ -1225,6 +1236,10 @@ out_del_locked: list_del_init(&dev->dev_list_entry); #endif +#ifdef CONFIG_SCST_FORWARD_MODE_PASS_THROUGH + scst_pr_clear_dev(dev); +#endif + out_free_dev: scst_free_device(dev); @@ -1284,6 +1299,10 @@ static void scst_unregister_device(struct scsi_device *scsidp) list_del_init(&dev->dev_list_entry); +#ifdef CONFIG_SCST_FORWARD_MODE_PASS_THROUGH + scst_pr_clear_dev(dev); +#endif + scst_dg_dev_remove_by_dev(dev); scst_assign_dev_handler(dev, &scst_null_devtype); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 2620b5461..47698297f 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -2959,6 +2959,7 @@ static int scst_persistent_reserve_in_local(struct scst_cmd *cmd) goto out_done; } +#ifndef CONFIG_SCST_FORWARD_MODE_PASS_THROUGH if (dev->scsi_dev != NULL) { PRINT_WARNING("PR commands for pass-through devices not " "supported (device %s)", dev->virt_name); @@ -2966,6 +2967,7 @@ static int scst_persistent_reserve_in_local(struct scst_cmd *cmd) SCST_LOAD_SENSE(scst_sense_invalid_opcode)); goto out_done; } +#endif buffer_size = scst_get_buf_full_sense(cmd, &buffer); if (unlikely(buffer_size <= 0)) From 2f44cc3ac1ed7ba395269fb2c615e71bea791b39 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 18 Feb 2016 01:49:09 +0000 Subject: [PATCH 077/121] scst: add OFFLINE ALUA state to the list of supported states Reported-by: Consus git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6806 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_tg.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scst/src/scst_tg.c b/scst/src/scst_tg.c index fae553190..b610fa6f9 100644 --- a/scst/src/scst_tg.c +++ b/scst/src/scst_tg.c @@ -1567,11 +1567,12 @@ int scst_tg_get_group_info(void **buf, uint32_t *length, list_for_each_entry(tg, &dg->tg_list, entry) { /* Target port group descriptor header. */ *p++ = (tg->preferred ? SCST_TG_PREFERRED : 0) | tg->state; - *p++ = SCST_TG_SUP_OPTIMIZED - | SCST_TG_SUP_NONOPTIMIZED - | SCST_TG_SUP_STANDBY - | SCST_TG_SUP_UNAVAILABLE - | SCST_TG_SUP_TRANSITION; + *p++ = SCST_TG_SUP_OPTIMIZED | + SCST_TG_SUP_NONOPTIMIZED | + SCST_TG_SUP_STANDBY | + SCST_TG_SUP_UNAVAILABLE | + SCST_TG_SUP_OFFLINE | + SCST_TG_SUP_TRANSITION; put_unaligned_be16(tg->group_id, p); p += 2; p++; /* reserved */ From 63d1de00a16ea07b88c15efc2e8771b5ead6d698 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 18 Feb 2016 03:15:53 +0000 Subject: [PATCH 078/121] web: unofficial git mirror added git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6807 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- www/downloads.html | 1 + 1 file changed, 1 insertion(+) diff --git a/www/downloads.html b/www/downloads.html index dfcdb0b8d..79e60c0be 100644 --- a/www/downloads.html +++ b/www/downloads.html @@ -67,6 +67,7 @@

From 2607cd0e47659e67c9252ecdc313214cc2e21228 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 18 Feb 2016 03:20:44 +0000 Subject: [PATCH 079/121] ibmvstgt: http://stgt.berlios.de -> http://stgt.sourceforge.net cleanup git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6808 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- ibmvstgt/src/Kconfig | 2 +- ibmvstgt/src/orig/2.6.35/Kconfig | 2 +- ibmvstgt/src/orig/2.6.36/Kconfig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ibmvstgt/src/Kconfig b/ibmvstgt/src/Kconfig index f3f71155e..5c989a9ed 100644 --- a/ibmvstgt/src/Kconfig +++ b/ibmvstgt/src/Kconfig @@ -977,7 +977,7 @@ config SCSI_IBMVSCSIS The userspace component needed to initialize the driver and documentation can be found: - http://stgt.berlios.de/ + http://stgt.sourceforge.net/ To compile this driver as a module, choose M here: the module will be called ibmvstgt. diff --git a/ibmvstgt/src/orig/2.6.35/Kconfig b/ibmvstgt/src/orig/2.6.35/Kconfig index d07f508d1..a80061834 100644 --- a/ibmvstgt/src/orig/2.6.35/Kconfig +++ b/ibmvstgt/src/orig/2.6.35/Kconfig @@ -969,7 +969,7 @@ config SCSI_IBMVSCSIS The userspace component needed to initialize the driver and documentation can be found: - http://stgt.berlios.de/ + http://stgt.sourceforge.net/ To compile this driver as a module, choose M here: the module will be called ibmvstgt. diff --git a/ibmvstgt/src/orig/2.6.36/Kconfig b/ibmvstgt/src/orig/2.6.36/Kconfig index f3f71155e..5c989a9ed 100644 --- a/ibmvstgt/src/orig/2.6.36/Kconfig +++ b/ibmvstgt/src/orig/2.6.36/Kconfig @@ -977,7 +977,7 @@ config SCSI_IBMVSCSIS The userspace component needed to initialize the driver and documentation can be found: - http://stgt.berlios.de/ + http://stgt.sourceforge.net/ To compile this driver as a module, choose M here: the module will be called ibmvstgt. From 69834314b6d69aee22beab74cfcace584ff6a99f Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 18 Feb 2016 03:29:33 +0000 Subject: [PATCH 080/121] web: Gentoo HOWTO update Suggested by calypso2k@poczta.fm git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6809 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/doc/SCST_Gentoo_HOWTO.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/iscsi-scst/doc/SCST_Gentoo_HOWTO.txt b/iscsi-scst/doc/SCST_Gentoo_HOWTO.txt index cca3aa443..9533ac6e8 100644 --- a/iscsi-scst/doc/SCST_Gentoo_HOWTO.txt +++ b/iscsi-scst/doc/SCST_Gentoo_HOWTO.txt @@ -85,6 +85,13 @@ work perfectly) 5. Build SCST + ! Important: SCST 3.1.x and trunk: Gentoo Hardened kernels uses + Grsec/PaX patchset. If you happen to use one of those kernels + (sys-kernel/hardened-sources) you need to change every call + "object_is_on_stack" to "object_starts_on_stack" to compile SCST + successfully. At the time of writing this there is a single such call + in scst/src/scst_lib.c + cd /root/scst make 2perf make scst scst_install From 7a58722e73afa7bb9ee5c319b25a65df811c47b2 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 18 Feb 2016 22:18:08 +0000 Subject: [PATCH 081/121] scst_vdisk: Rate-limit block I/O error messages git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6810 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 22 ++++++++++++++++++++++ scst/include/scst_debug.h | 14 ++++++++++++++ scst/src/dev_handlers/scst_vdisk.c | 3 ++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index 9fae2e744..d12657087 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -365,6 +365,28 @@ static inline __attribute__ ((format (printf, 1, 2))) int no_printk(const char *s, ...) { return 0; } #endif +/* */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) +/* See also commit 717115e1a585 */ + +#define DEFAULT_RATELIMIT_INTERVAL (5 * HZ) +#define DEFAULT_RATELIMIT_BURST 10 + +struct ratelimit_state { + int interval; + int burst; +}; + +#define DEFINE_RATELIMIT_STATE(name, interval, burst) \ + struct ratelimit_state name = {interval, burst,} + +static inline int __ratelimit(struct ratelimit_state *rs) +{ + return 1; +} +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) && !defined(kfree_rcu) diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index 18a052c98..00ea2c559 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -31,6 +31,10 @@ #include /* for WARN_ON_ONCE */ #endif +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27) +#include +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) /* * See also the following commits: @@ -284,6 +288,16 @@ do { \ #endif /* CONFIG_SCST_DEBUG || CONFIG_SCST_TRACING */ +#define PRINT_ERROR_RATELIMITED(format, args...) \ + do { \ + static DEFINE_RATELIMIT_STATE(_rs, \ + DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ + \ + if (__ratelimit(&_rs)) \ + PRINT_ERROR(format, ##args); \ + } while (0) + #ifdef CONFIG_SCST_DEBUG #define TRACE_DBG_FLAG(trace, format, args...) \ diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 4b9295d26..80aad71aa 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -6486,7 +6486,8 @@ static void blockio_endio(struct bio *bio) if (unlikely(error != 0)) { unsigned long flags; - PRINT_ERROR("BLOCKIO for cmd %p finished with error %d", + PRINT_ERROR_RATELIMITED( + "BLOCKIO for cmd %p finished with error %d", blockio_work->cmd, error); /* From a1b613af753ea29f70c640e5126b0b1d3e4a1da3 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 19 Feb 2016 03:12:53 +0000 Subject: [PATCH 082/121] iscsi-scst: clarify comment git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6811 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/nthread.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index 5701b8b93..42a6c96c8 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -868,6 +868,12 @@ static int process_read_io(struct iscsi_conn *conn, int *closed) /* * This command not yet received on the aborted * time, so shouldn't be affected by any abort. + * It should not be affected by conn_abort() + * as well, because close connection is initiated + * from single (this) read thread, so conn_abort() + * call stack can not be initiated in parallel to + * receive all the data event (do_recv() has check + * of conn->closing in the beginning) */ EXTRACHECKS_BUG_ON(cmnd->prelim_compl_flags != 0); From f029978199db28bb0d2b6cfde6ef6785d6929787 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 19 Feb 2016 03:35:26 +0000 Subject: [PATCH 083/121] scst: fix potential buffer overflow + cleanup Reported-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6812 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index c5b4250be..bb1eb2d58 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -12020,6 +12020,13 @@ int scst_block_generic_dev_done(struct scst_cmd *cmd, * therefore change them only if necessary */ + /* + * Potentially, a pass-through backend device can at any time change + * block size behind us, e.g. after FORMAT command, so we need to + * somehow detect it. Intercepting READ CAPACITY is, probably, the + * simplest, yet sufficient way for that. + */ + if (unlikely(opcode == READ_CAPACITY)) { if (scst_cmd_completed_good(cmd)) { /* Always keep track of disk capacity */ @@ -12027,8 +12034,8 @@ int scst_block_generic_dev_done(struct scst_cmd *cmd, uint8_t *buffer; buffer_size = scst_get_buf_full(cmd, &buffer); - if (unlikely(buffer_size <= 0)) { - if (buffer_size < 0) { + if (unlikely(buffer_size < 8)) { + if (buffer_size != 0) { PRINT_ERROR("%s: Unable to get cmd " "buffer (%d)", __func__, buffer_size); @@ -12045,7 +12052,7 @@ int scst_block_generic_dev_done(struct scst_cmd *cmd, set_block_shift(cmd, sh); TRACE_DBG("block_shift %d", sh); } - } else { + } else /* ToDo: add READ CAPACITY(16) here */ { /* It's all good */ } From f27b1f9cc3d99aedf6d14bd596f19b4caac4fb22 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 22 Feb 2016 04:13:53 +0000 Subject: [PATCH 084/121] scst_tg: Restore Linux and ESXi interoperability Linux and ESXi expect that target ports in one of the ALUA states standby or unavailable are able to process commands like TEST UNIT READY, READ CAPACITY, RESERVE and RELEASE. This patch partially reverts r6802. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6813 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 1 + scst/src/scst_tg.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 80aad71aa..fb9c64ec6 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3547,6 +3547,7 @@ static bool vdisk_no_fd_allowed_commands(const struct scst_cmd *cmd) switch (cmd->cdb[0]) { case TEST_UNIT_READY: + case GET_EVENT_STATUS_NOTIFICATION: case INQUIRY: case MODE_SENSE: case MODE_SENSE_10: diff --git a/scst/src/scst_tg.c b/scst/src/scst_tg.c index b610fa6f9..ba3567ba0 100644 --- a/scst/src/scst_tg.c +++ b/scst/src/scst_tg.c @@ -283,6 +283,8 @@ static int scst_tg_accept_standby(struct scst_cmd *cmd) TRACE_ENTRY(); switch (cmd->cdb[0]) { + case TEST_UNIT_READY: + case GET_EVENT_STATUS_NOTIFICATION: case INQUIRY: case MODE_SENSE: case MODE_SENSE_10: @@ -346,10 +348,18 @@ static int scst_tg_accept_unav(struct scst_cmd *cmd) TRACE_ENTRY(); switch (cmd->cdb[0]) { + case TEST_UNIT_READY: + case GET_EVENT_STATUS_NOTIFICATION: case INQUIRY: + case MODE_SENSE: + case MODE_SENSE_10: case READ_CAPACITY: case REPORT_LUNS: case REQUEST_SENSE: + case RELEASE: + case RELEASE_10: + case RESERVE: + case RESERVE_10: case READ_BUFFER: case WRITE_BUFFER: res = SCST_ALUA_CHECK_OK; From 97c5259476a17f0d2207b92642bdbb4fedced1ad Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Tue, 23 Feb 2016 04:34:24 +0000 Subject: [PATCH 085/121] Revert r6813 in (experimental) attempt to stay SPC complying git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6814 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 1 - scst/src/scst_tg.c | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index fb9c64ec6..80aad71aa 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3547,7 +3547,6 @@ static bool vdisk_no_fd_allowed_commands(const struct scst_cmd *cmd) switch (cmd->cdb[0]) { case TEST_UNIT_READY: - case GET_EVENT_STATUS_NOTIFICATION: case INQUIRY: case MODE_SENSE: case MODE_SENSE_10: diff --git a/scst/src/scst_tg.c b/scst/src/scst_tg.c index ba3567ba0..b610fa6f9 100644 --- a/scst/src/scst_tg.c +++ b/scst/src/scst_tg.c @@ -283,8 +283,6 @@ static int scst_tg_accept_standby(struct scst_cmd *cmd) TRACE_ENTRY(); switch (cmd->cdb[0]) { - case TEST_UNIT_READY: - case GET_EVENT_STATUS_NOTIFICATION: case INQUIRY: case MODE_SENSE: case MODE_SENSE_10: @@ -348,18 +346,10 @@ static int scst_tg_accept_unav(struct scst_cmd *cmd) TRACE_ENTRY(); switch (cmd->cdb[0]) { - case TEST_UNIT_READY: - case GET_EVENT_STATUS_NOTIFICATION: case INQUIRY: - case MODE_SENSE: - case MODE_SENSE_10: case READ_CAPACITY: case REPORT_LUNS: case REQUEST_SENSE: - case RELEASE: - case RELEASE_10: - case RESERVE: - case RESERVE_10: case READ_BUFFER: case WRITE_BUFFER: res = SCST_ALUA_CHECK_OK; From dd3f46fd285fcec95e426a64e6b3995c0a183334 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 24 Feb 2016 01:01:54 +0000 Subject: [PATCH 086/121] stpgd: Fix compilation in perf mode Reported-by: TomK git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6815 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- usr/stpgd/Makefile | 9 +-------- usr/stpgd/stpgd_main.c | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/usr/stpgd/Makefile b/usr/stpgd/Makefile index 3fa1e9bc7..fc340742e 100644 --- a/usr/stpgd/Makefile +++ b/usr/stpgd/Makefile @@ -89,14 +89,7 @@ extraclean: clean grep "^CFLAGS += \-DDEBUG -g -fno-inline -fno-inline-functions" Makefile >/dev/null rm Makefile.aa -2perf: - sed -i.aa s/"^C\?FLAGS += \-DEXTRACHECKS"/"#CFLAGS += \-DEXTRACHECKS"/ Makefile - grep "^#CFLAGS += \-DEXTRACHECKS" Makefile >/dev/null - sed -i.aa s/"^C\?FLAGS += \-DTRACING"/"#CFLAGS += \-DTRACING"/ Makefile - grep "^#CFLAGS += \-DTRACING" Makefile >/dev/null - sed -i.aa s/"^C\?FLAGS += \-DDEBUG -g -fno-inline -fno-inline-functions"/"#CFLAGS += \-DDEBUG -g -fno-inline -fno-inline-functions"/ Makefile - grep "^#CFLAGS += \-DDEBUG -g -fno-inline -fno-inline-functions" Makefile >/dev/null - rm Makefile.aa +2perf: 2release release-archive: ../../scripts/generate-release-archive stpgd "$$(sed -n 's/^#define[[:blank:]]VERSION_STR[[:blank:]]*\"\([^\"]*\)\".*/\1/p' ../include/version.h)" diff --git a/usr/stpgd/stpgd_main.c b/usr/stpgd/stpgd_main.c index 625879cfc..63fa92bdd 100644 --- a/usr/stpgd/stpgd_main.c +++ b/usr/stpgd/stpgd_main.c @@ -46,12 +46,12 @@ char *app_name; # endif #endif /* DEBUG */ -#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) - bool log_daemon = true; unsigned long trace_flag = DEFAULT_LOG_FLAGS; #endif /* defined(DEBUG) || defined(TRACING) */ +#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) + int transition_timeout = DEFAULT_TRANSITION_TIME; static struct option const long_options[] = { From ca246c4a50cf89a77b603e488af50dc731d9fdb9 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 24 Feb 2016 01:47:02 +0000 Subject: [PATCH 087/121] scst: Follow up for r6804 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6817 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/README | 14 +++++++------- scst/README_in-tree | 14 +++++++------- scst/src/dev_handlers/scst_vdisk.c | 4 +++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/scst/README b/scst/README index f54953803..7f78d8159 100644 --- a/scst/README +++ b/scst/README @@ -1647,14 +1647,14 @@ perform actual path state switching on SET TARGET PORT GROUPS command, for instance, by calling drbdadm. For more information see stpgd README as well as sample script scst_on_stpg. -DRBD compatibility -.................. +DRBD and other replication/failover SW compatibility +.................................................... -DRBD does not allow to open its device on the secondary as well as does -not allow to perform primary to secondary transition, if this device is -open. +DRBD as well as other replication/failover SW does not allow to open its +device on the secondary as well as does not allow to perform primary to +secondary transition, if this device is open. -SCST BLOCKIO handler has all the necessary support for this behavior. If +SCST BLOCKIO handler has all the necessary support for such behavior. If you write new ALUA state in the "state" attribute, SCST BLOCKIO handler before transition closes the open devices' handles and after transition reopens them, if the new state is active or nonoptimized. @@ -1668,7 +1668,7 @@ above). Wait until the blocking finished. 2. Change the ALUA state to "transitioning". At this moment all open file handles will be closed. -3. Perform the DRBD state transition +3. Perform the DRBD or other replication/failover SW state transition 4. Change the ALUA state to your desired secondary state. diff --git a/scst/README_in-tree b/scst/README_in-tree index defac1e6d..5159aea88 100644 --- a/scst/README_in-tree +++ b/scst/README_in-tree @@ -1500,14 +1500,14 @@ perform actual path state switching on SET TARGET PORT GROUPS command, for instance, by calling drbdadm. For more information see stpgd README as well as sample script scst_on_stpg. -DRBD compatibility -.................. +DRBD and other replication/failover SW compatibility +.................................................... -DRBD does not allow to open its device on the secondary as well as does -not allow to perform primary to secondary transition, if this device is -open. +DRBD as well as other replication/failover SW does not allow to open its +device on the secondary as well as does not allow to perform primary to +secondary transition, if this device is open. -SCST BLOCKIO handler has all the necessary support for this behavior. If +SCST BLOCKIO handler has all the necessary support for such behavior. If you write new ALUA state in the "state" attribute, SCST BLOCKIO handler before transition closes the open devices' handles and after transition reopens them, if the new state is active or nonoptimized. @@ -1521,7 +1521,7 @@ above). Wait until the blocking finished. 2. Change the ALUA state to "transitioning". At this moment all open file handles will be closed. -3. Perform the DRBD state transition +3. Perform the DRBD or other replication/failover SW state transition 4. Change the ALUA state to your desired secondary state. diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 80aad71aa..56f101770 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3617,7 +3617,9 @@ static int blockio_exec(struct scst_cmd *cmd) /* * We should not get here, unless the user space * misconfiguring something, e.g. set optimized - * ALUA state for secondary DRBD device. + * ALUA state for secondary DRBD device. See + * "DRBD and other replication/failover SW + * compatibility" section in SCST README. */ PRINT_WARNING("Closed FD on exec. Secondary DRBD or not " "blocked dev before ALUA state change? " From 068bc3f41eae1da1cee39e5839a1ab7c8851bbf4 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 1 Mar 2016 17:39:37 +0000 Subject: [PATCH 088/121] scst: Fix scst_resume_activity() Avoid that the following crash is triggered under memory pressure: PID: 12622 TASK: ffff88042069a040 CPU: 2 COMMAND: "scst_uid" #0 [ffff88040daebaa0] machine_kexec at ffffffff8103b60b #1 [ffff88040daebb00] crash_kexec at ffffffff810c99e2 #2 [ffff88040daebbd0] oops_end at ffffffff8152e1c0 #3 [ffff88040daebc00] die at ffffffff81010f5b #4 [ffff88040daebc30] do_general_protection at ffffffff8152dcb2 #5 [ffff88040daebc60] general_protection at ffffffff8152d485 [exception RIP: __scst_resume_activity+531] RIP: ffffffffa05ccbd3 RSP: ffff88040daebd10 RFLAGS: 00010046 RAX: 0000000000000063 RBX: dead000000100100 RCX: 0000000000000000 RDX: ffffffffa067c8a0 RSI: 0000000000000046 RDI: 0000000000000046 RBP: ffff88040daebd30 R8: 000000001c1471e6 R9: 6320746d676d2065 R10: 766974636120666f R11: 2064616568206f74 R12: ffff88068fea73a8 R13: ffff88068fea73a8 R14: ffff88040daebe08 R15: ffff88043a7eaab0 ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 #6 [ffff88040daebd18] mutex_lock at ffffffff8152af9e #7 [ffff88040daebd38] scst_resume_activity at ffffffffa05ccc6d [scst] #8 [ffff88040daebd48] scst_unregister_virtual_device at ffffffffa05ce18c [scst] #9 [ffff88040daebd88] vdev_del_device at ffffffffa07ca1c0 [scst_vdisk] #10 [ffff88040daebdb8] vdisk_del_device at ffffffffa07ca4bf [scst_vdisk] #11 [ffff88040daebde8] scst_process_devt_mgmt_store at ffffffffa0605ab9 [scst] #12 [ffff88040daebe38] scst_devt_mgmt_store_work_fn at ffffffffa0605af6 [scst] #13 [ffff88040daebe48] scst_process_sysfs_works at ffffffffa0601c5f [scst] #14 [ffff88040daebe78] sysfs_work_thread_fn at ffffffffa0601e97 [scst] #15 [ffff88040daebee8] kthread at ffffffff8109e78e #16 [ffff88040daebf48] kernel_thread at ffffffff8100c28a Reported-by: Ashok Ramu Reported-by: Boris Protopopov git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6818 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index d52fe3f42..b8fafe2f8 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -1092,7 +1092,8 @@ static void __scst_resume_activity(void) TRACE_MGMT_DBG("Moving delayed mgmt cmd %p to head of active " "mgmt cmd list", m); } - list_splice(&scst_delayed_mgmt_cmd_list, &scst_active_mgmt_cmd_list); + list_splice_init(&scst_delayed_mgmt_cmd_list, + &scst_active_mgmt_cmd_list); spin_unlock_irq(&scst_mcmd_lock); wake_up_all(&scst_mgmt_cmd_list_waitQ); From 83d0cb0f46e25175148afc6407ed1881f7093dc0 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 2 Mar 2016 04:13:42 +0000 Subject: [PATCH 089/121] iscsi-scst: fix possible recursive locking cmnd_done() called from cmnd_put() can take cmd_list_lock, so it must not be called under it. Reported and tested by David Chen git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6821 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/nthread.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index 42a6c96c8..65671bace 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -81,7 +81,6 @@ again: spin_lock_bh(&conn->cmd_list_lock); list_for_each_entry(cmnd, &conn->cmd_list, cmd_list_entry) { struct iscsi_cmnd *rsp; - int restart = 0; TRACE_CONN_CLOSE_DBG("cmd %p, scst_state %x, " "r2t_len_to_receive %d, ref_cnt %d, parent_req %p, " @@ -98,6 +97,12 @@ again: if (cmnd_get_check(cmnd)) continue; + /* + * If we don't unlock here, we are risking to get into + * recursive deadlock in cmnd_done() called from cmnd_put() + */ + spin_unlock_bh(&conn->cmd_list_lock); + for (i = 0; i < cmnd->sg_cnt; i++) { struct page *page = sg_page(&cmnd->sg[i]); @@ -106,18 +111,12 @@ again: atomic_read(&page->_count)); if (page->net_priv != NULL) { - if (restart == 0) { - spin_unlock_bh(&conn->cmd_list_lock); - restart = 1; - } while (page->net_priv != NULL) iscsi_put_page_callback(page); } } cmnd_put(cmnd); - - if (restart) - goto again; + goto again; } list_for_each_entry(rsp, &cmnd->rsp_cmd_list, @@ -133,6 +132,13 @@ again: if (cmnd_get_check(rsp)) continue; + /* + * If we don't unlock here, we are risking to + * get into recursive deadlock in cmnd_done() + * called from cmnd_put() + */ + spin_unlock_bh(&conn->cmd_list_lock); + for (i = 0; i < rsp->sg_cnt; i++) { struct page *page = sg_page(&rsp->sg[i]); @@ -143,18 +149,12 @@ again: atomic_read(&page->_count)); if (page->net_priv != NULL) { - if (restart == 0) { - spin_unlock_bh(&conn->cmd_list_lock); - restart = 1; - } while (page->net_priv != NULL) iscsi_put_page_callback(page); } } cmnd_put(rsp); - - if (restart) - goto again; + goto again; } } } From 69471744d88fcc38dccfc11a6b2bf93e1173cf87 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 2 Mar 2016 19:56:41 +0000 Subject: [PATCH 090/121] ib_srpt: Reduce command processing latency git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6822 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/README | 10 ++++++++++ srpt/src/ib_srpt.c | 33 +++++++++++++++++++++++++++------ srpt/src/ib_srpt.h | 2 ++ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/srpt/README b/srpt/README index 1f0c91594..4d002271d 100644 --- a/srpt/README +++ b/srpt/README @@ -68,6 +68,16 @@ The ib_srpt kernel module supports the following parameters: to 65536 bytes, which is sufficient to use the full bandwidth of low-latency HCAs. Increasing this value may decrease latency for applications transferring large amounts of data at once. +* srpt_irq_qd (number, default 1) + After the ib_srpt driver has received a SCSI command from an initiator + system an interrupt is triggered. The RDMA work completion can be processed + either in interrupt context or in thread context. This parameter controls + the maximum queue depth for which RDMA completions are processed in + interrupt context. If an RDMA completion has been processed in interrupt + context the associated SCSI command will be submitted to SCST from tasklet + context. This approach helps to reduce command processing latency for + low-latency storage devices (e.g. SSDs). WARNING: setting this parameter to + a high value can cause a system to lock up. * srpt_srq_size (number, default 4095) ib_srpt uses a shared receive queue (SRQ) for processing incoming SRP requests. This number may have to be increased when a large number of diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index d4fdcbe7a..ba740d499 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -148,6 +148,12 @@ module_param(srpt_sq_size, int, 0444); MODULE_PARM_DESC(srpt_sq_size, "Per-channel send queue (SQ) size."); +static int srpt_irq_qd = 1; +module_param(srpt_irq_qd, int, 0644); +MODULE_PARM_DESC(srpt_irq_qd, + "Maximum queue depth for submitting commands to SCST from IRQ context." + " WARNING: increasing this parameter may cause a system lockup."); + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) \ || defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 5 static int use_port_guid_in_session_name; @@ -190,9 +196,16 @@ MODULE_PARM_DESC(max_sge_delta, "Number to subtract from max_sge."); * dangerous because it might cause IB completions to be processed too late * ("IB completion for idx has not been received in time"). */ -static const enum scst_exec_context srpt_new_iu_context = SCST_CONTEXT_THREAD; -static const enum scst_exec_context srpt_xmt_rsp_context = SCST_CONTEXT_THREAD; -static const enum scst_exec_context srpt_send_context = SCST_CONTEXT_DIRECT; +static inline enum scst_exec_context +srpt_new_iu_context(struct srpt_rdma_ch *ch) +{ + return in_interrupt() && + atomic_read(&ch->sess->sess_cmd_count) <= ch->irq_qd ? + SCST_CONTEXT_TASKLET : SCST_CONTEXT_THREAD; +} +#define srpt_xmt_rsp_context SCST_CONTEXT_THREAD +#define srpt_send_context \ + (in_interrupt() ? SCST_CONTEXT_THREAD : SCST_CONTEXT_DIRECT) static struct ib_client srpt_client; static struct scst_tgt_template srpt_template; @@ -1954,7 +1967,7 @@ static void srpt_process_rcv_completion(struct ib_cq *cq, else ioctx = ch->ioctx_recv_ring[index]; ioctx->byte_len = wc->byte_len; - srpt_handle_new_iu(ch, ioctx, srpt_new_iu_context); + srpt_handle_new_iu(ch, ioctx, srpt_new_iu_context(ch)); } else if (ch->state <= CH_LIVE) { pr_info("receiving failed for idx %u with status %d\n", index, wc->status); @@ -1969,7 +1982,8 @@ static void srpt_process_wait_list(struct srpt_rdma_ch *ch) list_for_each_entry_safe(recv_ioctx, tmp, &ch->cmd_wait_list, wait_list) { - if (!srpt_handle_new_iu(ch, recv_ioctx, srpt_new_iu_context)) + if (!srpt_handle_new_iu(ch, recv_ioctx, + srpt_new_iu_context(ch))) break; } @@ -2098,7 +2112,13 @@ static void srpt_completion(struct ib_cq *cq, void *ctx) { struct srpt_rdma_ch *ch = ctx; - wake_up_process(ch->thread); + const int irq_qd = ch->irq_qd; + int processed = 0; + + if (atomic_read(&ch->sess->sess_cmd_count) <= irq_qd) + processed = srpt_process_completion(ch, irq_qd + 1, false); + if (processed == 0 || processed > irq_qd) + wake_up_process(ch->thread); } static void srpt_free_ch(struct kref *kref) @@ -2621,6 +2641,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, ch->rdma_cm.cm_id = rdma_cm_id; rdma_cm_id->context = ch; } + ch->irq_qd = srpt_irq_qd; /* * Avoid QUEUE_FULL conditions by limiting the number of buffers used * for the SRP protocol to the SCST SCSI command queue size. diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 25f816593..9ea725c06 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -317,6 +317,7 @@ enum rdma_ch_state { * @qp: IB queue pair used for communicating over this channel. * @cq: IB completion queue for this channel. * @kref: Per-channel reference count. + * @irq_qd: Maximum queue depth processed in atomic context. * @rq_size: IB receive queue size. * @max_sge: Maximum length of RDMA scatter list. * @max_rsp_size: Maximum size of an SRP response message in bytes. @@ -361,6 +362,7 @@ struct srpt_rdma_ch { }; struct ib_cq *cq; struct kref kref; + int irq_qd; struct rcu_head rcu; int rq_size; int max_sge; From f21aac581f2c146cde2b39425101d0558ca23736 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 4 Mar 2016 03:49:23 +0000 Subject: [PATCH 091/121] scst: make NULLIO use per-initiator threads To increase peformance by decreasing locks contention with multiple CPU cores between multiple threads in the global pool. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6823 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 56f101770..66ef444e8 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -789,7 +789,7 @@ static struct scst_dev_type vdisk_blk_devtype = { static struct scst_dev_type vdisk_null_devtype = { .name = "vdisk_nullio", .type = TYPE_DISK, - .threads_num = 0, + .threads_num = 1, .parse_atomic = 1, .dev_done_atomic = 1, #ifdef CONFIG_SCST_PROC From 8e2996b74afed2b3d3bec0e3ffde29451d2bd465 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 8 Mar 2016 18:24:23 +0000 Subject: [PATCH 092/121] scst_vdisk: Fix kfree() argument in vdev_size_store() error path The wrong variable is freed in the vdev_size_store() error path. Pass 'new_size' instead of 'buf' to kfree(). Signed-off-by: Sebastian Parschauer [ bvanassche: edited patch description ] git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6824 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 66ef444e8..35f633e5f 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -8686,7 +8686,7 @@ out: return res; out_free: - kfree(buf); + kfree(new_size); goto out; } From c12cdbf8600204c4c67462812cdcd9fe20235dba Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 10 Mar 2016 05:00:01 +0000 Subject: [PATCH 093/121] qla2x00t: decrease severity of 2 log messages Those messages don't necessare mean any error. Some harmless race conditions between the target driver and FW can lead to them as well. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6825 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla2x00-target/qla2x00t.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qla2x00t/qla2x00-target/qla2x00t.c b/qla2x00t/qla2x00-target/qla2x00t.c index b8359c468..12d2c12cd 100644 --- a/qla2x00t/qla2x00-target/qla2x00t.c +++ b/qla2x00t/qla2x00-target/qla2x00t.c @@ -5610,7 +5610,7 @@ static void q2t_response_pkt(scsi_qla_host_t *vha, response_t *pkt) */ q24_retry_term_exchange(vha, entry); } else - PRINT_ERROR("qla2x00t(%ld): ABTS_RESP_24XX " + PRINT_WARNING("qla2x00t(%ld): ABTS_RESP_24XX " "failed %x (subcode %x:%x)", vha->host_no, entry->compl_status, entry->error_subcode1, entry->error_subcode2); @@ -5815,7 +5815,7 @@ retry: "S_ID %x:%x:%x", s_id[0], s_id[1], s_id[2]); } else - PRINT_ERROR("qla2x00t(%ld): Unable to find " + PRINT_WARNING("qla2x00t(%ld): Unable to find " "initiator with S_ID %x:%x:%x", vha->host_no, s_id[0], s_id[1], s_id[2]); From 740ad417db3b69d87b05c71089853583f11d2f37 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 10 Mar 2016 05:25:55 +0000 Subject: [PATCH 094/121] scst: some more debug tracing on the pass-through path git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6826 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index bb1eb2d58..9ebd84083 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -7743,6 +7743,9 @@ static struct request *__blk_map_kern_sg(struct request_queue *q, (PAGE_SIZE - sizeof(struct bio)) / sizeof(struct bio_vec), BIO_MAX_PAGES); + TRACE_DBG("max_nr_vecs %d, nents %d, reading %d", max_nr_vecs, + nents, reading); + need_new_bio = true; tot_len = 0; bios = 0; @@ -7764,6 +7767,10 @@ static struct request *__blk_map_kern_sg(struct request_queue *q, l = 0; else l = len; + + TRACE_DBG("i %d, len %zd, tot_len %zd, l %zd, offset %zd", + i, len, tot_len, l, offset); + if (((sg->offset | l) & queue_dma_alignment(q)) || (page_addr && object_is_on_stack(page_addr + sg->offset))) { rq = ERR_PTR(-EINVAL); @@ -7798,6 +7805,8 @@ static struct request *__blk_map_kern_sg(struct request_queue *q, bio->bi_private = bw; bio->bi_end_io = blk_bio_map_kern_endio; + TRACE_DBG("new bio %p, bios %d", bio, bios); + if (hbio == NULL) hbio = bio; else @@ -7807,6 +7816,8 @@ static struct request *__blk_map_kern_sg(struct request_queue *q, bytes = min_t(size_t, len, PAGE_SIZE - offset); + TRACE_DBG("len %zd, bytes %zd, offset %zd", len, bytes, offset); + rc = bio_add_pc_page(q, bio, page, bytes, offset); if (rc < bytes) { if (unlikely(need_new_bio || rc < 0)) { From f59e86a6597e28572128885ad2744d50460d35ba Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 11 Mar 2016 03:10:04 +0000 Subject: [PATCH 095/121] This limits target group state changes to only apply to targets local to the host. This prevents the devices being blocked offline by changes to non-local targets. Signed-off-by: Adrian Saul with some minor corrections git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6827 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_tg.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scst/src/scst_tg.c b/scst/src/scst_tg.c index b610fa6f9..b8cc4456c 100644 --- a/scst/src/scst_tg.c +++ b/scst/src/scst_tg.c @@ -962,6 +962,7 @@ static void __scst_tg_set_state(struct scst_target_group *tg, struct scst_tg_tgt *tg_tgt; struct scst_tgt *tgt; enum scst_tg_state old_state = tg->state; + bool dev_changed; sBUG_ON(state >= ARRAY_SIZE(scst_alua_filter)); lockdep_assert_held(&scst_dg_mutex); @@ -973,8 +974,7 @@ static void __scst_tg_set_state(struct scst_target_group *tg, list_for_each_entry(dg_dev, &tg->dg->dev_list, entry) { dev = dg_dev->dev; - if (dev->handler->on_alua_state_change_start != NULL) - dev->handler->on_alua_state_change_start(dev, old_state, state); + dev_changed = false; list_for_each_entry(tgt_dev, &dev->dev_tgt_dev_list, dev_tgt_dev_list_entry) { tgt = tgt_dev->sess->tgt; @@ -982,6 +982,11 @@ static void __scst_tg_set_state(struct scst_target_group *tg, if (tg_tgt->tgt == tgt) { bool gen_ua = (state != SCST_TG_STATE_TRANSITIONING); + if ((dev->handler->on_alua_state_change_start != NULL) && !dev_changed) { + dev->handler->on_alua_state_change_start(dev, old_state, state); + dev_changed = true; + } + if ((tg->dg->stpg_rel_tgt_id == tgt_dev->sess->tgt->rel_tgt_id) && tid_equal(tg->dg->stpg_transport_id, tgt_dev->sess->transport_id)) gen_ua = false; @@ -991,7 +996,7 @@ static void __scst_tg_set_state(struct scst_target_group *tg, } } } - if (dev->handler->on_alua_state_change_finish != NULL) + if ((dev->handler->on_alua_state_change_finish != NULL) && dev_changed) dev->handler->on_alua_state_change_finish(dev, old_state, state); } From 3d28ef3f0a618836b96afb9966bf93d8545b0b2a Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 11 Mar 2016 03:27:53 +0000 Subject: [PATCH 096/121] scst_vdisk: warning clarification git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6828 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 35f633e5f..a420fdce5 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3621,8 +3621,8 @@ static int blockio_exec(struct scst_cmd *cmd) * "DRBD and other replication/failover SW * compatibility" section in SCST README. */ - PRINT_WARNING("Closed FD on exec. Secondary DRBD or not " - "blocked dev before ALUA state change? " + PRINT_WARNING("Closed FD on exec. Not active ALUA state " + "or not blocked dev before ALUA state change? " "(cmd %p, op %s, dev %s)", cmd, cmd->op_name, cmd->dev->virt_name); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_no_medium)); From 8aa0ecf6662d44fdb572d5b0e24bda6543606c60 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Mar 2016 04:06:34 +0000 Subject: [PATCH 097/121] scripts/generate-patched-kernel: Fix list-source-files path git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6830 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/generate-patched-kernel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate-patched-kernel b/scripts/generate-patched-kernel index 2faba70fd..1f0cee235 100755 --- a/scripts/generate-patched-kernel +++ b/scripts/generate-patched-kernel @@ -48,7 +48,7 @@ extract_kernel_tree "$1" || exit $? cd "${target}" || exit $? -list-source-files "${scst_dir}" | +"${script_dir}/list-source-files" "${scst_dir}" | grep -- "-${kernel_version}.*.patch$" | grep -v /in-tree/ | while read p; do From af8f462071e4f97d84c4cd7c2f5795ea59db1a8b Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Mar 2016 17:00:39 +0000 Subject: [PATCH 098/121] ib_srpt: Revert r6822 Revision 6822 triggers a race condition, hence revert it. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6831 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/README | 10 ---------- srpt/src/ib_srpt.c | 33 ++++++--------------------------- srpt/src/ib_srpt.h | 2 -- 3 files changed, 6 insertions(+), 39 deletions(-) diff --git a/srpt/README b/srpt/README index 4d002271d..1f0c91594 100644 --- a/srpt/README +++ b/srpt/README @@ -68,16 +68,6 @@ The ib_srpt kernel module supports the following parameters: to 65536 bytes, which is sufficient to use the full bandwidth of low-latency HCAs. Increasing this value may decrease latency for applications transferring large amounts of data at once. -* srpt_irq_qd (number, default 1) - After the ib_srpt driver has received a SCSI command from an initiator - system an interrupt is triggered. The RDMA work completion can be processed - either in interrupt context or in thread context. This parameter controls - the maximum queue depth for which RDMA completions are processed in - interrupt context. If an RDMA completion has been processed in interrupt - context the associated SCSI command will be submitted to SCST from tasklet - context. This approach helps to reduce command processing latency for - low-latency storage devices (e.g. SSDs). WARNING: setting this parameter to - a high value can cause a system to lock up. * srpt_srq_size (number, default 4095) ib_srpt uses a shared receive queue (SRQ) for processing incoming SRP requests. This number may have to be increased when a large number of diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index ba740d499..d4fdcbe7a 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -148,12 +148,6 @@ module_param(srpt_sq_size, int, 0444); MODULE_PARM_DESC(srpt_sq_size, "Per-channel send queue (SQ) size."); -static int srpt_irq_qd = 1; -module_param(srpt_irq_qd, int, 0644); -MODULE_PARM_DESC(srpt_irq_qd, - "Maximum queue depth for submitting commands to SCST from IRQ context." - " WARNING: increasing this parameter may cause a system lockup."); - #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) \ || defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 5 static int use_port_guid_in_session_name; @@ -196,16 +190,9 @@ MODULE_PARM_DESC(max_sge_delta, "Number to subtract from max_sge."); * dangerous because it might cause IB completions to be processed too late * ("IB completion for idx has not been received in time"). */ -static inline enum scst_exec_context -srpt_new_iu_context(struct srpt_rdma_ch *ch) -{ - return in_interrupt() && - atomic_read(&ch->sess->sess_cmd_count) <= ch->irq_qd ? - SCST_CONTEXT_TASKLET : SCST_CONTEXT_THREAD; -} -#define srpt_xmt_rsp_context SCST_CONTEXT_THREAD -#define srpt_send_context \ - (in_interrupt() ? SCST_CONTEXT_THREAD : SCST_CONTEXT_DIRECT) +static const enum scst_exec_context srpt_new_iu_context = SCST_CONTEXT_THREAD; +static const enum scst_exec_context srpt_xmt_rsp_context = SCST_CONTEXT_THREAD; +static const enum scst_exec_context srpt_send_context = SCST_CONTEXT_DIRECT; static struct ib_client srpt_client; static struct scst_tgt_template srpt_template; @@ -1967,7 +1954,7 @@ static void srpt_process_rcv_completion(struct ib_cq *cq, else ioctx = ch->ioctx_recv_ring[index]; ioctx->byte_len = wc->byte_len; - srpt_handle_new_iu(ch, ioctx, srpt_new_iu_context(ch)); + srpt_handle_new_iu(ch, ioctx, srpt_new_iu_context); } else if (ch->state <= CH_LIVE) { pr_info("receiving failed for idx %u with status %d\n", index, wc->status); @@ -1982,8 +1969,7 @@ static void srpt_process_wait_list(struct srpt_rdma_ch *ch) list_for_each_entry_safe(recv_ioctx, tmp, &ch->cmd_wait_list, wait_list) { - if (!srpt_handle_new_iu(ch, recv_ioctx, - srpt_new_iu_context(ch))) + if (!srpt_handle_new_iu(ch, recv_ioctx, srpt_new_iu_context)) break; } @@ -2112,13 +2098,7 @@ static void srpt_completion(struct ib_cq *cq, void *ctx) { struct srpt_rdma_ch *ch = ctx; - const int irq_qd = ch->irq_qd; - int processed = 0; - - if (atomic_read(&ch->sess->sess_cmd_count) <= irq_qd) - processed = srpt_process_completion(ch, irq_qd + 1, false); - if (processed == 0 || processed > irq_qd) - wake_up_process(ch->thread); + wake_up_process(ch->thread); } static void srpt_free_ch(struct kref *kref) @@ -2641,7 +2621,6 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, ch->rdma_cm.cm_id = rdma_cm_id; rdma_cm_id->context = ch; } - ch->irq_qd = srpt_irq_qd; /* * Avoid QUEUE_FULL conditions by limiting the number of buffers used * for the SRP protocol to the SCST SCSI command queue size. diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 9ea725c06..25f816593 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -317,7 +317,6 @@ enum rdma_ch_state { * @qp: IB queue pair used for communicating over this channel. * @cq: IB completion queue for this channel. * @kref: Per-channel reference count. - * @irq_qd: Maximum queue depth processed in atomic context. * @rq_size: IB receive queue size. * @max_sge: Maximum length of RDMA scatter list. * @max_rsp_size: Maximum size of an SRP response message in bytes. @@ -362,7 +361,6 @@ struct srpt_rdma_ch { }; struct ib_cq *cq; struct kref kref; - int irq_qd; struct rcu_head rcu; int rq_size; int max_sge; From 7d1a0072563dc736b2583ccc24aa2ba15558112e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Mar 2016 23:09:39 +0000 Subject: [PATCH 099/121] scst_sysfs: Separate LUN addition from LUN replacement code This patch does not change any functionality but makes __scst_process_luns_mgmt_store() easier to read. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6832 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_sysfs.c | 49 ++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index add49e090..e253b888d 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1401,6 +1401,39 @@ static int __scst_process_luns_mgmt_store(char *buffer, switch (action) { case SCST_LUN_ACTION_ADD: + { + unsigned int flags = SCST_ADD_LUN_GEN_UA; + + res = scst_parse_add_repl_param(acg, dev, pp, &virt_lun, + &read_only); + if (res != 0) + goto out_unlock; + + acg_dev = NULL; + list_for_each_entry(acg_dev_tmp, &acg->acg_dev_list, + acg_dev_list_entry) { + if (acg_dev_tmp->lun == virt_lun) { + acg_dev = acg_dev_tmp; + break; + } + } + + if (acg_dev != NULL) { + PRINT_ERROR("virt lun %ld already exists in group %s", + virt_lun, acg->acg_name); + res = -EEXIST; + goto out_unlock; + } + + if (read_only) + flags |= SCST_ADD_LUN_READ_ONLY; + res = scst_acg_add_lun(acg, + tgt_kobj ? tgt->tgt_luns_kobj : acg->luns_kobj, + dev, virt_lun, flags, NULL); + if (res != 0) + goto out_unlock; + break; + } case SCST_LUN_ACTION_REPLACE: { bool dev_replaced = false; @@ -1421,20 +1454,12 @@ static int __scst_process_luns_mgmt_store(char *buffer, } if (acg_dev != NULL) { - if (action == SCST_LUN_ACTION_ADD) { - PRINT_ERROR("virt lun %ld already exists in " - "group %s", virt_lun, acg->acg_name); - res = -EEXIST; + /* Replace */ + res = scst_acg_del_lun(acg, acg_dev->lun, false); + if (res != 0) goto out_unlock; - } else { - /* Replace */ - res = scst_acg_del_lun(acg, acg_dev->lun, - false); - if (res != 0) - goto out_unlock; - dev_replaced = true; - } + dev_replaced = true; } if (read_only) From da3b803d815b0bc114bd9192ed55d71d9fac098f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Mar 2016 23:10:10 +0000 Subject: [PATCH 100/121] scst_lib: Introduce __scst_acg_del_lun() This patch does not change any functionality. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6833 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 51 +++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 9ebd84083..8cc9a22b1 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4459,15 +4459,16 @@ out_free: goto out; } -/* The activity supposed to be suspended and scst_mutex held */ -int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, - bool gen_report_luns_changed) +/* Delete a LUN without generating a unit attention. */ +static struct scst_acg_dev *__scst_acg_del_lun(struct scst_acg *acg, + uint64_t lun, + bool *report_luns_changed) { - int res = 0; struct scst_acg_dev *acg_dev = NULL, *a; struct scst_tgt_dev *tgt_dev, *tt; - TRACE_ENTRY(); + scst_assert_activity_suspended(); + lockdep_assert_held(&scst_mutex); list_for_each_entry(a, &acg->acg_dev_list, acg_dev_list_entry) { if (a->lun == lun) { @@ -4475,13 +4476,11 @@ int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, break; } } - if (acg_dev == NULL) { - PRINT_ERROR("Device is not found in group %s", acg->acg_name); - res = -EINVAL; + if (acg_dev == NULL) goto out; - } - gen_report_luns_changed = scst_cm_on_del_lun(acg_dev, gen_report_luns_changed); + *report_luns_changed = scst_cm_on_del_lun(acg_dev, + *report_luns_changed); list_for_each_entry_safe(tgt_dev, tt, &acg_dev->dev->dev_tgt_dev_list, dev_tgt_dev_list_entry) { @@ -4491,12 +4490,38 @@ int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, scst_del_free_acg_dev(acg_dev, true); - if (gen_report_luns_changed) - scst_report_luns_changed(acg); - PRINT_INFO("Removed LUN %lld from group %s (target %s)", lun, acg->acg_name, acg->tgt ? acg->tgt->tgt_name : "?"); +out: + return acg_dev; +} + +/* + * Delete a LUN and generate a unit attention if gen_report_luns_changed is + * true. + */ +int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, + bool gen_report_luns_changed) +{ + int res = 0; + struct scst_acg_dev *acg_dev; + + TRACE_ENTRY(); + + scst_assert_activity_suspended(); + lockdep_assert_held(&scst_mutex); + + acg_dev = __scst_acg_del_lun(acg, lun, &gen_report_luns_changed); + if (acg_dev == NULL) { + PRINT_ERROR("Device is not found in group %s", acg->acg_name); + res = -EINVAL; + goto out; + } + + if (gen_report_luns_changed) + scst_report_luns_changed(acg); + out: TRACE_EXIT_RES(res); return res; From cf459edf685f4ced7a697221a71cfefe5f966feb Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Mar 2016 23:10:39 +0000 Subject: [PATCH 101/121] scst: Move LUN replacement code to scst_lib Move the code for LUN replacement from scst_sysfs.c into scst_lib.c. This patch reduces code duplication by calling __scst_acg_del_lun() from inside the LUN reassignment code. This patch does not change any functionality. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6834 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 41 +++++++++++++++++++++++++++++++++++ scst/src/scst_priv.h | 5 +++++ scst/src/scst_sysfs.c | 50 +++++-------------------------------------- 3 files changed, 51 insertions(+), 45 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 8cc9a22b1..4e4cd6bbd 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4527,6 +4527,47 @@ out: return res; } +/* + * Either add or replace a LUN. The repl_gen_ua argument controls whether or + * not a unit attention is triggered if LUN reassignment is performed. + */ +int scst_acg_repl_lun(struct scst_acg *acg, struct kobject *parent, + struct scst_device *dev, uint64_t lun, + unsigned flags) +{ + struct scst_acg_dev *acg_dev; + bool del_gen_ua = false; + int res = -EINVAL; + + scst_assert_activity_suspended(); + lockdep_assert_held(&scst_mutex); + + acg_dev = __scst_acg_del_lun(acg, lun, &del_gen_ua); + if (!acg_dev) + flags |= SCST_ADD_LUN_GEN_UA; + res = scst_acg_add_lun(acg, parent, dev, lun, flags, NULL); + if (res != 0) + goto out; + + if (acg_dev && (flags & SCST_REPL_LUN_GEN_UA)) { + struct scst_tgt_dev *tgt_dev; + + list_for_each_entry(tgt_dev, &dev->dev_tgt_dev_list, + dev_tgt_dev_list_entry) { + if (tgt_dev->acg_dev->acg == acg && + tgt_dev->lun == lun) { + TRACE_MGMT_DBG("INQUIRY DATA HAS CHANGED" + " on tgt_dev %p", tgt_dev); + scst_gen_aen_or_ua(tgt_dev, + SCST_LOAD_SENSE(scst_sense_inquiry_data_changed)); + } + } + } + +out: + return res; +} + /* The activity supposed to be suspended and scst_mutex held */ int scst_alloc_add_acg(struct scst_tgt *tgt, const char *acg_name, bool tgt_acg, struct scst_acg **out_acg) diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 9347d4daf..5a5c63a30 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -366,11 +366,16 @@ void scst_nexus_loss(struct scst_tgt_dev *tgt_dev, bool queue_UA); #define SCST_ADD_LUN_READ_ONLY 1 #define SCST_ADD_LUN_GEN_UA 2 #define SCST_ADD_LUN_CM 4 +#define SCST_REPL_LUN_GEN_UA 8 + int scst_acg_add_lun(struct scst_acg *acg, struct kobject *parent, struct scst_device *dev, uint64_t lun, unsigned int flags, struct scst_acg_dev **out_acg_dev); int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, bool gen_report_luns_changed); +int scst_acg_repl_lun(struct scst_acg *acg, struct kobject *parent, + struct scst_device *dev, uint64_t lun, + unsigned flags); int scst_acg_add_acn(struct scst_acg *acg, const char *name); #ifdef CONFIG_SCST_PROC diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index e253b888d..73abe11f4 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1436,57 +1436,17 @@ static int __scst_process_luns_mgmt_store(char *buffer, } case SCST_LUN_ACTION_REPLACE: { - bool dev_replaced = false; - unsigned int flags = 0; + unsigned int flags = (read_only ? SCST_ADD_LUN_READ_ONLY : 0) | + (replace_gen_ua ? SCST_REPL_LUN_GEN_UA : 0); res = scst_parse_add_repl_param(acg, dev, pp, &virt_lun, &read_only); if (res != 0) goto out_unlock; - acg_dev = NULL; - list_for_each_entry(acg_dev_tmp, &acg->acg_dev_list, - acg_dev_list_entry) { - if (acg_dev_tmp->lun == virt_lun) { - acg_dev = acg_dev_tmp; - break; - } - } - - if (acg_dev != NULL) { - /* Replace */ - res = scst_acg_del_lun(acg, acg_dev->lun, false); - if (res != 0) - goto out_unlock; - - dev_replaced = true; - } - - if (read_only) - flags |= SCST_ADD_LUN_READ_ONLY; - if (!dev_replaced) - flags |= SCST_ADD_LUN_GEN_UA; - res = scst_acg_add_lun(acg, - tgt_kobj ? tgt->tgt_luns_kobj : acg->luns_kobj, - dev, virt_lun, flags, NULL); - if (res != 0) - goto out_unlock; - - if (dev_replaced && replace_gen_ua) { - struct scst_tgt_dev *tgt_dev; - - list_for_each_entry(tgt_dev, &dev->dev_tgt_dev_list, - dev_tgt_dev_list_entry) { - if ((tgt_dev->acg_dev->acg == acg) && - (tgt_dev->lun == virt_lun)) { - TRACE_MGMT_DBG("INQUIRY DATA HAS CHANGED" - " on tgt_dev %p", tgt_dev); - scst_gen_aen_or_ua(tgt_dev, - SCST_LOAD_SENSE(scst_sense_inquiry_data_changed)); - } - } - } - + res = scst_acg_repl_lun(acg, tgt_kobj ? tgt->tgt_luns_kobj : + acg->luns_kobj, dev, virt_lun, + flags); break; } case SCST_LUN_ACTION_DEL: From eff3021fb563e7497d1e11cfa63e345532e6d596 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 24 Mar 2016 04:08:12 +0000 Subject: [PATCH 102/121] scst: Port to Linux kernel v4.6 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6835 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/nthread.c | 2 +- scst/include/backport.h | 34 ++++++++++++++++++++++++++++++ scst/src/dev_handlers/scst_user.c | 4 ++-- scst/src/dev_handlers/scst_vdisk.c | 16 +++++++------- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index 65671bace..4874c7c62 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -1371,7 +1371,7 @@ retry: set_fs(KERNEL_DS); res = vfs_writev(file, (struct iovec __force __user *)iop, - count, &off); + count, &off, 0); set_fs(oldfs); TRACE_WRITE("sid %#Lx, cid %u, res %d, iov_len %zd", (unsigned long long int)conn->session->sid, diff --git a/scst/include/backport.h b/scst/include/backport.h index d12657087..d791e555d 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -212,6 +212,25 @@ static inline struct inode *file_inode(const struct file *f) } #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) +static inline ssize_t vfs_readv_backport(struct file *file, + const struct iovec __user *vec, + unsigned long vlen, loff_t *pos, + int flags) +{ + return vfs_readv(file, vec, vlen, pos); +} +static inline ssize_t vfs_writev_backport(struct file *file, + const struct iovec __user *vec, + unsigned long vlen, loff_t *pos, + int flags) +{ + return vfs_writev(file, vec, vlen, pos); +} +#define vfs_readv vfs_readv_backport +#define vfs_writev vfs_writev_backport +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) static inline int vfs_fsync_backport(struct file *file, int datasync) { @@ -325,6 +344,21 @@ static inline bool list_entry_in_list(const struct list_head *entry) #define lockdep_assert_held(l) do { (void)(l); } while (0) #endif +/* */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) +static inline long get_user_pages_backport(unsigned long start, + unsigned long nr_pages, + int write, int force, + struct page **pages, + struct vm_area_struct **vmas) +{ + return get_user_pages(current, current->mm, start, nr_pages, write, + force, pages, vmas); +} +#define get_user_pages get_user_pages_backport +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 1615572bf..20dd9da8d 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -1267,8 +1267,8 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff, (ucmd->cmd != NULL) ? ucmd->cmd->bufflen : -1); down_read(&tsk->mm->mmap_sem); - rc = get_user_pages(tsk, tsk->mm, ubuff, ucmd->num_data_pages, - 1/*writable*/, 0/*don't force*/, ucmd->data_pages, NULL); + rc = get_user_pages(ubuff, ucmd->num_data_pages, 1/*writable*/, + 0/*don't force*/, ucmd->data_pages, NULL); up_read(&tsk->mm->mmap_sem); /* get_user_pages() flushes dcache */ diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index a420fdce5..559d79781 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -2023,8 +2023,8 @@ static int vdisk_format_dif(struct scst_cmd *cmd, uint64_t start_lba, full_len, (long long)loff); /* WRITE */ - err = vfs_writev(fd, (struct iovec __force __user *)iv, iv_count, - &loff); + err = vfs_writev(fd, (struct iovec __force __user *)iv, + iv_count, &loff, 0); if (err < 0) { PRINT_ERROR("Formatting DIF write() returned %lld from " "%zd", (long long)err, full_len); @@ -5860,7 +5860,7 @@ static int vdev_read_dif_tags(struct vdisk_cmd_params *p) /* READ */ err = vfs_readv(fd, (struct iovec __force __user *)iv, iv_count, - &loff); + &loff, 0); if ((err < 0) || (err < full_len)) { unsigned long flags; @@ -5994,8 +5994,8 @@ restart: TRACE_DBG("Writing DIF: eiv_count %d, full_len %zd", eiv_count, full_len); /* WRITE */ - err = vfs_writev(fd, (struct iovec __force __user *)eiv, eiv_count, - &loff); + err = vfs_writev(fd, (struct iovec __force __user *)eiv, + eiv_count, &loff, 0); if (err < 0) { unsigned long flags; @@ -6141,7 +6141,7 @@ static enum compl_status_e fileio_exec_read(struct vdisk_cmd_params *p) /* READ */ err = vfs_readv(fd, (struct iovec __force __user *)iv, iv_count, - &loff); + &loff, 0); if ((err < 0) || (err < full_len)) { PRINT_ERROR("readv() returned %lld from %zd", (unsigned long long int)err, @@ -6334,8 +6334,8 @@ restart: TRACE_DBG("Writing: eiv_count %d, full_len %zd", eiv_count, full_len); /* WRITE */ - err = vfs_writev(fd, (struct iovec __force __user *)eiv, eiv_count, - &loff); + err = vfs_writev(fd, (struct iovec __force __user *)eiv, + eiv_count, &loff, 0); if (err < 0) { PRINT_ERROR("write() returned %lld from %zd", (unsigned long long int)err, From 4f10d6254e07fedfcb7a35189786b7e354165a04 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 24 Mar 2016 17:13:06 +0000 Subject: [PATCH 103/121] scst_vdisk: Remove superfluous semicolons git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6836 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 559d79781..b967c7c1b 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -2045,7 +2045,7 @@ static int vdisk_format_dif(struct scst_cmd *cmd, uint64_t start_lba, } virt_dev->format_progress_done = done; - }; + } out_set_fs: set_fs(old_fs); @@ -5885,7 +5885,7 @@ static int vdev_read_dif_tags(struct vdisk_cmd_params *p) if (finished) break; - }; + } set_fs(old_fs); @@ -6047,7 +6047,7 @@ restart: if (finished) break; - }; + } set_fs(old_fs); @@ -6162,7 +6162,7 @@ static enum compl_status_e fileio_exec_read(struct vdisk_cmd_params *p) break; length = scst_get_buf_next(cmd, (uint8_t __force **)&address); - }; + } set_fs(old_fs); From fef250eb90d27e4a788ef17cbb2e445112d82d41 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 24 Mar 2016 17:13:46 +0000 Subject: [PATCH 104/121] scst_vdisk: Introduce vdisk_on_free_cmd_params() This patch does not change any functionality. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6837 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index b967c7c1b..22bf2dcad 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3500,6 +3500,12 @@ static int fileio_exec(struct scst_cmd *cmd) return vdev_do_job(cmd, ops); } +static void vdisk_on_free_cmd_params(const struct vdisk_cmd_params *p) +{ + if (p->iv != p->small_iv) + kfree(p->iv); +} + static void fileio_on_free_cmd(struct scst_cmd *cmd) { struct vdisk_cmd_params *p = cmd->dh_priv; @@ -3524,8 +3530,7 @@ static void fileio_on_free_cmd(struct scst_cmd *cmd) cmd->data_len = 0; } - if (p->iv != p->small_iv) - kfree(p->iv); + vdisk_on_free_cmd_params(p); kmem_cache_free(vdisk_cmd_param_cachep, p); From 3a7a5e728905a13a030e029a4f6649fd33c856ed Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 24 Mar 2016 17:14:29 +0000 Subject: [PATCH 105/121] scst_vdisk: Fix handling of vdisk_cmd_params::iv Avoid that the iv pointer can become a dangling pointer for vdisk_fileio devices. Freeing iv without resetting iv_count makes it namely possible that iv will be used after the memory that pointer points at has been freed. For vdisk_blockio devices, call vdisk_on_free_cmd_params() to free the iv pointer. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6838 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 22bf2dcad..ceb0c26a5 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -3640,6 +3640,7 @@ static int blockio_exec(struct scst_cmd *cmd) cmd->dh_priv = NULL; out: + vdisk_on_free_cmd_params(&p); return res; err: @@ -3667,6 +3668,7 @@ static int nullio_exec(struct scst_cmd *cmd) cmd->dh_priv = NULL; out: + vdisk_on_free_cmd_params(&p); return res; err: @@ -5792,7 +5794,6 @@ static int vdev_read_dif_tags(struct vdisk_cmd_params *p) bool finished = false; int tags_num, l; struct scatterlist *tags_sg; - bool free_iv = false; TRACE_ENTRY(); @@ -5827,7 +5828,6 @@ static int vdev_read_dif_tags(struct vdisk_cmd_params *p) res = -ENOMEM; goto out; } - free_iv = true; } max_iv_count = p->iv_count; @@ -5894,10 +5894,6 @@ static int vdev_read_dif_tags(struct vdisk_cmd_params *p) set_fs(old_fs); -out_free_iv: - if (free_iv && (iv != p->small_iv)) - kfree(p->iv); - out: TRACE_EXIT_RES(res); return res; @@ -5906,7 +5902,7 @@ out_set_fs: set_fs(old_fs); for (i = 0; i < iv_count; i++) scst_put_dif_buf(cmd, (void __force *)(iv[i].iov_base)); - goto out_free_iv; + goto out; } static int vdev_write_dif_tags(struct vdisk_cmd_params *p) @@ -5925,7 +5921,6 @@ static int vdev_write_dif_tags(struct vdisk_cmd_params *p) bool finished = false; int tags_num, l; struct scatterlist *tags_sg; - bool free_iv = false; TRACE_ENTRY(); @@ -5960,7 +5955,6 @@ static int vdev_write_dif_tags(struct vdisk_cmd_params *p) res = -ENOMEM; goto out; } - free_iv = true; } max_iv_count = p->iv_count; @@ -6056,10 +6050,6 @@ restart: set_fs(old_fs); -out_free_iv: - if (free_iv && (iv != p->small_iv)) - kfree(iv); - out: TRACE_EXIT_RES(res); return res; @@ -6068,7 +6058,7 @@ out_set_fs: set_fs(old_fs); for (i = 0; i < iv_count; i++) scst_put_dif_buf(cmd, (void __force *)(iv[i].iov_base)); - goto out_free_iv; + goto out; } static enum compl_status_e blockio_exec_read(struct vdisk_cmd_params *p) From 63768c8715aa3df25ce992e598de88992733db2f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 24 Mar 2016 17:14:49 +0000 Subject: [PATCH 106/121] ib_srpt: Fix a debug message git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6839 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index d4fdcbe7a..6cbf2c548 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2183,7 +2183,7 @@ static int srpt_compl_thread(void *arg) } set_current_state(TASK_RUNNING); - pr_debug("%s-%d: about to unregister this session()\n", + pr_debug("%s-%d: about to unregister this session\n", ch->sess_name, ch->qp->qp_num); scst_unregister_session(ch->sess, false, srpt_unreg_sess); From 8695583ee9eb69072212ec00779392af14c649d4 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 24 Mar 2016 17:15:23 +0000 Subject: [PATCH 107/121] ib_srpt: Reduce CPU load caused by stopping a large number of sessions Avoid that stopping a large number of SRPT sessions causes a high context switch frequency and hence a high CPU load. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6840 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 6cbf2c548..f4f0f698a 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2187,8 +2187,12 @@ static int srpt_compl_thread(void *arg) ch->sess_name, ch->qp->qp_num); scst_unregister_session(ch->sess, false, srpt_unreg_sess); - while (!kthread_should_stop()) - schedule_timeout(DIV_ROUND_UP(HZ, 10)); + set_current_state(TASK_INTERRUPTIBLE); + while (!kthread_should_stop()) { + schedule(); + set_current_state(TASK_INTERRUPTIBLE); + } + __set_current_state(TASK_RUNNING); return 0; } From 7289593aff34b3d46bfef168d86a1924c79ce3c8 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 15:50:21 +0000 Subject: [PATCH 108/121] scst: Fix checkpatch complaints about using spaces for indentation instead of tabs git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6841 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 2 +- scst/src/dev_handlers/scst_user.c | 8 ++++---- scst/src/scst_event.c | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index d791e555d..c28298034 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -53,7 +53,7 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 20) #ifndef __printf -#define __printf(a, b) __attribute__((format(printf,a,b))) +#define __printf(a, b) __attribute__((format(printf, a, b))) #endif #endif diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 20dd9da8d..40b1a902b 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -36,10 +36,10 @@ #ifndef INSIDE_KERNEL_TREE #if defined(CONFIG_HIGHMEM4G) || defined(CONFIG_HIGHMEM64G) -#warning HIGHMEM kernel configurations are not supported by this module,\ - because nowadays it is not worth the effort. Consider changing\ - VMSPLIT option or use a 64-bit configuration instead. See README file\ - for details. +#warning HIGHMEM kernel configurations are not supported by this module, \ +because nowadays it is not worth the effort. Consider changing \ +VMSPLIT option or use a 64-bit configuration instead. See README file \ +for details. #endif #endif diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index a5ca67dda..11de3c1be 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -1091,13 +1091,13 @@ int scst_event_init(void) } #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 21) - class_member = class_device_create(scst_event_sysfs_class, NULL, + class_member = class_device_create(scst_event_sysfs_class, NULL, MKDEV(scst_event_major, 0), NULL, SCST_EVENT_NAME); - if (IS_ERR(class_member)) { - res = PTR_ERR(class_member); - goto out_chrdev; - } + if (IS_ERR(class_member)) { + res = PTR_ERR(class_member); + goto out_chrdev; + } #else dev = device_create(scst_event_sysfs_class, NULL, MKDEV(scst_event_major, 0), From b109098efe7ec1a16181c801fc2313904d252606 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 15:52:41 +0000 Subject: [PATCH 109/121] ib_srpt: Fix checkpatch complaints about missing spaces git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6842 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/conftest/register_mad_agent/register_mad_agent.c | 2 +- srpt/src/ib_srpt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/srpt/conftest/register_mad_agent/register_mad_agent.c b/srpt/conftest/register_mad_agent/register_mad_agent.c index fe0421c2b..c464f1443 100644 --- a/srpt/conftest/register_mad_agent/register_mad_agent.c +++ b/srpt/conftest/register_mad_agent/register_mad_agent.c @@ -7,7 +7,7 @@ static int modinit(void) a = ib_register_mad_agent(NULL, 0, 0, NULL, 0, NULL, NULL, NULL, 0); - return a!= 0; + return a != 0; } module_init(modinit); diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 25f816593..c4c14b2f3 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -52,7 +52,7 @@ #define vlan_dev_vlan_id(dev) (panic("RHEL 5 misses vlan_dev_vlan_id()"),0) #endif #if defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 6 -#define __ethtool_get_settings(dev, cmd) (panic("RHEL misses __ethtool_get_settings()"),0) +#define __ethtool_get_settings(dev, cmd) (panic("RHEL misses __ethtool_get_settings()"), 0) #endif #include #include From d4fc2435ec702710f95ed88c9625654ce0e36ef5 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 15:55:41 +0000 Subject: [PATCH 110/121] scst_mem: Remove a superfluous cast git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6843 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 281ca0e9e..56d51c09c 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -366,7 +366,7 @@ static unsigned long __sgv_can_be_shrunk(void) } spin_unlock_bh(&sgv_pools_lock); - res = max((int)0, inactive_pages - sgv_lo_wmk); + res = max(0, inactive_pages - sgv_lo_wmk); TRACE_MEM("Can free %ld (total %d)", res, atomic_read(&sgv_pages_total)); TRACE_EXIT_RES(res); From 45a032c3573391415f796dd52d504b4ecabc16d5 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 15:57:03 +0000 Subject: [PATCH 111/121] fcst: Remove a CVS keyword marker git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6844 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- fcst/fcst.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/fcst/fcst.h b/fcst/fcst.h index 771937a3a..9e403835f 100644 --- a/fcst/fcst.h +++ b/fcst/fcst.h @@ -13,8 +13,6 @@ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - * - * $Id$ */ #ifndef __SCSI_FCST_H__ #define __SCSI_FCST_H__ From 4dfb9d10c7a727c8551cb42d8006b9926cb15eff Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 15:57:41 +0000 Subject: [PATCH 112/121] fcst: Change "signed" into "signed int" git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6845 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- fcst/ft_cmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fcst/ft_cmd.c b/fcst/ft_cmd.c index e0b0baa2f..adc297847 100644 --- a/fcst/ft_cmd.c +++ b/fcst/ft_cmd.c @@ -330,7 +330,7 @@ int ft_send_response(struct scst_cmd *cmd) * For bi-directional comands, the bi_resid is for the read direction. */ if (dir & SCST_DATA_WRITE) - resid = (signed)scst_cmd_get_bufflen(cmd) - + resid = (signed int)scst_cmd_get_bufflen(cmd) - fcmd->write_data_len; if (dir & SCST_DATA_READ) { error = ft_send_read_data(cmd); @@ -340,12 +340,12 @@ int ft_send_response(struct scst_cmd *cmd) } if (dir == SCST_DATA_BIDI) { - bi_resid = (signed)scst_cmd_get_out_bufflen(cmd) - + bi_resid = (signed int)scst_cmd_get_out_bufflen(cmd) - scst_cmd_get_resp_data_len(cmd); if (bi_resid) len += sizeof(__be32); } else - resid = (signed)scst_cmd_get_bufflen(cmd) - + resid = (signed int)scst_cmd_get_bufflen(cmd) - scst_cmd_get_resp_data_len(cmd); } From 3ab98d81744ccca1d08bce2532e9a2c0be9f4803 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 16:10:26 +0000 Subject: [PATCH 113/121] iscsi-scst: Fix checkpatch complaints about whitespace git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6846 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/config.c | 14 +++++++------- iscsi-scst/kernel/conn.c | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/iscsi-scst/kernel/config.c b/iscsi-scst/kernel/config.c index 557aedac2..b4c7e842e 100644 --- a/iscsi-scst/kernel/config.c +++ b/iscsi-scst/kernel/config.c @@ -31,13 +31,13 @@ int ctr_open_state; #define ISCSI_PROC_LOG_ENTRY_NAME "trace_level" static struct scst_trace_log iscsi_local_trace_tbl[] = { - { TRACE_D_WRITE, "d_write" }, - { TRACE_CONN_OC, "conn" }, - { TRACE_CONN_OC_DBG, "conn_dbg" }, - { TRACE_D_IOV, "iov" }, - { TRACE_D_DUMP_PDU, "pdu" }, - { TRACE_NET_PG, "net_page" }, - { 0, NULL } + { TRACE_D_WRITE, "d_write" }, + { TRACE_CONN_OC, "conn" }, + { TRACE_CONN_OC_DBG, "conn_dbg" }, + { TRACE_D_IOV, "iov" }, + { TRACE_D_DUMP_PDU, "pdu" }, + { TRACE_NET_PG, "net_page" }, + { 0, NULL } }; static int iscsi_log_info_show(struct seq_file *seq, void *v) diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index 7224e1abf..3b1de7fea 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -103,7 +103,7 @@ void conn_info_show(struct seq_file *seq, struct iscsi_session *session) switch (sk->sk_family) { case AF_INET: snprintf(buf, sizeof(buf), -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) "%u.%u.%u.%u", NIPQUAD(inet_sk(sk)->daddr)); #else "%pI4", &inet_sk(sk)->inet_daddr); @@ -111,7 +111,7 @@ void conn_info_show(struct seq_file *seq, struct iscsi_session *session) break; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) case AF_INET6: -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) snprintf(buf, sizeof(buf), "[%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]", NIP6(inet6_sk(sk)->daddr)); From 2681ed8bcbf254c09a56c48da8aaf17032ed3031 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 16:10:45 +0000 Subject: [PATCH 114/121] iscsi-scstd: Fix checkpatch complaints about whitespace git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6847 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/usr/chap.c | 20 ++++++++++---------- iscsi-scst/usr/ctldev.c | 2 +- iscsi-scst/usr/event.c | 2 +- iscsi-scst/usr/iscsi_scstd.c | 4 ++-- iscsi-scst/usr/iscsid.c | 28 ++++++++++++++-------------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/iscsi-scst/usr/chap.c b/iscsi-scst/usr/chap.c index 5c9c2fd13..9b7b1e054 100644 --- a/iscsi-scst/usr/chap.c +++ b/iscsi-scst/usr/chap.c @@ -171,7 +171,7 @@ static inline void encode_hex_string(u8 *intnum, long length, char *string) strptr = string; for (i = 0; i < length; i++, strptr += 2) - sprintf(strptr, "%.2hhx", intnum[i]); + sprintf(strptr, "%.2hhx", intnum[i]); } /* Base64 encoding, taken from UNH iSCSI "IntegerToBase64String()" */ @@ -339,15 +339,15 @@ static inline void chap_calc_digest_sha1(char chap_id, const char *secret, int s */ static int chap_rand(void) { - int fd; - int r; + int fd; + int r; - fd = open("/dev/urandom", O_RDONLY); - assert(fd != -1); - if (read(fd, &r, sizeof(r)) < sizeof(r)) { - } - close(fd); - return r; + fd = open("/dev/urandom", O_RDONLY); + assert(fd != -1); + if (read(fd, &r, sizeof(r)) < sizeof(r)) { + } + close(fd); + return r; } static int chap_initiator_auth_create_challenge(struct connection *conn) @@ -639,7 +639,7 @@ int cmnd_exec_auth_chap(struct connection *conn) { int res; - switch(conn->auth_state) { + switch (conn->auth_state) { case CHAP_AUTH_STATE_START: res = chap_initiator_auth_create_challenge(conn); break; diff --git a/iscsi-scst/usr/ctldev.c b/iscsi-scst/usr/ctldev.c index 38bbba576..08db4d72b 100644 --- a/iscsi-scst/usr/ctldev.c +++ b/iscsi-scst/usr/ctldev.c @@ -298,7 +298,7 @@ int kernel_params_get(u32 tid, u64 sid, int type, struct iscsi_param *params) if ((err = ioctl(ctrl_fd, ISCSI_PARAM_GET, &info)) < 0) { err = -errno; - log_debug(1, "Can't get session params for session 0x%" PRIx64 + log_debug(1, "Can't get session params for session 0x%" PRIx64 " (tid %u, err %d): %s\n", sid, tid, err, strerror(errno)); } diff --git a/iscsi-scst/usr/event.c b/iscsi-scst/usr/event.c index fef761a4f..7bbd1f418 100644 --- a/iscsi-scst/usr/event.c +++ b/iscsi-scst/usr/event.c @@ -57,7 +57,7 @@ static int nl_write(int fd, void *data, int len) nlh.nlmsg_type = 0; memset(&msg, 0, sizeof(msg)); - msg.msg_name= (void *)&dest_addr; + msg.msg_name = (void *)&dest_addr; msg.msg_namelen = sizeof(dest_addr); msg.msg_iov = iov; msg.msg_iovlen = 2; diff --git a/iscsi-scst/usr/iscsi_scstd.c b/iscsi-scst/usr/iscsi_scstd.c index a12c8dcb7..31bcc7f3a 100644 --- a/iscsi-scst/usr/iscsi_scstd.c +++ b/iscsi-scst/usr/iscsi_scstd.c @@ -40,7 +40,7 @@ #include "iscsid.h" #include "iscsi_adm.h" -static char* server_address; +static char *server_address; uint16_t server_port = ISCSI_LISTEN_PORT; struct pollfd poll_array[POLL_MAX]; @@ -620,7 +620,7 @@ again: switch (conn->state) { case STATE_KERNEL: conn_pass_to_kern(conn, pollfd->fd); - if(conn->passed_to_kern) + if (conn->passed_to_kern) conn->state = STATE_CLOSE; else conn->state = STATE_EXIT; diff --git a/iscsi-scst/usr/iscsid.c b/iscsi-scst/usr/iscsid.c index ef8f08fa2..85c33d10f 100644 --- a/iscsi-scst/usr/iscsid.c +++ b/iscsi-scst/usr/iscsid.c @@ -576,7 +576,7 @@ static void login_start(struct connection *conn) if (!config_initiator_access_allowed(conn->tid, conn->fd) || !target_portal_allowed(target, conn->target_portal, - conn->initiator) || + conn->initiator) || !isns_scn_access_allowed(conn->tid, name)) { log_info("Initiator %s not allowed to connect to " "target %s", name, target_name); @@ -698,21 +698,21 @@ static void cmnd_reject(struct connection *conn, u8 reason) static int cmnd_exec_auth(struct connection *conn) { - int res; + int res; - switch (conn->auth_method) { - case AUTH_CHAP: - res = cmnd_exec_auth_chap(conn); - break; - case AUTH_NONE: - res = 0; - break; - default: - log_error("Unknown auth. method %d", conn->auth_method); - res = -3; - } + switch (conn->auth_method) { + case AUTH_CHAP: + res = cmnd_exec_auth_chap(conn); + break; + case AUTH_NONE: + res = 0; + break; + default: + log_error("Unknown auth. method %d", conn->auth_method); + res = -3; + } - return res; + return res; } static void cmnd_exec_login(struct connection *conn) From c477b5f99cd9706f9602bfa87ef62eb2b40356ba Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 16:16:06 +0000 Subject: [PATCH 115/121] iscsi-scstd: Fix more checkpatch complaints about whitespace git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6848 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/usr/isns.c | 6 +++--- iscsi-scst/usr/md5.c | 6 +++--- iscsi-scst/usr/misc.h | 16 ++++++++-------- iscsi-scst/usr/param.c | 2 +- iscsi-scst/usr/sha1.c | 12 ++++++------ iscsi-scst/usr/target.c | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/iscsi-scst/usr/isns.c b/iscsi-scst/usr/isns.c index c7d8fcca5..d33688e32 100644 --- a/iscsi-scst/usr/isns.c +++ b/iscsi-scst/usr/isns.c @@ -507,9 +507,9 @@ int isns_target_register(char *name) err = isns_tlv_set(&tlv, max_buf - length, ISNS_ATTR_ISCSI_NAME, strlen(isns_entity_target_name) + 1, isns_entity_target_name); } -if (err < 0) + if (err < 0) goto out; - length += err; + length += err; err = isns_tlv_set(&tlv, max_buf - length, ISNS_ATTR_ENTITY_IDENTIFIER, strlen(eid) + 1, eid); @@ -1010,7 +1010,7 @@ static int send_scn_rsp(char *name, uint16_t transaction) *((uint32_t *)hdr->pdu) = 0; max_buf = sizeof(buf) - offsetof(struct isns_hdr, pdu); tlv = (struct isns_tlv *)((char *)hdr->pdu + 4); - length +=4; + length += 4; err = isns_tlv_set(&tlv, max_buf - length, ISNS_ATTR_ISCSI_NAME, strlen(name) + 1, name); diff --git a/iscsi-scst/usr/md5.c b/iscsi-scst/usr/md5.c index 746eef545..fcd7cdf2d 100644 --- a/iscsi-scst/usr/md5.c +++ b/iscsi-scst/usr/md5.c @@ -1,4 +1,4 @@ -/* +/* * MD5 Message Digest Algorithm (RFC1321). * * Derived from cryptoapi implementation, originally based on the @@ -6,10 +6,10 @@ * * Copyright (c) Cryptoapi developers. * Copyright (c) 2002 James Morris - * + * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) + * Software Foundation; either version 2 of the License, or (at your option) * any later version. * */ diff --git a/iscsi-scst/usr/misc.h b/iscsi-scst/usr/misc.h index ef5dbd4bd..eb388e1ad 100644 --- a/iscsi-scst/usr/misc.h +++ b/iscsi-scst/usr/misc.h @@ -25,7 +25,7 @@ struct __qelem { #undef offsetof #ifdef __compiler_offsetof -#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) +#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER) #else #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif @@ -45,19 +45,19 @@ static inline int list_empty(const struct __qelem *head) static inline int list_length_is_one(const struct __qelem *head) { - return (!list_empty(head) && head->q_forw == head->q_back); + return (!list_empty(head) && head->q_forw == head->q_back); } #define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) #define list_entry(ptr, type, member) \ container_of(ptr, type, member) #define list_for_each_entry(pos, head, member) \ for (pos = list_entry((head)->q_forw, typeof(*pos), member); \ - &pos->member != (head); \ + &pos->member != (head); \ pos = list_entry(pos->member.q_forw, typeof(*pos), member)) #define list_for_each_entry_safe(pos, n, head, member) \ @@ -73,7 +73,7 @@ static inline int list_length_is_one(const struct __qelem *head) INIT_LIST_HEAD(elem); \ } while (0) -#define list_add(new, head) insque (new, head) +#define list_add(new, head) insque(new, head) #define list_add_tail(new, head) insque(new, (head)->q_back) @@ -94,12 +94,12 @@ static inline int list_length_is_one(const struct __qelem *head) #define min_t(type, x, y) ({ \ type __min1 = (x); \ type __min2 = (y); \ - __min1 < __min2 ? __min1: __min2; }) + __min1 < __min2 ? __min1 : __min2; }) #define max_t(type, x, y) ({ \ type __max1 = (x); \ type __max2 = (y); \ - __max1 > __max2 ? __max1: __max2; }) + __max1 > __max2 ? __max1 : __max2; }) #ifndef IPV6_V6ONLY #define IPV6_V6ONLY 26 diff --git a/iscsi-scst/usr/param.c b/iscsi-scst/usr/param.c index afdc83628..e289aa9fa 100644 --- a/iscsi-scst/usr/param.c +++ b/iscsi-scst/usr/param.c @@ -337,7 +337,7 @@ static struct iscsi_key_ops marker_ops = { .set_val = marker_set_val, }; -#define SET_KEY_VALUES(x) DEFAULT_##x,DEFAULT_##x,MIN_##x,MAX_##x +#define SET_KEY_VALUES(x) DEFAULT_##x, DEFAULT_##x, MIN_##x, MAX_##x /* * List of local target keys with initial values. diff --git a/iscsi-scst/usr/sha1.c b/iscsi-scst/usr/sha1.c index 52771c459..e92dbac83 100644 --- a/iscsi-scst/usr/sha1.c +++ b/iscsi-scst/usr/sha1.c @@ -17,9 +17,9 @@ #include "sha1.h" /* SHA1 transforms */ -#define F1(x,y,z) (z ^ (x & (y ^ z))) /* x ? y : z */ -#define F2(x,y,z) (x ^ y ^ z) /* XOR */ -#define F3(x,y,z) ((x & y) + (z & (x ^ y))) /* majority */ +#define F1(x, y, z) (z ^ (x & (y ^ z))) /* x ? y : z */ +#define F2(x, y, z) (x ^ y ^ z) /* XOR */ +#define F3(x, y, z) ((x & y) + (z & (x ^ y))) /* majority */ /* SHA1 per-round constants */ #define K1 0x5A827999UL /* Rounds 0-19: sqrt(2) * 2^30 */ @@ -56,17 +56,17 @@ static void __sha1_transform(u32 hash[SHA1_DIGEST_WORDS], e = d; d = c; c = rol32(b, 30); b = a; a = t; } - for (; i < 40; i ++) { + for (; i < 40; i++) { t = F2(b, c, d) + K2 + rol32(a, 5) + e + W[i]; e = d; d = c; c = rol32(b, 30); b = a; a = t; } - for (; i < 60; i ++) { + for (; i < 60; i++) { t = F3(b, c, d) + K3 + rol32(a, 5) + e + W[i]; e = d; d = c; c = rol32(b, 30); b = a; a = t; } - for (; i < 80; i ++) { + for (; i < 80; i++) { t = F2(b, c, d) + K4 + rol32(a, 5) + e + W[i]; e = d; d = c; c = rol32(b, 30); b = a; a = t; } diff --git a/iscsi-scst/usr/target.c b/iscsi-scst/usr/target.c index ad1698e13..25558e629 100644 --- a/iscsi-scst/usr/target.c +++ b/iscsi-scst/usr/target.c @@ -292,7 +292,7 @@ void target_list_build(struct connection *conn, char *target_name) else if (strcmp(conn->target_portal, portal) && !is_addr_loopback(portal) && target_portal_allowed(target, portal, - conn->initiator)) + conn->initiator)) target_print_addr(conn, portal, family); } } From 3990a6ccd4669ef4417f881620cd4ce236090e16 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 16:24:59 +0000 Subject: [PATCH 116/121] iscsi-scstd: Insert a blank line after declarations Additionally, surround complex values with parentheses, declare static char arrays const and change C++ comments into C comments. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6849 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/usr/chap.c | 2 +- iscsi-scst/usr/config.c | 3 +++ iscsi-scst/usr/event.c | 5 +++++ iscsi-scst/usr/iscsi_adm.c | 6 +++--- iscsi-scst/usr/iscsi_scstd.c | 9 ++++++--- iscsi-scst/usr/iscsid.c | 8 ++++++-- iscsi-scst/usr/iscsid.h | 4 ++-- iscsi-scst/usr/isns.c | 1 + iscsi-scst/usr/log.c | 5 ++++- iscsi-scst/usr/param.c | 4 +++- mpt/mpt_scst.c | 2 ++ 11 files changed, 36 insertions(+), 13 deletions(-) diff --git a/iscsi-scst/usr/chap.c b/iscsi-scst/usr/chap.c index 9b7b1e054..dfefae1ac 100644 --- a/iscsi-scst/usr/chap.c +++ b/iscsi-scst/usr/chap.c @@ -575,7 +575,7 @@ static int chap_target_auth_create_response(struct connection *conn) response_len = 2 * digest_len; else response_len = ((digest_len - 1) / 3 + 1) * 4; - //"0x" / "0b" and "\0": + /* "0x" / "0b" and "\0": */ response_len += 3; if (!(digest = malloc(digest_len))) { diff --git a/iscsi-scst/usr/config.c b/iscsi-scst/usr/config.c index 2f1b2dc37..8a11f32ae 100644 --- a/iscsi-scst/usr/config.c +++ b/iscsi-scst/usr/config.c @@ -514,6 +514,7 @@ int __config_account_add(struct target *target, int dir, char *name, char *pass, if (dir == ISCSI_USER_DIR_OUTGOING) { struct iscsi_attr *old; + list_for_each_entry(old, list, ulist) { log_warning("Only one outgoing %s account is " "supported. Replacing the old one.\n", @@ -1061,6 +1062,7 @@ static int config_isns_load(const char *config) isns_server = strdup(config_sep_string(&q)); } else if (!strcasecmp(p, ISCSI_ISNS_ACCESS_CONTROL_ATTR_NAME)) { char *str = config_sep_string(&q); + if (!strcasecmp(str, "No")) isns_access_control = 0; else @@ -1139,6 +1141,7 @@ int config_load(const char *config_name) err = config_isns_load(buf); if ((err == 0) && (isns_server != NULL)) { int rc = isns_init(); + if (rc != 0) { log_error("iSNS server %s init failed: %d", isns_server, rc); isns_exit(); diff --git a/iscsi-scst/usr/event.c b/iscsi-scst/usr/event.c index 7bbd1f418..8d0734767 100644 --- a/iscsi-scst/usr/event.c +++ b/iscsi-scst/usr/event.c @@ -105,6 +105,7 @@ static int strncasecmp_numwild(const char *name, const char *mask) if (!strncasecmp(name, mask, strlen(name))) { int j; + if (strlen(name) > strlen(mask)) goto out; for (j = strlen(name); j < strlen(mask); j++) { @@ -430,6 +431,7 @@ static int handle_e_mgmt_cmd(int fd, const struct iscsi_kern_event *event) res = handle_add_attr(NULL, p, event->cookie); } else if (strcasecmp("add_target_attribute", pp) == 0) { struct target *target; + pp = config_sep_string(&p); target = target_find_by_name(pp); if (target == NULL) { @@ -442,6 +444,7 @@ static int handle_e_mgmt_cmd(int fd, const struct iscsi_kern_event *event) res = handle_del_attr(NULL, p, event->cookie); } else if (strcasecmp("del_target_attribute", pp) == 0) { struct target *target; + pp = config_sep_string(&p); target = target_find_by_name(pp); if (target == NULL) { @@ -465,6 +468,7 @@ out: static void add_key_mark(char *res_str, int res_str_len, int new_line) { int offs = strlen(res_str); + snprintf(&res_str[offs], res_str_len - offs, "%s%s\n", new_line ? "\n" : "", SCST_SYSFS_KEY_MARK); return; @@ -702,6 +706,7 @@ static int handle_target_redirect(struct target *target, char *p) if (inet_pton(AF_INET, addr, &ia) != 1) { char tmp[sizeof(target->redirect.addr)]; + if (*addr == '[') t = addr+1; else diff --git a/iscsi-scst/usr/iscsi_adm.c b/iscsi-scst/usr/iscsi_adm.c index 72a70a8ec..7177d7783 100644 --- a/iscsi-scst/usr/iscsi_adm.c +++ b/iscsi-scst/usr/iscsi_adm.c @@ -46,10 +46,9 @@ enum iscsi_adm_op { OP_SHOW, }; -static char program_name[] = "iscsi-scst-adm"; +static const char program_name[] = "iscsi-scst-adm"; -static struct option const long_options[] = -{ +static struct option const long_options[] = { {"op", required_argument, NULL, 'o'}, {"tid", required_argument, NULL, 't'}, {"sid", required_argument, NULL, 's'}, @@ -278,6 +277,7 @@ static int parse_trgt_params(struct msg_trgt *msg, char *params) while ((p = strsep(¶ms, ",")) != NULL) { int idx; u32 val; + if (!*p) continue; if (!(q = strchr(p, '='))) diff --git a/iscsi-scst/usr/iscsi_scstd.c b/iscsi-scst/usr/iscsi_scstd.c index 31bcc7f3a..147bd3da0 100644 --- a/iscsi-scst/usr/iscsi_scstd.c +++ b/iscsi-scst/usr/iscsi_scstd.c @@ -52,10 +52,9 @@ int conn_blocked; struct iscsi_init_params iscsi_init_params; -static char program_name[] = "iscsi-scstd"; +static const char program_name[] = "iscsi-scstd"; -static struct option const long_options[] = -{ +static struct option const long_options[] = { {"config", required_argument, 0, 'c'}, {"foreground", no_argument, 0, 'f'}, {"debug", required_argument, 0, 'd'}, @@ -209,6 +208,7 @@ out: static int transmit_iser(int fd, bool start) { int opt = start; + return ioctl(fd, RDMA_CORK, &opt, sizeof(opt)); } @@ -370,6 +370,7 @@ out_close: static int transmit_sock(int fd, bool start) { int opt = start; + return setsockopt(fd, SOL_TCP, TCP_CORK, &opt, sizeof(opt)); } @@ -744,6 +745,7 @@ static void event_loop(void) (conn->state == STATE_EXIT) || (conn->state == STATE_DROP)) { struct session *sess = conn->sess; + log_debug(1, "closing conn %p", conn); conn_free_pdu(conn); close(pollfd->fd); @@ -928,6 +930,7 @@ int main(int argc, char **argv) exit(1); } else if (pid) { int res = -1; + close(init_report_pipe[1]); if (read(init_report_pipe[0], &res, sizeof(res)) < sizeof(res)) exit(-1); diff --git a/iscsi-scst/usr/iscsid.c b/iscsi-scst/usr/iscsid.c index 85c33d10f..c0a58fa97 100644 --- a/iscsi-scst/usr/iscsid.c +++ b/iscsi-scst/usr/iscsid.c @@ -299,6 +299,7 @@ static int login_check_reinstatement(struct connection *conn) goto out; } else { struct connection *c = conn_find(session, conn->cid); + if (c != NULL) { /* Kernel will do connection reinstatement */ log_debug(1, "Conn %x reinstatement " @@ -527,6 +528,7 @@ static void login_start(struct connection *conn) if (session_type) { if (!strcmp(session_type, "Discovery")) { int ret = conn->is_discovery(conn->fd); + if (ret) { login_rsp_tgt_err(conn, ISCSI_STATUS_MISSING_FIELDS); return; @@ -645,6 +647,7 @@ static int login_finish(struct connection *conn) if (conn->is_iser && conn->session_params[key_target_recv_data_length].key_state == KEY_STATE_START) { char buf[32] = "\0"; + params_val_to_str(session_keys, key_target_recv_data_length, session_keys[key_target_recv_data_length].local_def, buf, sizeof(buf)); @@ -750,7 +753,7 @@ static void cmnd_exec_login(struct connection *conn) login_start(conn); if (rsp->status_class) return; - //else fall through + /* else fall through */ case STATE_SECURITY: text_scan_security(conn); if (rsp->status_class) @@ -848,6 +851,7 @@ static void cmnd_exec_login(struct connection *conn) } if (!stay && !nsg_disagree) { int err; + text_check_params(conn); err = login_finish(conn); if (err != 0) { @@ -1081,7 +1085,7 @@ void cmnd_finish(struct connection *conn) conn->state = STATE_LOGIN; break; case STATE_SECURITY_FULL: - //fall through + /* fall through */ case STATE_LOGIN_FULL: if (conn->session_type == SESSION_NORMAL) conn->state = STATE_KERNEL; diff --git a/iscsi-scst/usr/iscsid.h b/iscsi-scst/usr/iscsid.h index 8335629ab..885002876 100644 --- a/iscsi-scst/usr/iscsid.h +++ b/iscsi-scst/usr/iscsid.h @@ -180,8 +180,8 @@ struct connection { #define ISCSI_USER_DIR_INCOMING 0 #define ISCSI_USER_DIR_OUTGOING 1 -#define ISCSI_USER_NAME(attr) (attr)->attr_key -#define ISCSI_USER_PASS(attr) (attr)->attr_value +#define ISCSI_USER_NAME(attr) ((attr)->attr_key) +#define ISCSI_USER_PASS(attr) ((attr)->attr_value) struct iscsi_attr { struct __qelem ulist; diff --git a/iscsi-scst/usr/isns.c b/iscsi-scst/usr/isns.c index d33688e32..9d1bde508 100644 --- a/iscsi-scst/usr/isns.c +++ b/iscsi-scst/usr/isns.c @@ -551,6 +551,7 @@ int isns_target_register(char *name) if (scn_listen_port) { uint32_t sport = htonl(scn_listen_port); + err = isns_tlv_set(&tlv, max_buf - length, ISNS_ATTR_SCN_PORT, sizeof(sport), &sport); if (err < 0) diff --git a/iscsi-scst/usr/log.c b/iscsi-scst/usr/log.c index 675125ada..7a3d4769e 100644 --- a/iscsi-scst/usr/log.c +++ b/iscsi-scst/usr/log.c @@ -37,6 +37,7 @@ static void dolog_nofunc(int prio, const char *fmt, va_list ap) if (log_daemon) { int len = strlen(fmt); char f[len+1+1]; + if (fmt[len] != '\n') sprintf(f, "%s\n", fmt); else @@ -63,6 +64,7 @@ static void dolog(int prio, const char *func, int line, const char *fmt, va_list if (log_daemon) { int len = strlen(func) + strlen(fmt); char f[len+1+1]; + if (fmt[len] != '\n') sprintf(f, "%s:%d: %s %s\n", func, line, (prio == LOG_ERR) ? "ERROR:" : "", fmt); @@ -83,13 +85,14 @@ static void dolog(int prio, const char *func, int line, const char *fmt, va_list void __log(const char *func, int line, int prio, int level, const char *fmt, ...) { + va_list ap; + if (level) { prio = LOG_DEBUG; if (log_level < level) return; } - va_list ap; va_start(ap, fmt); dolog(prio, func, line, fmt, ap); va_end(ap); diff --git a/iscsi-scst/usr/param.c b/iscsi-scst/usr/param.c index e289aa9fa..08ea77fb2 100644 --- a/iscsi-scst/usr/param.c +++ b/iscsi-scst/usr/param.c @@ -29,6 +29,7 @@ size_t strlcpy(char *dest, const char *src, size_t size) if (size) { size_t len = (ret >= size) ? size - 1 : ret; + memcpy(dest, src, len); dest[len] = '\0'; } @@ -56,6 +57,7 @@ int params_index_by_name_numwild(const char *name, const struct iscsi_key *keys) for (i = 0; keys[i].name; i++) { if (!strncasecmp(keys[i].name, name, strlen(keys[i].name))) { int j; + if (strlen(keys[i].name) > strlen(name)) continue; for (j = strlen(keys[i].name); j < strlen(name); j++) { @@ -205,8 +207,8 @@ static int digest_str_to_val(const char *str, unsigned int *val) { int err = 0; const char *p, *q; - p = str; + p = str; *val = 0; do { while ((*p != '\0') && isspace(*p)) diff --git a/mpt/mpt_scst.c b/mpt/mpt_scst.c index d0458fcdf..6fe26b01a 100644 --- a/mpt/mpt_scst.c +++ b/mpt/mpt_scst.c @@ -164,6 +164,7 @@ static int mpt_target_show(struct seq_file *seq, void *v) if (ioc->bus_type == SPI) { #endif int i = 0; + seq_printf(seq, "Target ID :%d\n" "Capabilities :0x%x\n" "PhysicalInterface:0x%x\n", @@ -252,6 +253,7 @@ static ssize_t mpt_proc_target_write(struct file *file, const char __user *buf, if (strncmp("target_id:", tmp, strlen("target_id:")) == 0) { char *s = tmp + strlen("target_id:"); int id = simple_strtoul(s, NULL, 0); + if (id < MPT_MAX_SCSI_DEVICES) { if (IsScsi(tgt->priv)) { TRACE_DBG("Changing target id to %d\n", id); From 30f362caa377caefb50765b6a03883115a88cb9d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 16:56:50 +0000 Subject: [PATCH 117/121] scst: Address more checkpatch warnings git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6850 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 8 +++++--- scst/include/scst.h | 2 +- scst/include/scst_const.h | 2 +- scst/src/dev_handlers/scst_cdrom.c | 2 +- scst/src/dev_handlers/scst_dev_handler.h | 1 + scst/src/dev_handlers/scst_disk.c | 2 +- scst/src/dev_handlers/scst_modisk.c | 2 +- scst/src/dev_handlers/scst_user.c | 2 ++ scst/src/dev_handlers/scst_vdisk.c | 20 ++++++++++++++------ scst/src/scst_copy_mgr.c | 8 ++++---- scst/src/scst_dlm.c | 4 ++-- scst/src/scst_event.c | 2 +- scst/src/scst_lib.c | 10 +++++----- scst/src/scst_main.c | 6 +++--- scst/src/scst_pres.c | 2 +- scst/src/scst_priv.h | 10 +++++----- scst/src/scst_proc.c | 8 ++++++++ scst/src/scst_sysfs.c | 6 +++--- scst/src/scst_targ.c | 1 + 19 files changed, 60 insertions(+), 38 deletions(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index c28298034..4b5dcbc81 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -88,8 +88,10 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q) typedef cpumask_t cpumask_var_t[1]; #define cpumask_bits(maskp) ((maskp)->bits) #ifdef CONFIG_CPUMASK_OFFSTACK -/* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also, - * not all bits may be allocated. */ +/* + * Assuming NR_CPUS is huge, a runtime limit is more efficient. Also, + * not all bits may be allocated. + */ #define nr_cpumask_bits nr_cpu_ids #else #define nr_cpumask_bits NR_CPUS @@ -341,7 +343,7 @@ static inline bool list_entry_in_list(const struct list_head *entry) /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) -#define lockdep_assert_held(l) do { (void)(l); } while (0) +#define lockdep_assert_held(l) (void)(l) #endif /* */ diff --git a/scst/include/scst.h b/scst/include/scst.h index 4dc8db2ff..c1dffdd98 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1819,7 +1819,7 @@ struct scst_tgt { /* Divide two 64-bit numbers with reasonably accuracy. */ static inline void __scst_time_per_cmd(uint64_t *t, uint64_t n) { - unsigned shift; + unsigned int shift; if (!n) return; diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index f670ad632..30c8f5115 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -481,7 +481,7 @@ static inline int scst_sense_response_code(const uint8_t *sense) * From . See also commit * d30a2605be9d5132d95944916e8f578fcfe4f976. */ -#define BLKDISCARD _IO(0x12,119) +#define BLKDISCARD _IO(0x12, 119) #endif /************************************************************* diff --git a/scst/src/dev_handlers/scst_cdrom.c b/scst/src/dev_handlers/scst_cdrom.c index ce6d3d1fc..92697b5bb 100644 --- a/scst/src/dev_handlers/scst_cdrom.c +++ b/scst/src/dev_handlers/scst_cdrom.c @@ -99,7 +99,7 @@ static int cdrom_attach(struct scst_device *dev) rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, buffer_size, sense_buffer, SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) , NULL #endif ); diff --git a/scst/src/dev_handlers/scst_dev_handler.h b/scst/src/dev_handlers/scst_dev_handler.h index 5e65480f6..6810224f8 100644 --- a/scst/src/dev_handlers/scst_dev_handler.h +++ b/scst/src/dev_handlers/scst_dev_handler.h @@ -81,6 +81,7 @@ static int scst_dev_handler_build_std_proc(struct scst_dev_type *dev_type) /* Create the proc file entry for the device */ /* Workaround to keep /proc ABI intact */ const char *name; + if (strcmp(dev_type->name, "vdisk_fileio") == 0) name = "vdisk"; else diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index 13edb3528..a6f00be1f 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -196,7 +196,7 @@ static int disk_attach(struct scst_device *dev) rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, buffer_size, sense_buffer, SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) , NULL #endif ); diff --git a/scst/src/dev_handlers/scst_modisk.c b/scst/src/dev_handlers/scst_modisk.c index fe87e39dc..5dd8271c0 100644 --- a/scst/src/dev_handlers/scst_modisk.c +++ b/scst/src/dev_handlers/scst_modisk.c @@ -200,7 +200,7 @@ static int modisk_attach(struct scst_device *dev) rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, buffer_size, sense_buffer, SCST_GENERIC_MODISK_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) , NULL #endif ); diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 40b1a902b..643e0ade8 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -4048,11 +4048,13 @@ static int dev_user_read_proc(struct seq_file *seq, struct scst_dev_type *dev_ty list_for_each_entry(dev, &dev_list, dev_list_entry) { int i; + seq_printf(seq, "Device %s commands:\n", dev->name); spin_lock_irqsave(&dev->udev_cmd_threads.cmd_list_lock, flags); for (i = 0; i < (int)ARRAY_SIZE(dev->ucmd_hash); i++) { struct list_head *head = &dev->ucmd_hash[i]; struct scst_user_cmd *ucmd; + list_for_each_entry(ucmd, head, hash_list_entry) { seq_printf(seq, "ucmd %p (state %x, ref %d), " "sent_to_user %d, seen_by_user %d, " diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index ceb0c26a5..a667c4f34 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -22,6 +22,9 @@ * GNU General Public License for more details. */ +#ifndef INSIDE_KERNEL_TREE +#include +#endif #include #include #include @@ -34,14 +37,15 @@ #include #include #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) +#include +#else #include +#endif #include #include #include #include -#ifndef INSIDE_KERNEL_TREE -#include -#endif #include #include #include @@ -3318,7 +3322,8 @@ err: * @small_sg_size: size of @small_sg * @p_sg_cnt: pointer to an int where the sg vector size will be written */ -static struct scatterlist *alloc_sg(size_t size, unsigned off, gfp_t gfp_mask, +static struct scatterlist *alloc_sg(size_t size, unsigned int off, + gfp_t gfp_mask, struct scatterlist *small_sg, int small_sg_size, int *p_sg_cnt) { @@ -6447,6 +6452,7 @@ static inline void blockio_check_finish(struct scst_blockio_work *blockio_work) static void blockio_bio_destructor(struct bio *bio) { struct scst_blockio_work *blockio_work = bio->bi_private; + bio_free(bio, blockio_work->bioset); blockio_check_finish(blockio_work); } @@ -7000,6 +7006,7 @@ struct bio_priv_sync { static void blockio_bio_destructor_sync(struct bio *bio) { struct bio_priv_sync *s = bio->bi_private; + bio_free(bio, s->bs); complete(&s->c1); } @@ -7053,7 +7060,7 @@ static void blockio_end_sync_io(struct bio *bio) * Increments *@loff with the number of bytes transferred upon success. */ static ssize_t blockio_rw_sync(struct scst_vdisk_dev *virt_dev, void *buf, - size_t len, loff_t *loff, unsigned rw) + size_t len, loff_t *loff, unsigned int rw) { struct bio_priv_sync s = { COMPLETION_INITIALIZER_ONSTACK(s.c), 0, @@ -7068,7 +7075,7 @@ static ssize_t blockio_rw_sync(struct scst_vdisk_dev *virt_dev, void *buf, void *p; struct page *q; int max_nr_vecs, rc; - unsigned bytes, off; + unsigned int bytes, off; ssize_t ret = -ENOMEM; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)) && (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 6, 0)) bool submitted = false; @@ -10114,6 +10121,7 @@ static int vdisk_write_proc(char *buffer, char **start, off_t offset, if (isdigit(*p)) { char *pp; + block_size = simple_strtoul(p, &pp, 0); p = pp; if ((*p != '\0') && !isspace(*p)) { diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index bd64f477d..80ca7e8cb 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -3025,9 +3025,8 @@ static int scst_cm_add_to_descr_list(struct scst_cmd *ec_cmd, fcmd = __scst_create_prepare_internal_cmd(ec_cmd->cdb, ec_cmd->cdb_len, SCST_CMD_QUEUE_SIMPLE, tgt_dev, GFP_KERNEL, true); - if (fcmd == NULL) { + if (fcmd == NULL) goto out_enomem_free_e; - } fcmd->expected_data_direction = ec_cmd->expected_data_direction; fcmd->expected_transfer_len_full = ec_cmd->expected_transfer_len_full; @@ -3073,8 +3072,9 @@ skip_fcmd_create: if (tp != NULL) { if (((unsigned long)t->cm_fcmd->dev) <= ((unsigned long)tp->cm_fcmd->dev)) { list_for_each_entry(t, &priv->cm_sorted_devs_list, cm_sorted_devs_list_entry) { - printk(KERN_EMERG "%s: t %p, cm dev %p\n", __func__, - t, t->cm_fcmd->dev); + pr_emerg("%s: t %p, cm dev %p\n", + __func__, t, + t->cm_fcmd->dev); } sBUG(); break; diff --git a/scst/src/scst_dlm.c b/scst/src/scst_dlm.c index b8f2e890f..5b4f79cf5 100644 --- a/scst/src/scst_dlm.c +++ b/scst/src/scst_dlm.c @@ -525,11 +525,11 @@ struct scst_dlm_readdir_context { /* Append the name of each directory entry to the buffer @arg points to. */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) static int scst_dlm_filldir(void *arg, const char *name_arg, int name_len, - loff_t curr_pos, u64 inode, unsigned dtype) + loff_t curr_pos, u64 inode, unsigned int dtype) #else static int scst_dlm_filldir(struct dir_context *arg, const char *name_arg, int name_len, loff_t curr_pos, u64 inode, - unsigned dtype) + unsigned int dtype) #endif { char *p, *q, name[64]; diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index 11de3c1be..49805dbd7 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -27,7 +27,7 @@ static struct class *scst_event_sysfs_class; static int scst_event_major; #define SCST_MAX_EVENTS 2048 -#define SCST_MAX_PAYLOAD 3*1024 +#define SCST_MAX_PAYLOAD (3*1024) #define SCST_DEFAULT_EVENT_TIMEOUT (60*HZ) struct scst_event_priv { diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 4e4cd6bbd..973c7f1f1 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4533,7 +4533,7 @@ out: */ int scst_acg_repl_lun(struct scst_acg *acg, struct kobject *parent, struct scst_device *dev, uint64_t lun, - unsigned flags) + unsigned int flags) { struct scst_acg_dev *acg_dev; bool del_gen_ua = false; @@ -6759,7 +6759,7 @@ static void scst_send_release(struct scst_device *dev) "SCSI mid-level"); rc = scsi_execute(scsi_dev, cdb, SCST_DATA_NONE, NULL, 0, sense, 15, 0, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) , NULL #endif ); @@ -13172,7 +13172,7 @@ int scst_obtain_device_parameters(struct scst_device *dev, TRACE(TRACE_SCSI, "%s", "Doing internal MODE_SENSE"); rc = scsi_execute(dev->scsi_dev, cmd, SCST_DATA_READ, buffer, sizeof(buffer), sense_buffer, 15, 0, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) , NULL #endif ); @@ -14472,7 +14472,7 @@ out_unlock: #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) void scst_vfs_unlink_and_put(struct nameidata *nd) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) vfs_unlink(nd->dentry->d_parent->d_inode, nd->dentry); dput(nd->dentry); mntput(nd->mnt); @@ -14500,7 +14500,7 @@ void scst_vfs_unlink_and_put(struct path *path) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) void scst_path_put(struct nameidata *nd) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) dput(nd->dentry); mntput(nd->mnt); #else diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index b8fafe2f8..dbf6431b0 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -725,7 +725,7 @@ static const char *const scst_cmd_state_name[] = { [SCST_CMD_STATE_XMIT_WAIT] = "XMIT_WAIT", }; -char *scst_get_cmd_state_name(char *name, int len, unsigned state) +char *scst_get_cmd_state_name(char *name, int len, unsigned int state) { if (state < ARRAY_SIZE(scst_cmd_state_name) && scst_cmd_state_name[state]) @@ -804,7 +804,7 @@ static const char *const scst_tm_fn_name[] = { [SCST_PR_ABORT_ALL] = "PR_ABORT_ALL", }; -char *scst_get_tm_fn_name(char *name, int len, unsigned fn) +char *scst_get_tm_fn_name(char *name, int len, unsigned int fn) { if (fn < ARRAY_SIZE(scst_tm_fn_name) && scst_tm_fn_name[fn]) strlcpy(name, scst_tm_fn_name[fn], len); @@ -823,7 +823,7 @@ static const char *const scst_mcmd_state_name[] = { [SCST_MCMD_STATE_FINISHED] = "FINISHED", }; -char *scst_get_mcmd_state_name(char *name, int len, unsigned state) +char *scst_get_mcmd_state_name(char *name, int len, unsigned int state) { if (state < ARRAY_SIZE(scst_mcmd_state_name) && scst_mcmd_state_name[state]) diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 1cc85396b..5ac78d112 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -47,7 +47,7 @@ #include #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) #include #endif diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 5a5c63a30..694d9e395 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -277,9 +277,9 @@ extern void scst_tgt_dev_stop_threads(struct scst_tgt_dev *tgt_dev); extern struct scst_dev_type scst_null_devtype; -char *scst_get_cmd_state_name(char *name, int len, unsigned state); -char *scst_get_mcmd_state_name(char *name, int len, unsigned state); -char *scst_get_tm_fn_name(char *name, int len, unsigned fn); +char *scst_get_cmd_state_name(char *name, int len, unsigned int state); +char *scst_get_mcmd_state_name(char *name, int len, unsigned int state); +char *scst_get_tm_fn_name(char *name, int len, unsigned int fn); extern struct scst_cmd *__scst_check_deferred_commands_locked( struct scst_order_data *order_data, bool return_first); @@ -375,7 +375,7 @@ int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, bool gen_report_luns_changed); int scst_acg_repl_lun(struct scst_acg *acg, struct kobject *parent, struct scst_device *dev, uint64_t lun, - unsigned flags); + unsigned int flags); int scst_acg_add_acn(struct scst_acg *acg, const char *name); #ifdef CONFIG_SCST_PROC @@ -428,7 +428,7 @@ static inline int scst_dlm_new_lockspace(const char *name, int namelen, #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) static inline int scst_exec_req(struct scsi_device *sdev, const unsigned char *cmd, int cmd_len, int data_direction, - struct scatterlist *sgl, unsigned bufflen, unsigned nents, + struct scatterlist *sgl, unsigned int bufflen, unsigned int nents, int timeout, int retries, void *privdata, void (*done)(void *, char *, int, int), gfp_t gfp) { diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index 9d44a2782..ebd12d5e8 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -235,6 +235,7 @@ static DEFINE_MUTEX(scst_proc_mutex); static int strcasecmp(const char *s1, const char *s2) { int c1, c2; + do { c1 = tolower(*s1++); c2 = tolower(*s2++); @@ -246,6 +247,7 @@ static int strcasecmp(const char *s1, const char *s2) static int strncasecmp(const char *s1, const char *s2, size_t n) { int c1, c2; + do { c1 = tolower(*s1++); c2 = tolower(*s2++); @@ -595,6 +597,7 @@ static int lat_info_show(struct seq_file *seq, void *v) struct list_head *head = &sess->sess_tgt_dev_list[t]; struct scst_tgt_dev *tgt_dev; + list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) { @@ -763,6 +766,7 @@ static ssize_t scst_proc_scsi_tgt_gen_write_lat(struct file *file, struct list_head *head = &sess->sess_tgt_dev_list[t]; struct scst_tgt_dev *tgt_dev; + list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) { tgt_dev->scst_time = 0; @@ -2106,6 +2110,7 @@ static ssize_t scst_proc_groups_devices_write(struct file *file, * procfs is now obsoleted. */ struct scst_acg_dev *a; + list_for_each_entry(a, &acg->acg_dev_list, acg_dev_list_entry) { if (a->dev == dev) { rc = scst_acg_del_lun(acg, a->lun, true); @@ -2254,6 +2259,7 @@ static ssize_t scst_proc_groups_names_write(struct file *file, { struct scst_acg *a, *new_acg = NULL; char *name = p; + p = pp; while (!isspace(*pp) && *pp != '\0') pp++; @@ -2429,10 +2435,12 @@ static int scst_sessions_info_show(struct seq_file *seq, void *v) list_for_each_entry(sess, &acg->acg_sess_list, acg_sess_list_entry) { int active_cmds = 0, t; + for (t = SESS_TGT_DEV_LIST_HASH_SIZE-1; t >= 0; t--) { struct list_head *head = &sess->sess_tgt_dev_list[t]; struct scst_tgt_dev *tgt_dev; + list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) { active_cmds += atomic_read(&tgt_dev->tgt_dev_cmd_count); diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 73abe11f4..5556b5735 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -2802,7 +2802,7 @@ static int scst_tgt_sysfs_##attr##_show_work_fn( \ int res; \ uint64_t c = 0; \ \ - BUILD_BUG_ON((unsigned)(dir) >= ARRAY_SIZE(sess->io_stats)); \ + BUILD_BUG_ON((unsigned int)(dir) >= ARRAY_SIZE(sess->io_stats));\ \ res = mutex_lock_interruptible(&scst_mutex); \ if (res) \ @@ -3046,7 +3046,7 @@ static ssize_t scst_dev_sysfs_type_show(struct kobject *kobj, dev = container_of(kobj, struct scst_device, dev_kobj); pos = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d - %s\n", dev->type, - (unsigned)dev->type >= ARRAY_SIZE(scst_dev_handler_types) ? + (unsigned int)dev->type >= ARRAY_SIZE(scst_dev_handler_types) ? "unknown" : scst_dev_handler_types[dev->type]); return pos; @@ -5744,7 +5744,7 @@ static ssize_t scst_devt_type_show(struct kobject *kobj, devt = container_of(kobj, struct scst_dev_type, devt_kobj); pos = sprintf(buf, "%d - %s\n", devt->type, - (unsigned)devt->type >= ARRAY_SIZE(scst_dev_handler_types) ? + (unsigned int)devt->type >= ARRAY_SIZE(scst_dev_handler_types) ? "unknown" : scst_dev_handler_types[devt->type]); return pos; diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 47698297f..52aa7066c 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -5210,6 +5210,7 @@ static void scst_ioctx_get(struct scst_cmd_threads *p_cmd_threads) #warning IO context sharing functionality disabled on 3.5 kernels due to bug in them. \ See "http://lkml.org/lkml/2012/7/17/515" for more details. static int q; + if (q == 0) { q++; PRINT_WARNING("IO context sharing functionality " From 30c98e92cd3355fea7a2da86319dd43161d2e1a2 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 16:57:04 +0000 Subject: [PATCH 118/121] scst_local: Address checkpatch warnings git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6851 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst_local/scst_local.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index c4ce704bf..b545a3951 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -51,10 +51,10 @@ #ifndef INSIDE_KERNEL_TREE #if defined(CONFIG_HIGHMEM4G) || defined(CONFIG_HIGHMEM64G) -#warning HIGHMEM kernel configurations are not supported by this module,\ - because nowadays it is not worth the effort. Consider changing\ - VMSPLIT option or use a 64-bit configuration instead. See SCST core\ - README file for details. +#warning HIGHMEM kernel configurations are not supported by this module, \ +because nowadays it is not worth the effort. Consider changing \ +VMSPLIT option or use a 64-bit configuration instead. See SCST core \ +README file for details. #endif #endif From 86816401fa9183abc7b975cc0e5b5bda49974ee9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 17:09:46 +0000 Subject: [PATCH 119/121] scst: Move more backports from scst_debug.h into backport.h git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6852 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 36 +++++++++++++++++++++++++++-- scst/include/scst_debug.h | 48 +-------------------------------------- 2 files changed, 35 insertions(+), 49 deletions(-) diff --git a/scst/include/backport.h b/scst/include/backport.h index 4b5dcbc81..6c735b86c 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -375,12 +375,44 @@ static inline long get_user_pages_backport(unsigned long start, /* */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) && !defined(RHEL_MAJOR) +#define KERN_CONT "" +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) -#ifndef pr_err -#define pr_err(fmt, ...) printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) +/* + * See also the following commits: + * d091c2f5 - Introduction of pr_info() etc. in . + * 311d0761 - Introduction of pr_cont() in . + * 968ab183 - Moved pr_info() etc. from to + */ +#ifndef pr_emerg + +#ifndef pr_fmt +#define pr_fmt(fmt) fmt #endif + +#define pr_emerg(fmt, ...) printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) +#define pr_alert(fmt, ...) printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) +#define pr_crit(fmt, ...) printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) +#define pr_err(fmt, ...) printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warning(fmt, ...) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) +#define pr_notice(fmt, ...) printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) + +#endif /* pr_emerg */ + +#ifndef pr_info +#define pr_info(fmt, ...) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) #endif +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +#ifndef pr_cont +#define pr_cont(fmt, ...) printk(KERN_CONT fmt, ##__VA_ARGS__) +#endif +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) /* * See also patch "kernel.h: add pr_warn for symmetry to dev_warn, diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index 00ea2c559..e154c23d0 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -35,43 +35,6 @@ #include #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) -/* - * See also the following commits: - * d091c2f5 - Introduction of pr_info() etc. in . - * 311d0761 - Introduction of pr_cont() in . - * 968ab183 - Moved pr_info() etc. from to - */ -#ifndef pr_emerg -#ifndef pr_fmt -#define pr_fmt(fmt) fmt -#endif - -#define pr_emerg(fmt, ...) \ - printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) -#define pr_alert(fmt, ...) \ - printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_crit(fmt, ...) \ - printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) -#define pr_err(fmt, ...) \ - printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warning(fmt, ...) \ - printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) -#define pr_notice(fmt, ...) \ - printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) -#endif -#ifndef pr_info -#define pr_info(fmt, ...) \ - printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -#endif -#endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) -#ifndef pr_cont -#define pr_cont(fmt, ...) \ - printk(KERN_CONT fmt, ##__VA_ARGS__) -#endif -#endif - #if !defined(INSIDE_KERNEL_TREE) #ifdef CONFIG_SCST_DEBUG @@ -148,10 +111,6 @@ #define TRACE_MINOR_AND_MGMT_DBG (TRACE_MINOR|TRACE_MGMT_DEBUG) -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) && !defined(RHEL_MAJOR) -#define KERN_CONT "" -#endif - /* * Note: in the next two printk() statements the KERN_CONT macro is only * present to suppress a checkpatch warning (KERN_CONT is defined as ""). @@ -175,12 +134,7 @@ #define ___unlikely(a) unlikely(a) #endif -int -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 21) || defined(__printf) -__printf(6, 7) -#else -__attribute__((format(printf, 6, 7))) -#endif +int __printf(6, 7) debug_print_with_prefix(unsigned long trace_flag, const char *severity, const char *prefix, const char *func, int line, const char *fmt, ...); From 520b66677d69fddc1776efff87c87724aac234ab Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 17:26:50 +0000 Subject: [PATCH 120/121] scst: Fix RHEL 5 build git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6853 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 3 +++ scst/include/scst_debug.h | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/scst/include/backport.h b/scst/include/backport.h index 6c735b86c..5d12d023b 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -20,8 +20,11 @@ * GNU General Public License for more details. */ +#include /* struct request_queue */ +#include /* struct scatterlist */ #include /* kmalloc() */ #include /* sync_page_range() */ +#include /* struct scsi_cmnd */ /* */ diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index e154c23d0..ee2e18ee4 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -35,6 +35,12 @@ #include #endif +#ifdef INSIDE_KERNEL_TREE +#include +#else +#include +#endif + #if !defined(INSIDE_KERNEL_TREE) #ifdef CONFIG_SCST_DEBUG From b34cf85d839a1deeaa00b74ac8c01bdef1f6aff2 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 27 Mar 2016 22:44:44 +0000 Subject: [PATCH 121/121] scst_sysfs: Report LUN replacement failure correctly This is a follow-up for r6834. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6854 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 5556b5735..43b769591 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1447,6 +1447,8 @@ static int __scst_process_luns_mgmt_store(char *buffer, res = scst_acg_repl_lun(acg, tgt_kobj ? tgt->tgt_luns_kobj : acg->luns_kobj, dev, virt_lun, flags); + if (res != 0) + goto out_unlock; break; } case SCST_LUN_ACTION_DEL: