aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_tpc.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2017-01-17 18:32:47 +0000
committerAlexander Motin <mav@FreeBSD.org>2017-01-17 18:32:47 +0000
commit640603fbf690b9801e70429a4c8b3ded2947e787 (patch)
treef0db624674f53e364db66524ba8f9937c12bd7e0 /sys/cam/ctl/ctl_tpc.c
parenta396e10cd921ede285140bf62af057a43dce01f1 (diff)
downloadsrc-640603fbf690b9801e70429a4c8b3ded2947e787.tar.gz
src-640603fbf690b9801e70429a4c8b3ded2947e787.zip
Remove writing 'residual' field of struct ctl_scsiio.
This field has no practical use and never readed. Initiators already receive respective residual size from frontends. Removed field had different semantics, which looks useless, and was never passed through by any frontend. While there, fix kern_data_resid field support in case of HA, missed in r312291. MFC after: 13 days
Notes
Notes: svn path=/head/; revision=312348
Diffstat (limited to 'sys/cam/ctl/ctl_tpc.c')
-rw-r--r--sys/cam/ctl/ctl_tpc.c91
1 files changed, 14 insertions, 77 deletions
diff --git a/sys/cam/ctl/ctl_tpc.c b/sys/cam/ctl/ctl_tpc.c
index 9e1cfa852edb..c8d60cad0194 100644
--- a/sys/cam/ctl/ctl_tpc.c
+++ b/sys/cam/ctl/ctl_tpc.c
@@ -282,19 +282,10 @@ ctl_inquiry_evpd_tpc(struct ctl_scsiio *ctsio, int alloc_len)
ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO);
tpc_ptr = (struct scsi_vpd_tpc *)ctsio->kern_data_ptr;
- ctsio->kern_sg_entries = 0;
-
- if (data_len < alloc_len) {
- ctsio->residual = alloc_len - data_len;
- ctsio->kern_data_len = data_len;
- ctsio->kern_total_len = data_len;
- } else {
- ctsio->residual = 0;
- ctsio->kern_data_len = alloc_len;
- ctsio->kern_total_len = alloc_len;
- }
ctsio->kern_rel_offset = 0;
ctsio->kern_sg_entries = 0;
+ ctsio->kern_data_len = min(data_len, alloc_len);
+ ctsio->kern_total_len = ctsio->kern_data_len;
/*
* The control device is always connected. The disk device, on the
@@ -457,19 +448,10 @@ ctl_receive_copy_operating_parameters(struct ctl_scsiio *ctsio)
alloc_len = scsi_4btoul(cdb->length);
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO);
-
ctsio->kern_sg_entries = 0;
-
- if (total_len < alloc_len) {
- ctsio->residual = alloc_len - total_len;
- ctsio->kern_data_len = total_len;
- ctsio->kern_total_len = total_len;
- } else {
- ctsio->residual = 0;
- ctsio->kern_data_len = alloc_len;
- ctsio->kern_total_len = alloc_len;
- }
ctsio->kern_rel_offset = 0;
+ ctsio->kern_data_len = min(total_len, alloc_len);
+ ctsio->kern_total_len = ctsio->kern_data_len;
data = (struct scsi_receive_copy_operating_parameters_data *)ctsio->kern_data_ptr;
scsi_ulto4b(sizeof(*data) - 4 + 4, data->length);
@@ -554,19 +536,10 @@ ctl_receive_copy_status_lid1(struct ctl_scsiio *ctsio)
alloc_len = scsi_4btoul(cdb->length);
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO);
-
ctsio->kern_sg_entries = 0;
-
- if (total_len < alloc_len) {
- ctsio->residual = alloc_len - total_len;
- ctsio->kern_data_len = total_len;
- ctsio->kern_total_len = total_len;
- } else {
- ctsio->residual = 0;
- ctsio->kern_data_len = alloc_len;
- ctsio->kern_total_len = alloc_len;
- }
ctsio->kern_rel_offset = 0;
+ ctsio->kern_data_len = min(total_len, alloc_len);
+ ctsio->kern_total_len = ctsio->kern_data_len;
data = (struct scsi_receive_copy_status_lid1_data *)ctsio->kern_data_ptr;
scsi_ulto4b(sizeof(*data) - 4, data->available_data);
@@ -631,19 +604,10 @@ ctl_receive_copy_failure_details(struct ctl_scsiio *ctsio)
alloc_len = scsi_4btoul(cdb->length);
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO);
-
ctsio->kern_sg_entries = 0;
-
- if (total_len < alloc_len) {
- ctsio->residual = alloc_len - total_len;
- ctsio->kern_data_len = total_len;
- ctsio->kern_total_len = total_len;
- } else {
- ctsio->residual = 0;
- ctsio->kern_data_len = alloc_len;
- ctsio->kern_total_len = alloc_len;
- }
ctsio->kern_rel_offset = 0;
+ ctsio->kern_data_len = min(total_len, alloc_len);
+ ctsio->kern_total_len = ctsio->kern_data_len;
data = (struct scsi_receive_copy_failure_details_data *)ctsio->kern_data_ptr;
if (list_copy.completed && (list_copy.error || list_copy.abort)) {
@@ -702,19 +666,10 @@ ctl_receive_copy_status_lid4(struct ctl_scsiio *ctsio)
alloc_len = scsi_4btoul(cdb->length);
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO);
-
ctsio->kern_sg_entries = 0;
-
- if (total_len < alloc_len) {
- ctsio->residual = alloc_len - total_len;
- ctsio->kern_data_len = total_len;
- ctsio->kern_total_len = total_len;
- } else {
- ctsio->residual = 0;
- ctsio->kern_data_len = alloc_len;
- ctsio->kern_total_len = alloc_len;
- }
ctsio->kern_rel_offset = 0;
+ ctsio->kern_data_len = min(total_len, alloc_len);
+ ctsio->kern_total_len = ctsio->kern_data_len;
data = (struct scsi_receive_copy_status_lid4_data *)ctsio->kern_data_ptr;
scsi_ulto4b(sizeof(*data) - 4 + list_copy.sense_len,
@@ -2402,19 +2357,10 @@ ctl_receive_rod_token_information(struct ctl_scsiio *ctsio)
alloc_len = scsi_4btoul(cdb->length);
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO);
-
ctsio->kern_sg_entries = 0;
-
- if (total_len < alloc_len) {
- ctsio->residual = alloc_len - total_len;
- ctsio->kern_data_len = total_len;
- ctsio->kern_total_len = total_len;
- } else {
- ctsio->residual = 0;
- ctsio->kern_data_len = alloc_len;
- ctsio->kern_total_len = alloc_len;
- }
ctsio->kern_rel_offset = 0;
+ ctsio->kern_data_len = min(total_len, alloc_len);
+ ctsio->kern_total_len = ctsio->kern_data_len;
data = (struct scsi_receive_copy_status_lid4_data *)ctsio->kern_data_ptr;
scsi_ulto4b(sizeof(*data) - 4 + list_copy.sense_len +
@@ -2482,19 +2428,10 @@ ctl_report_all_rod_tokens(struct ctl_scsiio *ctsio)
alloc_len = scsi_4btoul(cdb->length);
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO);
-
ctsio->kern_sg_entries = 0;
-
- if (total_len < alloc_len) {
- ctsio->residual = alloc_len - total_len;
- ctsio->kern_data_len = total_len;
- ctsio->kern_total_len = total_len;
- } else {
- ctsio->residual = 0;
- ctsio->kern_data_len = alloc_len;
- ctsio->kern_total_len = alloc_len;
- }
ctsio->kern_rel_offset = 0;
+ ctsio->kern_data_len = min(total_len, alloc_len);
+ ctsio->kern_total_len = ctsio->kern_data_len;
data = (struct scsi_report_all_rod_tokens_data *)ctsio->kern_data_ptr;
i = 0;