diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-11-08 16:10:44 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-11-08 16:13:38 -0500 |
commit | 4863e525659abbc903aacc67fd916f12914f6c1d (patch) | |
tree | 228f0fe16e5264922c383c5b9a6cfc17b30a5e6d /drivers/target | |
parent | 4a9a6c8d538eff6d627fa14409c7c25aff652541 (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>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_device.c | 9 | ||||
-rw-r--r-- | drivers/target/target_core_xcopy.c | 18 |
2 files changed, 10 insertions, 17 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) | |||
1409 | struct se_device *target_alloc_device(struct se_hba *hba, const char *name) | 1409 | struct 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 | ||
655 | out: | 641 | out: |
656 | if (remote_port == true) | ||
657 | kfree(cmd->se_lun); | ||
658 | return ret; | 642 | return ret; |
659 | } | 643 | } |
660 | 644 | ||