History

target: Return descriptor format sense data in case the LU spans 64bit sectors

In case a LU spans 64bit sectors, fixed size sense data information field is only 32 bits which means the sector information will be truncated. Thus, if the LU spans 64bit sectors, use descriptor format sense data to correctly report sector information.

Sagi Grimberg committed 11 years ago

Commit 4e4937e1 parent f5a8b3a4 files · +18 −4Browse files

Unified · Split

4 files
  1. drivers/target/target_core_hba.c +5 −0
  2. drivers/target/target_core_spc.c +9 −3
  3. drivers/target/target_core_transport.c +2 −1
  4. include/target/target_core_backend.h +2 −0
drivers/target/target_core_hba.c+5−0
@@ -176,3 +176,8 @@ core_delete_hba(struct se_hba *hba) · 175 unmodified lines
176176 kfree(hba);
177177 return 0;
178178 }
179+
180+bool target_sense_desc_format(struct se_device *dev)
181+{
182+ return dev->transport->get_blocks(dev) > U32_MAX;
183+}
drivers/target/target_core_spc.c+9−3
@@ -761,7 +761,12 @@ static int spc_modesense_control(struct se_cmd *cmd, u8 pc, u8 *p) · 760 unmodified lines
761761 if (pc == 1)
762762 goto out;
763763
764− p[2] = 2;
764+ /* GLTSD: No implicit save of log parameters */
765+ p[2] = (1 << 1);
766+ if (target_sense_desc_format(dev))
767+ /* D_SENSE: Descriptor format sense data for 64bit sectors */
768+ p[2] |= (1 << 2);
769+
765770 /*
766771 * From spc4r23, 7.4.7 Control mode page
767772 *
@@ -1144,6 +1149,7 @@ static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd) · 376 unmodified lines
11441149 unsigned char *rbuf;
11451150 u8 ua_asc = 0, ua_ascq = 0;
11461151 unsigned char buf[SE_SENSE_BUF];
1152+ bool desc_format = target_sense_desc_format(cmd->se_dev);
11471153
11481154 memset(buf, 0, SE_SENSE_BUF);
11491155
@@ -1158,10 +1164,10 @@ static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd) · 8 unmodified lines
11581164 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
11591165
11601166 if (!core_scsi3_ua_clear_for_request_sense(cmd, &ua_asc, &ua_ascq))
1161− scsi_build_sense_buffer(0, buf, UNIT_ATTENTION,
1167+ scsi_build_sense_buffer(desc_format, buf, UNIT_ATTENTION,
11621168 ua_asc, ua_ascq);
11631169 else
1164− scsi_build_sense_buffer(0, buf, NO_SENSE, 0x0, 0x0);
1170+ scsi_build_sense_buffer(desc_format, buf, NO_SENSE, 0x0, 0x0);
11651171
11661172 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length));
11671173 transport_kunmap_data_sg(cmd);
drivers/target/target_core_transport.c+2−1
@@ -2735,6 +2735,7 @@ static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason) · 2734 unmodified lines
27352735 u8 *buffer = cmd->sense_buffer;
27362736 int r = (__force int)reason;
27372737 u8 asc, ascq;
2738+ bool desc_format = target_sense_desc_format(cmd->se_dev);
27382739
27392740 if (r < ARRAY_SIZE(sense_info_table) && sense_info_table[r].key)
27402741 si = &sense_info_table[r];
@@ -2754,7 +2755,7 @@ static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason) · 13 unmodified lines
27542755 ascq = si->ascq;
27552756 }
27562757
2757− scsi_build_sense_buffer(0, buffer, si->key, asc, ascq);
2758+ scsi_build_sense_buffer(desc_format, buffer, si->key, asc, ascq);
27582759 if (si->add_sector_info)
27592760 return scsi_set_sense_information(buffer,
27602761 cmd->scsi_sense_length,
include/target/target_core_backend.h+2−0
@@ -93,4 +93,6 @@ bool target_lun_is_rdonly(struct se_cmd *); · 92 unmodified lines
9393 sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd,
9494 sense_reason_t (*exec_cmd)(struct se_cmd *cmd));
9595
96+bool target_sense_desc_format(struct se_device *dev);
97+
9698 #endif /* TARGET_CORE_BACKEND_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t