Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

target: Add protection SGLs to target_submit_cmd_map_sgls

This patch adds support to target_submit_cmd_map_sgls() for
accepting 'sgl_prot' + 'sgl_prot_count' parameters for
DIF protection information.

Note the passed parameters are stored at se_cmd->t_prot_sg
and se_cmd->t_prot_nents respectively.

Also, update tcm_loop and vhost-scsi fabrics usage of
target_submit_cmd_map_sgls() to take into account the
new parameters.

Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

+18 -5
+1 -1
drivers/target/loopback/tcm_loop.c
··· 217 217 scsi_bufflen(sc), tcm_loop_sam_attr(sc), 218 218 sc->sc_data_direction, 0, 219 219 scsi_sglist(sc), scsi_sg_count(sc), 220 - sgl_bidi, sgl_bidi_count); 220 + sgl_bidi, sgl_bidi_count, NULL, 0); 221 221 if (rc < 0) { 222 222 set_host_byte(sc, DID_NO_CONNECT); 223 223 goto out_done;
+14 -2
drivers/target/target_core_transport.c
··· 1310 1310 * @sgl_count: scatterlist count for unidirectional mapping 1311 1311 * @sgl_bidi: struct scatterlist memory for bidirectional READ mapping 1312 1312 * @sgl_bidi_count: scatterlist count for bidirectional READ mapping 1313 + * @sgl_prot: struct scatterlist memory protection information 1314 + * @sgl_prot_count: scatterlist count for protection information 1313 1315 * 1314 1316 * Returns non zero to signal active I/O shutdown failure. All other 1315 1317 * setup exceptions will be returned as a SCSI CHECK_CONDITION response, ··· 1324 1322 unsigned char *cdb, unsigned char *sense, u32 unpacked_lun, 1325 1323 u32 data_length, int task_attr, int data_dir, int flags, 1326 1324 struct scatterlist *sgl, u32 sgl_count, 1327 - struct scatterlist *sgl_bidi, u32 sgl_bidi_count) 1325 + struct scatterlist *sgl_bidi, u32 sgl_bidi_count, 1326 + struct scatterlist *sgl_prot, u32 sgl_prot_count) 1328 1327 { 1329 1328 struct se_portal_group *se_tpg; 1330 1329 sense_reason_t rc; ··· 1366 1363 transport_send_check_condition_and_sense(se_cmd, rc, 0); 1367 1364 target_put_sess_cmd(se_sess, se_cmd); 1368 1365 return 0; 1366 + } 1367 + /* 1368 + * Save pointers for SGLs containing protection information, 1369 + * if present. 1370 + */ 1371 + if (sgl_prot_count) { 1372 + se_cmd->t_prot_sg = sgl_prot; 1373 + se_cmd->t_prot_nents = sgl_prot_count; 1369 1374 } 1370 1375 1371 1376 rc = target_setup_cmd_from_cdb(se_cmd, cdb); ··· 1417 1406 return 0; 1418 1407 } 1419 1408 } 1409 + 1420 1410 /* 1421 1411 * Check if we need to delay processing because of ALUA 1422 1412 * Active/NonOptimized primary access state.. ··· 1457 1445 { 1458 1446 return target_submit_cmd_map_sgls(se_cmd, se_sess, cdb, sense, 1459 1447 unpacked_lun, data_length, task_attr, data_dir, 1460 - flags, NULL, 0, NULL, 0); 1448 + flags, NULL, 0, NULL, 0, NULL, 0); 1461 1449 } 1462 1450 EXPORT_SYMBOL(target_submit_cmd); 1463 1451
+1 -1
drivers/vhost/scsi.c
··· 889 889 cmd->tvc_lun, cmd->tvc_exp_data_len, 890 890 cmd->tvc_task_attr, cmd->tvc_data_direction, 891 891 TARGET_SCF_ACK_KREF, sg_ptr, cmd->tvc_sgl_count, 892 - sg_bidi_ptr, sg_no_bidi); 892 + sg_bidi_ptr, sg_no_bidi, NULL, 0); 893 893 if (rc < 0) { 894 894 transport_send_check_condition_and_sense(se_cmd, 895 895 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
+2 -1
include/target/target_core_fabric.h
··· 105 105 sense_reason_t target_setup_cmd_from_cdb(struct se_cmd *, unsigned char *); 106 106 int target_submit_cmd_map_sgls(struct se_cmd *, struct se_session *, 107 107 unsigned char *, unsigned char *, u32, u32, int, int, int, 108 - struct scatterlist *, u32, struct scatterlist *, u32); 108 + struct scatterlist *, u32, struct scatterlist *, u32, 109 + struct scatterlist *, u32); 109 110 int target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *, 110 111 unsigned char *, u32, u32, int, int, int); 111 112 int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,