Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCOPY follow up fixes #646

Merged
merged 4 commits into from
Jan 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion tcmur_cmd_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,12 @@ static int xcopy_parse_target_descs(struct tcmu_device *udev,
{
int i, ret;

if (tdll % XCOPY_TARGET_DESC_LEN) {
tcmu_dev_err(udev,
"CSCD descriptor list length %u not a multiple of %u\n",
(unsigned int)tdll, XCOPY_TARGET_DESC_LEN);
return TCMU_STS_NOTSUPP_TGT_DESC_TYPE;
}
/* From spc4r36q,section 6.4.3.4 CSCD DESCRIPTOR LIST LENGTH field
* If the number of CSCD descriptors exceeds the allowed number, the copy
* manager shall terminate the command with CHECK CONDITION status, with
Expand All @@ -1173,7 +1179,7 @@ static int xcopy_parse_target_descs(struct tcmu_device *udev,
return TCMU_STS_TOO_MANY_TGT_DESC;
}

for (i = 0; i < RCR_OP_MAX_TARGET_DESC_COUNT; i++) {
for (i = 0; tdll >= XCOPY_TARGET_DESC_LEN; i++) {
/*
* Only Identification Descriptor Target Descriptor support
* for now.
Expand All @@ -1184,13 +1190,15 @@ static int xcopy_parse_target_descs(struct tcmu_device *udev,
return ret;

tgt_desc += XCOPY_TARGET_DESC_LEN;
tdll -= XCOPY_TARGET_DESC_LEN;
} else {
tcmu_dev_err(udev, "Unsupport target descriptor type code 0x%x\n",
tgt_desc[0]);
return TCMU_STS_NOTSUPP_TGT_DESC_TYPE;
}
}

ret = TCMU_STS_CP_TGT_DEV_NOTCONN;
if (xcopy->src_dev)
ret = xcopy_locate_udev(udev->ctx, xcopy->dst_tid_wwn,
&xcopy->dst_dev);
Expand Down Expand Up @@ -1308,6 +1316,12 @@ static int xcopy_parse_parameter_list(struct tcmu_device *dev,
* data, after the last segment descriptor.
* */
inline_dl = be32toh(*(uint32_t *)&par[12]);
if (inline_dl != 0) {
tcmu_dev_err(dev, "non-zero xcopy inline_dl %u unsupported\n",
inline_dl);
ret = TCMU_STS_INVALID_PARAM_LIST_LEN;
goto err;
}

/* From spc4r31, section 6.3.1 EXTENDED COPY command introduction
*
Expand Down Expand Up @@ -1349,6 +1363,18 @@ static int xcopy_parse_parameter_list(struct tcmu_device *dev,
if (ret != TCMU_STS_OK)
goto err;

/*
* tcmu-runner can't determine whether the device(s) referred to in an
* XCOPY request should be accessible to the initiator via transport
* settings, ACLs, etc. XXX Consequently, we need to fail any
* cross-device requests for safety reasons.
*/
if (dev != xcopy->src_dev || dev != xcopy->dst_dev) {
tcmu_dev_err(dev, "Cross-device XCOPY not supported\n");
ret = TCMU_STS_CP_TGT_DEV_NOTCONN;
goto err;
}

if (tcmu_dev_get_block_size(xcopy->src_dev) !=
tcmu_dev_get_block_size(xcopy->dst_dev)) {
tcmu_dev_err(dev, "The block size of src dev %u != dst dev %u\n",
Expand Down