diff options
Diffstat (limited to 'drivers/target/target_core_xcopy.c')
-rw-r--r-- | drivers/target/target_core_xcopy.c | 53 |
1 files changed, 37 insertions, 16 deletions
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; |
903 | } | 923 | } |
904 | 924 | ||
905 | list_id = p[0]; | 925 | list_id = p[0]; |
906 | if (list_id != 0x00) { | 926 | list_id_usage = (p[1] & 0x18) >> 3; |
907 | pr_err("XCOPY with non zero list_id: 0x%02x\n", list_id); | 927 | |
908 | goto out; | ||
909 | } | ||
910 | list_id_usage = (p[1] & 0x18); | ||
911 | /* | 928 | /* |
912 | * Determine TARGET DESCRIPTOR LIST LENGTH + SEGMENT DESCRIPTOR LIST LENGTH | 929 | * Determine TARGET DESCRIPTOR LIST LENGTH + SEGMENT DESCRIPTOR LIST LENGTH |
913 | */ | 930 | */ |
@@ -920,13 +937,6 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd) | |||
920 | goto out; | 937 | goto out; |
921 | } | 938 | } |
922 | 939 | ||
923 | xop = kzalloc(sizeof(struct xcopy_op), GFP_KERNEL); | ||
924 | if (!xop) { | ||
925 | pr_err("Unable to allocate xcopy_op\n"); | ||
926 | goto out; | ||
927 | } | ||
928 | xop->xop_se_cmd = se_cmd; | ||
929 | |||
930 | pr_debug("Processing XCOPY with list_id: 0x%02x list_id_usage: 0x%02x" | 940 | pr_debug("Processing XCOPY with list_id: 0x%02x list_id_usage: 0x%02x" |
931 | " tdll: %hu sdll: %u inline_dl: %u\n", list_id, list_id_usage, | 941 | " tdll: %hu sdll: %u inline_dl: %u\n", list_id, list_id_usage, |
932 | tdll, sdll, inline_dl); | 942 | tdll, sdll, inline_dl); |
@@ -935,6 +945,17 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd) | |||
935 | if (rc <= 0) | 945 | if (rc <= 0) |
936 | goto out; | 946 | goto out; |
937 | 947 | ||
948 | if (xop->src_dev->dev_attrib.block_size != | ||
949 | xop->dst_dev->dev_attrib.block_size) { | ||
950 | pr_err("XCOPY: Non matching src_dev block_size: %u + dst_dev" | ||
951 | " block_size: %u currently unsupported\n", | ||
952 | xop->src_dev->dev_attrib.block_size, | ||
953 | xop->dst_dev->dev_attrib.block_size); | ||
954 | xcopy_pt_undepend_remotedev(xop); | ||
955 | ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
956 | goto out; | ||
957 | } | ||
958 | |||
938 | pr_debug("XCOPY: Processed %d target descriptors, length: %u\n", rc, | 959 | pr_debug("XCOPY: Processed %d target descriptors, length: %u\n", rc, |
939 | rc * XCOPY_TARGET_DESC_LEN); | 960 | rc * XCOPY_TARGET_DESC_LEN); |
940 | seg_desc = &p[16]; | 961 | seg_desc = &p[16]; |
@@ -957,7 +978,7 @@ out: | |||
957 | if (p) | 978 | if (p) |
958 | transport_kunmap_data_sg(se_cmd); | 979 | transport_kunmap_data_sg(se_cmd); |
959 | kfree(xop); | 980 | kfree(xop); |
960 | return TCM_INVALID_CDB_FIELD; | 981 | return ret; |
961 | } | 982 | } |
962 | 983 | ||
963 | static sense_reason_t target_rcr_operating_parameters(struct se_cmd *se_cmd) | 984 | static sense_reason_t target_rcr_operating_parameters(struct se_cmd *se_cmd) |