aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2013-11-08 16:10:44 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2013-11-08 16:13:38 -0500
commit4863e525659abbc903aacc67fd916f12914f6c1d (patch)
tree228f0fe16e5264922c383c5b9a6cfc17b30a5e6d
parent4a9a6c8d538eff6d627fa14409c7c25aff652541 (diff)
target: Add per device xcopy_lun for copy offload I/O
This patch adds a se_device->xcopy_lun that is used for local copy offload I/O, instead of allocating + initializing a pseudo se_lun for each received EXTENDED_COPY operation. Also, move declaration of struct se_lun + struct se_port_stat_grps ahead of struct se_device. Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/target_core_device.c9
-rw-r--r--drivers/target/target_core_xcopy.c18
-rw-r--r--include/target/target_core_base.h57
3 files changed, 39 insertions, 45 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 569a3c7c9e5a..dbe40ef14776 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -1409,6 +1409,7 @@ static void scsi_dump_inquiry(struct se_device *dev)
1409struct se_device *target_alloc_device(struct se_hba *hba, const char *name) 1409struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
1410{ 1410{
1411 struct se_device *dev; 1411 struct se_device *dev;
1412 struct se_lun *xcopy_lun;
1412 1413
1413 dev = hba->transport->alloc_device(hba, name); 1414 dev = hba->transport->alloc_device(hba, name);
1414 if (!dev) 1415 if (!dev)
@@ -1471,6 +1472,14 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
1471 dev->dev_attrib.fabric_max_sectors = DA_FABRIC_MAX_SECTORS; 1472 dev->dev_attrib.fabric_max_sectors = DA_FABRIC_MAX_SECTORS;
1472 dev->dev_attrib.optimal_sectors = DA_FABRIC_MAX_SECTORS; 1473 dev->dev_attrib.optimal_sectors = DA_FABRIC_MAX_SECTORS;
1473 1474
1475 xcopy_lun = &dev->xcopy_lun;
1476 xcopy_lun->lun_se_dev = dev;
1477 init_completion(&xcopy_lun->lun_shutdown_comp);
1478 INIT_LIST_HEAD(&xcopy_lun->lun_acl_list);
1479 spin_lock_init(&xcopy_lun->lun_acl_lock);
1480 spin_lock_init(&xcopy_lun->lun_sep_lock);
1481 init_completion(&xcopy_lun->lun_ref_comp);
1482
1474 return dev; 1483 return dev;
1475} 1484}
1476 1485
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index b12fc43b5463..d67304a6aa9e 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -401,9 +401,6 @@ static void xcopy_pt_release_cmd(struct se_cmd *se_cmd)
401 struct xcopy_pt_cmd *xpt_cmd = container_of(se_cmd, 401 struct xcopy_pt_cmd *xpt_cmd = container_of(se_cmd,
402 struct xcopy_pt_cmd, se_cmd); 402 struct xcopy_pt_cmd, se_cmd);
403 403
404 if (xpt_cmd->remote_port)
405 kfree(se_cmd->se_lun);
406
407 kfree(xpt_cmd); 404 kfree(xpt_cmd);
408} 405}
409 406
@@ -568,21 +565,10 @@ static int target_xcopy_init_pt_lun(
568 return 0; 565 return 0;
569 } 566 }
570 567
571 pt_cmd->se_lun = kzalloc(sizeof(struct se_lun), GFP_KERNEL); 568 pt_cmd->se_lun = &se_dev->xcopy_lun;
572 if (!pt_cmd->se_lun) {
573 pr_err("Unable to allocate pt_cmd->se_lun\n");
574 return -ENOMEM;
575 }
576 init_completion(&pt_cmd->se_lun->lun_shutdown_comp);
577 INIT_LIST_HEAD(&pt_cmd->se_lun->lun_acl_list);
578 spin_lock_init(&pt_cmd->se_lun->lun_acl_lock);
579 spin_lock_init(&pt_cmd->se_lun->lun_sep_lock);
580 init_completion(&pt_cmd->se_lun->lun_ref_comp);
581
582 pt_cmd->se_dev = se_dev; 569 pt_cmd->se_dev = se_dev;
583 570
584 pr_debug("Setup emulated se_dev: %p from se_dev\n", pt_cmd->se_dev); 571 pr_debug("Setup emulated se_dev: %p from se_dev\n", pt_cmd->se_dev);
585 pt_cmd->se_lun->lun_se_dev = se_dev;
586 pt_cmd->se_cmd_flags |= SCF_SE_LUN_CMD | SCF_CMD_XCOPY_PASSTHROUGH; 572 pt_cmd->se_cmd_flags |= SCF_SE_LUN_CMD | SCF_CMD_XCOPY_PASSTHROUGH;
587 573
588 pr_debug("Setup emulated se_dev: %p to pt_cmd->se_lun->lun_se_dev\n", 574 pr_debug("Setup emulated se_dev: %p to pt_cmd->se_lun->lun_se_dev\n",
@@ -653,8 +639,6 @@ static int target_xcopy_setup_pt_cmd(
653 return 0; 639 return 0;
654 640
655out: 641out:
656 if (remote_port == true)
657 kfree(cmd->se_lun);
658 return ret; 642 return ret;
659} 643}
660 644
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 1ad0a4240b00..96bf1b0239cc 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -627,6 +627,34 @@ struct se_dev_attrib {
627 struct config_group da_group; 627 struct config_group da_group;
628}; 628};
629 629
630struct se_port_stat_grps {
631 struct config_group stat_group;
632 struct config_group scsi_port_group;
633 struct config_group scsi_tgt_port_group;
634 struct config_group scsi_transport_group;
635};
636
637struct se_lun {
638#define SE_LUN_LINK_MAGIC 0xffff7771
639 u32 lun_link_magic;
640 /* See transport_lun_status_table */
641 enum transport_lun_status_table lun_status;
642 u32 lun_access;
643 u32 lun_flags;
644 u32 unpacked_lun;
645 atomic_t lun_acl_count;
646 spinlock_t lun_acl_lock;
647 spinlock_t lun_sep_lock;
648 struct completion lun_shutdown_comp;
649 struct list_head lun_acl_list;
650 struct se_device *lun_se_dev;
651 struct se_port *lun_sep;
652 struct config_group lun_group;
653 struct se_port_stat_grps port_stat_grps;
654 struct completion lun_ref_comp;
655 struct percpu_ref lun_ref;
656};
657
630struct se_dev_stat_grps { 658struct se_dev_stat_grps {
631 struct config_group stat_group; 659 struct config_group stat_group;
632 struct config_group scsi_dev_group; 660 struct config_group scsi_dev_group;
@@ -710,6 +738,7 @@ struct se_device {
710 struct se_subsystem_api *transport; 738 struct se_subsystem_api *transport;
711 /* Linked list for struct se_hba struct se_device list */ 739 /* Linked list for struct se_hba struct se_device list */
712 struct list_head dev_list; 740 struct list_head dev_list;
741 struct se_lun xcopy_lun;
713}; 742};
714 743
715struct se_hba { 744struct se_hba {
@@ -729,34 +758,6 @@ struct se_hba {
729 struct se_subsystem_api *transport; 758 struct se_subsystem_api *transport;
730}; 759};
731 760
732struct se_port_stat_grps {
733 struct config_group stat_group;
734 struct config_group scsi_port_group;
735 struct config_group scsi_tgt_port_group;
736 struct config_group scsi_transport_group;
737};
738
739struct se_lun {
740#define SE_LUN_LINK_MAGIC 0xffff7771
741 u32 lun_link_magic;
742 /* See transport_lun_status_table */
743 enum transport_lun_status_table lun_status;
744 u32 lun_access;
745 u32 lun_flags;
746 u32 unpacked_lun;
747 atomic_t lun_acl_count;
748 spinlock_t lun_acl_lock;
749 spinlock_t lun_sep_lock;
750 struct completion lun_shutdown_comp;
751 struct list_head lun_acl_list;
752 struct se_device *lun_se_dev;
753 struct se_port *lun_sep;
754 struct config_group lun_group;
755 struct se_port_stat_grps port_stat_grps;
756 struct completion lun_ref_comp;
757 struct percpu_ref lun_ref;
758};
759
760struct scsi_port_stats { 761struct scsi_port_stats {
761 u64 cmd_pdus; 762 u64 cmd_pdus;
762 u64 tx_data_octets; 763 u64 tx_data_octets;