aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-10 06:52:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-10 06:52:19 -0400
commita188e7e93a36627fb3f0013f41857ab54f076d04 (patch)
tree7686a0e870decdab3971db709fb0edf04241c07e /drivers/vhost
parente1b28147f684af67bfac989756c27c19859d3d4e (diff)
parentcf0eb28d3ba60098865bf7dbcbfdd6b1cc483e3b (diff)
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull scsi target updates from Nicholas Bellinger: "Things have been calm for the most part with no new fabric drivers in flight for v3.7 (we're up to eight now !), so this update is primarily focused on addressing a few long-standing items within target-core and iscsi-target fabric code. The highlights include: - target: Simplify fabric sense data length handling (roland) - qla2xxx: Fix endianness of task management response code (roland) - target: fix truncation of mode data, support zero allocation length (paolo) - target: Properly support zero-length commands in normal processing path (paolo) - iscsi-target: Correctly set 0xffffffff field within ISCSI_OP_REJECT PDU (ronnie + nab) - iscsi-target: Add explicit set of cache_dynamic_acls=1 for TPG demo-mode (ronnie + nab) - target/file: Re-enable optional fd_buffered_io=1 operation (nab + hch) - iscsi-target: Add MaxXmitDataSegmenthLength forr target -> initiator MDRSL declaration (nab) - target: Add target_submit_cmd_map_sgls for SGL fabric memory passthrough (nab + hch) - tcm_loop: Convert I/O path to use target_submit_cmd_map_sgls (hch + nab) - tcm_vhost: Convert I/O path to use target_submit_cmd_map_sgls (nab + hch) The last series for adding a new target_submit_cmd_map_sgls() fabric caller (as requested by hch) that accepts pre-allocated SGL memory (using existing logic), along with converting tcm_loop + tcm_vhost has only been in -next for the last days, but has gotten enough review +testing and is clear enough a mechanical change that I think it's reasonable to merge for -rc1 code. Thanks again to everyone who contributed this round! Extra special thanks to Roland (PureStorage) for tracking down the qla2xxx target TMR response code endian issue, and to Paolo (Redhat) for resolving the long standing zero-length CDB issues within target-core between virtual and pSCSI backends." * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (44 commits) iscsi-target: Bump defaults for nopin_timeout + nopin_response_timeout values iscsit: proper endianess conversions iscsit: use the itt_t abstract type iscsit: add missing endianess conversion in iscsit_check_inaddr_any iscsit: remove incorrect unlock in iscsit_build_sendtargets_resp iscsit: mark various functions static target/iscsi: precedence bug in iscsit_set_dataout_sequence_values() target/usb-gadget: strlen() doesn't count the terminator target/usb-gadget: remove duplicate initialization tcm_vhost: Convert I/O path to use target_submit_cmd_map_sgls target: Add control CDB READ payload zero work-around tcm_loop: Convert I/O path to use target_submit_cmd_map_sgls target: Add target_submit_cmd_map_sgls for SGL fabric memory passthrough iscsi-target: Add explicit set of cache_dynamic_acls=1 for TPG demo-mode iscsi-target: Change iscsi_target_seq_pdu_list.c to honor MaxXmitDataSegmentLength iscsi-target: Add MaxXmitDataSegmentLength connection recovery check iscsi-target: Convert incoming PDU payload checks to MaxXmitDataSegmentLength iscsi-target: Enable MaxXmitDataSegmentLength operation in login path iscsi-target: Add base MaxXmitDataSegmentLength code target/file: Re-enable optional fd_buffered_io=1 operation ...
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/tcm_vhost.c81
-rw-r--r--drivers/vhost/tcm_vhost.h8
2 files changed, 22 insertions, 67 deletions
diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
index ed8e2e6c8df2..aa31692064dd 100644
--- a/drivers/vhost/tcm_vhost.c
+++ b/drivers/vhost/tcm_vhost.c
@@ -330,17 +330,6 @@ static int tcm_vhost_queue_tm_rsp(struct se_cmd *se_cmd)
330 return 0; 330 return 0;
331} 331}
332 332
333static u16 tcm_vhost_set_fabric_sense_len(struct se_cmd *se_cmd,
334 u32 sense_length)
335{
336 return 0;
337}
338
339static u16 tcm_vhost_get_fabric_sense_len(void)
340{
341 return 0;
342}
343
344static void vhost_scsi_free_cmd(struct tcm_vhost_cmd *tv_cmd) 333static void vhost_scsi_free_cmd(struct tcm_vhost_cmd *tv_cmd)
345{ 334{
346 struct se_cmd *se_cmd = &tv_cmd->tvc_se_cmd; 335 struct se_cmd *se_cmd = &tv_cmd->tvc_se_cmd;
@@ -426,10 +415,7 @@ static struct tcm_vhost_cmd *vhost_scsi_allocate_cmd(
426{ 415{
427 struct tcm_vhost_cmd *tv_cmd; 416 struct tcm_vhost_cmd *tv_cmd;
428 struct tcm_vhost_nexus *tv_nexus; 417 struct tcm_vhost_nexus *tv_nexus;
429 struct se_portal_group *se_tpg = &tv_tpg->se_tpg;
430 struct se_session *se_sess; 418 struct se_session *se_sess;
431 struct se_cmd *se_cmd;
432 int sam_task_attr;
433 419
434 tv_nexus = tv_tpg->tpg_nexus; 420 tv_nexus = tv_tpg->tpg_nexus;
435 if (!tv_nexus) { 421 if (!tv_nexus) {
@@ -445,23 +431,11 @@ static struct tcm_vhost_cmd *vhost_scsi_allocate_cmd(
445 } 431 }
446 INIT_LIST_HEAD(&tv_cmd->tvc_completion_list); 432 INIT_LIST_HEAD(&tv_cmd->tvc_completion_list);
447 tv_cmd->tvc_tag = v_req->tag; 433 tv_cmd->tvc_tag = v_req->tag;
434 tv_cmd->tvc_task_attr = v_req->task_attr;
435 tv_cmd->tvc_exp_data_len = exp_data_len;
436 tv_cmd->tvc_data_direction = data_direction;
437 tv_cmd->tvc_nexus = tv_nexus;
448 438
449 se_cmd = &tv_cmd->tvc_se_cmd;
450 /*
451 * Locate the SAM Task Attr from virtio_scsi_cmd_req
452 */
453 sam_task_attr = v_req->task_attr;
454 /*
455 * Initialize struct se_cmd descriptor from TCM infrastructure
456 */
457 transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, exp_data_len,
458 data_direction, sam_task_attr,
459 &tv_cmd->tvc_sense_buf[0]);
460
461#if 0 /* FIXME: vhost_scsi_allocate_cmd() BIDI operation */
462 if (bidi)
463 se_cmd->se_cmd_flags |= SCF_BIDI;
464#endif
465 return tv_cmd; 439 return tv_cmd;
466} 440}
467 441
@@ -560,37 +534,10 @@ static void tcm_vhost_submission_work(struct work_struct *work)
560{ 534{
561 struct tcm_vhost_cmd *tv_cmd = 535 struct tcm_vhost_cmd *tv_cmd =
562 container_of(work, struct tcm_vhost_cmd, work); 536 container_of(work, struct tcm_vhost_cmd, work);
537 struct tcm_vhost_nexus *tv_nexus;
563 struct se_cmd *se_cmd = &tv_cmd->tvc_se_cmd; 538 struct se_cmd *se_cmd = &tv_cmd->tvc_se_cmd;
564 struct scatterlist *sg_ptr, *sg_bidi_ptr = NULL; 539 struct scatterlist *sg_ptr, *sg_bidi_ptr = NULL;
565 int rc, sg_no_bidi = 0; 540 int rc, sg_no_bidi = 0;
566 /*
567 * Locate the struct se_lun pointer based on v_req->lun, and
568 * attach it to struct se_cmd
569 */
570 rc = transport_lookup_cmd_lun(&tv_cmd->tvc_se_cmd, tv_cmd->tvc_lun);
571 if (rc < 0) {
572 pr_err("Failed to look up lun: %d\n", tv_cmd->tvc_lun);
573 transport_send_check_condition_and_sense(&tv_cmd->tvc_se_cmd,
574 tv_cmd->tvc_se_cmd.scsi_sense_reason, 0);
575 transport_generic_free_cmd(se_cmd, 0);
576 return;
577 }
578
579 rc = target_setup_cmd_from_cdb(se_cmd, tv_cmd->tvc_cdb);
580 if (rc == -ENOMEM) {
581 transport_send_check_condition_and_sense(se_cmd,
582 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
583 transport_generic_free_cmd(se_cmd, 0);
584 return;
585 } else if (rc < 0) {
586 if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT)
587 tcm_vhost_queue_status(se_cmd);
588 else
589 transport_send_check_condition_and_sense(se_cmd,
590 se_cmd->scsi_sense_reason, 0);
591 transport_generic_free_cmd(se_cmd, 0);
592 return;
593 }
594 541
595 if (tv_cmd->tvc_sgl_count) { 542 if (tv_cmd->tvc_sgl_count) {
596 sg_ptr = tv_cmd->tvc_sgl; 543 sg_ptr = tv_cmd->tvc_sgl;
@@ -608,17 +555,19 @@ static void tcm_vhost_submission_work(struct work_struct *work)
608 } else { 555 } else {
609 sg_ptr = NULL; 556 sg_ptr = NULL;
610 } 557 }
611 558 tv_nexus = tv_cmd->tvc_nexus;
612 rc = transport_generic_map_mem_to_cmd(se_cmd, sg_ptr, 559
613 tv_cmd->tvc_sgl_count, sg_bidi_ptr, 560 rc = target_submit_cmd_map_sgls(se_cmd, tv_nexus->tvn_se_sess,
614 sg_no_bidi); 561 tv_cmd->tvc_cdb, &tv_cmd->tvc_sense_buf[0],
562 tv_cmd->tvc_lun, tv_cmd->tvc_exp_data_len,
563 tv_cmd->tvc_task_attr, tv_cmd->tvc_data_direction,
564 0, sg_ptr, tv_cmd->tvc_sgl_count,
565 sg_bidi_ptr, sg_no_bidi);
615 if (rc < 0) { 566 if (rc < 0) {
616 transport_send_check_condition_and_sense(se_cmd, 567 transport_send_check_condition_and_sense(se_cmd,
617 se_cmd->scsi_sense_reason, 0); 568 TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
618 transport_generic_free_cmd(se_cmd, 0); 569 transport_generic_free_cmd(se_cmd, 0);
619 return;
620 } 570 }
621 transport_handle_cdb_direct(se_cmd);
622} 571}
623 572
624static void vhost_scsi_handle_vq(struct vhost_scsi *vs) 573static void vhost_scsi_handle_vq(struct vhost_scsi *vs)
@@ -1531,8 +1480,6 @@ static struct target_core_fabric_ops tcm_vhost_ops = {
1531 .queue_data_in = tcm_vhost_queue_data_in, 1480 .queue_data_in = tcm_vhost_queue_data_in,
1532 .queue_status = tcm_vhost_queue_status, 1481 .queue_status = tcm_vhost_queue_status,
1533 .queue_tm_rsp = tcm_vhost_queue_tm_rsp, 1482 .queue_tm_rsp = tcm_vhost_queue_tm_rsp,
1534 .get_fabric_sense_len = tcm_vhost_get_fabric_sense_len,
1535 .set_fabric_sense_len = tcm_vhost_set_fabric_sense_len,
1536 /* 1483 /*
1537 * Setup callers for generic logic in target_core_fabric_configfs.c 1484 * Setup callers for generic logic in target_core_fabric_configfs.c
1538 */ 1485 */
diff --git a/drivers/vhost/tcm_vhost.h b/drivers/vhost/tcm_vhost.h
index d9e93557d669..7e87c63ecbcd 100644
--- a/drivers/vhost/tcm_vhost.h
+++ b/drivers/vhost/tcm_vhost.h
@@ -5,6 +5,12 @@
5struct tcm_vhost_cmd { 5struct tcm_vhost_cmd {
6 /* Descriptor from vhost_get_vq_desc() for virt_queue segment */ 6 /* Descriptor from vhost_get_vq_desc() for virt_queue segment */
7 int tvc_vq_desc; 7 int tvc_vq_desc;
8 /* virtio-scsi initiator task attribute */
9 int tvc_task_attr;
10 /* virtio-scsi initiator data direction */
11 enum dma_data_direction tvc_data_direction;
12 /* Expected data transfer length from virtio-scsi header */
13 u32 tvc_exp_data_len;
8 /* The Tag from include/linux/virtio_scsi.h:struct virtio_scsi_cmd_req */ 14 /* The Tag from include/linux/virtio_scsi.h:struct virtio_scsi_cmd_req */
9 u64 tvc_tag; 15 u64 tvc_tag;
10 /* The number of scatterlists associated with this cmd */ 16 /* The number of scatterlists associated with this cmd */
@@ -17,6 +23,8 @@ struct tcm_vhost_cmd {
17 struct virtio_scsi_cmd_resp __user *tvc_resp; 23 struct virtio_scsi_cmd_resp __user *tvc_resp;
18 /* Pointer to vhost_scsi for our device */ 24 /* Pointer to vhost_scsi for our device */
19 struct vhost_scsi *tvc_vhost; 25 struct vhost_scsi *tvc_vhost;
26 /* Pointer to vhost nexus memory */
27 struct tcm_vhost_nexus *tvc_nexus;
20 /* The TCM I/O descriptor that is accessed via container_of() */ 28 /* The TCM I/O descriptor that is accessed via container_of() */
21 struct se_cmd tvc_se_cmd; 29 struct se_cmd tvc_se_cmd;
22 /* work item used for cmwq dispatch to tcm_vhost_submission_work() */ 30 /* work item used for cmwq dispatch to tcm_vhost_submission_work() */