diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-27 13:16:33 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-27 13:16:33 -0400 |
| commit | acda24c47eace7afd7017126a9e0cc04a98e95f3 (patch) | |
| tree | f783cbce82dce6f683b04b61c9c5912cd45ec850 | |
| parent | 63e656083d2b280d42464e0a4297cdc48d6f75d3 (diff) | |
| parent | 60a01f558af9c48b0bb31f303c479e32721add3f (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target fixes from Nicholas Bellinger:
"Here are the outstanding target pending fixes for v3.12-rc7.
This includes a number of EXTENDED_COPY related fixes as a result of
Thomas and Doug's continuing testing and feedback.
Also included is an important vhost/scsi fix that addresses a long
standing issue where the 'write' parameter for get_user_pages_fast()
was incorrectly set for virtio-scsi WRITEs -> DMA_TO_DEVICE, and not
for virtio-scsi READs -> DMA_FROM_DEVICE.
This resulted in random userspace segfaults and other unpleasantness
on KVM host, and unfortunately has been an issue since the initial
merge of vhost/scsi in v3.6. This patch is CC'ed to stable, along
with two other less critical items"
* git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending:
vhost/scsi: Fix incorrect usage of get_user_pages_fast write parameter
target/pscsi: fix return value check
target: Fail XCOPY for non matching source + destination block_size
target: Generate failure for XCOPY I/O with non-zero scsi_status
target: Add missing XCOPY I/O operation sense_buffer
iser-target: check device before dereferencing its variable
target: Return an error for WRITE SAME with ANCHOR==1
target: Fix assignment of LUN in tracepoints
target: Reject EXTENDED_COPY when emulate_3pc is disabled
target: Allow non zero ListID in EXTENDED_COPY parameter list
target: Make target_do_xcopy failures return INVALID_PARAMETER_LIST
| -rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.c | 2 | ||||
| -rw-r--r-- | drivers/target/target_core_pscsi.c | 8 | ||||
| -rw-r--r-- | drivers/target/target_core_sbc.c | 5 | ||||
| -rw-r--r-- | drivers/target/target_core_xcopy.c | 53 | ||||
| -rw-r--r-- | drivers/vhost/scsi.c | 2 | ||||
| -rw-r--r-- | include/trace/events/target.h | 4 |
6 files changed, 50 insertions, 24 deletions
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 3591855cc5b5..6df23502059a 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
| @@ -594,7 +594,7 @@ isert_connect_release(struct isert_conn *isert_conn) | |||
| 594 | 594 | ||
| 595 | pr_debug("Entering isert_connect_release(): >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); | 595 | pr_debug("Entering isert_connect_release(): >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); |
| 596 | 596 | ||
| 597 | if (device->use_frwr) | 597 | if (device && device->use_frwr) |
| 598 | isert_conn_free_frwr_pool(isert_conn); | 598 | isert_conn_free_frwr_pool(isert_conn); |
| 599 | 599 | ||
| 600 | if (isert_conn->conn_qp) { | 600 | if (isert_conn->conn_qp) { |
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 551c96ca60ac..0f199f6a0738 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c | |||
| @@ -134,10 +134,10 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) | |||
| 134 | * pSCSI Host ID and enable for phba mode | 134 | * pSCSI Host ID and enable for phba mode |
| 135 | */ | 135 | */ |
| 136 | sh = scsi_host_lookup(phv->phv_host_id); | 136 | sh = scsi_host_lookup(phv->phv_host_id); |
| 137 | if (IS_ERR(sh)) { | 137 | if (!sh) { |
| 138 | pr_err("pSCSI: Unable to locate SCSI Host for" | 138 | pr_err("pSCSI: Unable to locate SCSI Host for" |
| 139 | " phv_host_id: %d\n", phv->phv_host_id); | 139 | " phv_host_id: %d\n", phv->phv_host_id); |
| 140 | return PTR_ERR(sh); | 140 | return -EINVAL; |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | phv->phv_lld_host = sh; | 143 | phv->phv_lld_host = sh; |
| @@ -515,10 +515,10 @@ static int pscsi_configure_device(struct se_device *dev) | |||
| 515 | sh = phv->phv_lld_host; | 515 | sh = phv->phv_lld_host; |
| 516 | } else { | 516 | } else { |
| 517 | sh = scsi_host_lookup(pdv->pdv_host_id); | 517 | sh = scsi_host_lookup(pdv->pdv_host_id); |
| 518 | if (IS_ERR(sh)) { | 518 | if (!sh) { |
| 519 | pr_err("pSCSI: Unable to locate" | 519 | pr_err("pSCSI: Unable to locate" |
| 520 | " pdv_host_id: %d\n", pdv->pdv_host_id); | 520 | " pdv_host_id: %d\n", pdv->pdv_host_id); |
| 521 | return PTR_ERR(sh); | 521 | return -EINVAL; |
| 522 | } | 522 | } |
| 523 | } | 523 | } |
| 524 | } else { | 524 | } else { |
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 4714c6f8da4b..d9b92b2c524d 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c | |||
| @@ -263,6 +263,11 @@ sbc_setup_write_same(struct se_cmd *cmd, unsigned char *flags, struct sbc_ops *o | |||
| 263 | sectors, cmd->se_dev->dev_attrib.max_write_same_len); | 263 | sectors, cmd->se_dev->dev_attrib.max_write_same_len); |
| 264 | return TCM_INVALID_CDB_FIELD; | 264 | return TCM_INVALID_CDB_FIELD; |
| 265 | } | 265 | } |
| 266 | /* We always have ANC_SUP == 0 so setting ANCHOR is always an error */ | ||
| 267 | if (flags[0] & 0x10) { | ||
| 268 | pr_warn("WRITE SAME with ANCHOR not supported\n"); | ||
| 269 | return TCM_INVALID_CDB_FIELD; | ||
| 270 | } | ||
| 266 | /* | 271 | /* |
| 267 | * Special case for WRITE_SAME w/ UNMAP=1 that ends up getting | 272 | * Special case for WRITE_SAME w/ UNMAP=1 that ends up getting |
| 268 | * translated into block discard requests within backend code. | 273 | * translated into block discard requests within backend code. |
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c index 3da4fd10b9f8..474cd44fac14 100644 --- a/drivers/target/target_core_xcopy.c +++ b/drivers/target/target_core_xcopy.c | |||
| @@ -82,6 +82,9 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op | |||
| 82 | mutex_lock(&g_device_mutex); | 82 | mutex_lock(&g_device_mutex); |
| 83 | list_for_each_entry(se_dev, &g_device_list, g_dev_node) { | 83 | list_for_each_entry(se_dev, &g_device_list, g_dev_node) { |
| 84 | 84 | ||
| 85 | if (!se_dev->dev_attrib.emulate_3pc) | ||
| 86 | continue; | ||
| 87 | |||
| 85 | memset(&tmp_dev_wwn[0], 0, XCOPY_NAA_IEEE_REGEX_LEN); | 88 | memset(&tmp_dev_wwn[0], 0, XCOPY_NAA_IEEE_REGEX_LEN); |
| 86 | target_xcopy_gen_naa_ieee(se_dev, &tmp_dev_wwn[0]); | 89 | target_xcopy_gen_naa_ieee(se_dev, &tmp_dev_wwn[0]); |
| 87 | 90 | ||
| @@ -357,6 +360,7 @@ struct xcopy_pt_cmd { | |||
| 357 | struct se_cmd se_cmd; | 360 | struct se_cmd se_cmd; |
| 358 | struct xcopy_op *xcopy_op; | 361 | struct xcopy_op *xcopy_op; |
| 359 | struct completion xpt_passthrough_sem; | 362 | struct completion xpt_passthrough_sem; |
| 363 | unsigned char sense_buffer[TRANSPORT_SENSE_BUFFER]; | ||
| 360 | }; | 364 | }; |
| 361 | 365 | ||
| 362 | static struct se_port xcopy_pt_port; | 366 | static struct se_port xcopy_pt_port; |
| @@ -675,7 +679,8 @@ static int target_xcopy_issue_pt_cmd(struct xcopy_pt_cmd *xpt_cmd) | |||
| 675 | 679 | ||
| 676 | pr_debug("target_xcopy_issue_pt_cmd(): SCSI status: 0x%02x\n", | 680 | pr_debug("target_xcopy_issue_pt_cmd(): SCSI status: 0x%02x\n", |
| 677 | se_cmd->scsi_status); | 681 | se_cmd->scsi_status); |
| 678 | return 0; | 682 | |
| 683 | return (se_cmd->scsi_status) ? -EINVAL : 0; | ||
| 679 | } | 684 | } |
| 680 | 685 | ||
| 681 | static int target_xcopy_read_source( | 686 | static int target_xcopy_read_source( |
| @@ -708,7 +713,7 @@ static int target_xcopy_read_source( | |||
| 708 | (unsigned long long)src_lba, src_sectors, length); | 713 | (unsigned long long)src_lba, src_sectors, length); |
| 709 | 714 | ||
| 710 | transport_init_se_cmd(se_cmd, &xcopy_pt_tfo, NULL, length, | 715 | transport_init_se_cmd(se_cmd, &xcopy_pt_tfo, NULL, length, |
| 711 | DMA_FROM_DEVICE, 0, NULL); | 716 | DMA_FROM_DEVICE, 0, &xpt_cmd->sense_buffer[0]); |
| 712 | xop->src_pt_cmd = xpt_cmd; | 717 | xop->src_pt_cmd = xpt_cmd; |
| 713 | 718 | ||
| 714 | rc = target_xcopy_setup_pt_cmd(xpt_cmd, xop, src_dev, &cdb[0], | 719 | rc = target_xcopy_setup_pt_cmd(xpt_cmd, xop, src_dev, &cdb[0], |
| @@ -768,7 +773,7 @@ static int target_xcopy_write_destination( | |||
| 768 | (unsigned long long)dst_lba, dst_sectors, length); | 773 | (unsigned long long)dst_lba, dst_sectors, length); |
| 769 | 774 | ||
| 770 | transport_init_se_cmd(se_cmd, &xcopy_pt_tfo, NULL, length, | 775 | transport_init_se_cmd(se_cmd, &xcopy_pt_tfo, NULL, length, |
| 771 | DMA_TO_DEVICE, 0, NULL); | 776 | DMA_TO_DEVICE, 0, &xpt_cmd->sense_buffer[0]); |
| 772 | xop->dst_pt_cmd = xpt_cmd; | 777 | xop->dst_pt_cmd = xpt_cmd; |
| 773 | 778 | ||
| 774 | rc = target_xcopy_setup_pt_cmd(xpt_cmd, xop, dst_dev, &cdb[0], | 779 | rc = target_xcopy_setup_pt_cmd(xpt_cmd, xop, dst_dev, &cdb[0], |
| @@ -884,30 +889,42 @@ out: | |||
| 884 | 889 | ||
| 885 | sense_reason_t target_do_xcopy(struct se_cmd *se_cmd) | 890 | sense_reason_t target_do_xcopy(struct se_cmd *se_cmd) |
| 886 | { | 891 | { |
| 892 | struct se_device *dev = se_cmd->se_dev; | ||
| 887 | struct xcopy_op *xop = NULL; | 893 | struct xcopy_op *xop = NULL; |
| 888 | unsigned char *p = NULL, *seg_desc; | 894 | unsigned char *p = NULL, *seg_desc; |
| 889 | unsigned int list_id, list_id_usage, sdll, inline_dl, sa; | 895 | unsigned int list_id, list_id_usage, sdll, inline_dl, sa; |
| 896 | sense_reason_t ret = TCM_INVALID_PARAMETER_LIST; | ||
| 890 | int rc; | 897 | int rc; |
| 891 | unsigned short tdll; | 898 | unsigned short tdll; |
| 892 | 899 | ||
| 900 | if (!dev->dev_attrib.emulate_3pc) { | ||
| 901 | pr_err("EXTENDED_COPY operation explicitly disabled\n"); | ||
| 902 | return TCM_UNSUPPORTED_SCSI_OPCODE; | ||
| 903 | } | ||
| 904 | |||
| 893 | sa = se_cmd->t_task_cdb[1] & 0x1f; | 905 | sa = se_cmd->t_task_cdb[1] & 0x1f; |
| 894 | if (sa != 0x00) { | 906 | if (sa != 0x00) { |
| 895 | pr_err("EXTENDED_COPY(LID4) not supported\n"); | 907 | pr_err("EXTENDED_COPY(LID4) not supported\n"); |
| 896 | return TCM_UNSUPPORTED_SCSI_OPCODE; | 908 | return TCM_UNSUPPORTED_SCSI_OPCODE; |
| 897 | } | 909 | } |
| 898 | 910 | ||
| 911 | xop = kzalloc(sizeof(struct xcopy_op), GFP_KERNEL); | ||
| 912 | if (!xop) { | ||
| 913 | pr_err("Unable to allocate xcopy_op\n"); | ||
| 914 | return TCM_OUT_OF_RESOURCES; | ||
| 915 | } | ||
| 916 | xop->xop_se_cmd = se_cmd; | ||
| 917 | |||
| 899 | p = transport_kmap_data_sg(se_cmd); | 918 | p = transport_kmap_data_sg(se_cmd); |
| 900 | if (!p) { | 919 | if (!p) { |
| 901 | pr_err("transport_kmap_data_sg() failed in target_do_xcopy\n"); | 920 | pr_err("transport_kmap_data_sg() failed in target_do_xcopy\n"); |
| 921 | kfree(xop); | ||
| 902 | return TCM_OUT_OF_RESOURCES; | 922 | return TCM_OUT_OF_RESOURCES; |
