Commit 4863e525659abbc903aacc67fd916f12914f6c1d

Authored by Nicholas Bellinger
1 parent 4a9a6c8d53

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>

Showing 3 changed files with 39 additions and 45 deletions Side-by-side Diff

drivers/target/target_core_device.c
... ... @@ -1409,6 +1409,7 @@
1409 1409 struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
1410 1410 {
1411 1411 struct se_device *dev;
  1412 + struct se_lun *xcopy_lun;
1412 1413  
1413 1414 dev = hba->transport->alloc_device(hba, name);
1414 1415 if (!dev)
... ... @@ -1470,6 +1471,14 @@
1470 1471 dev->dev_attrib.max_write_same_len = DA_MAX_WRITE_SAME_LEN;
1471 1472 dev->dev_attrib.fabric_max_sectors = DA_FABRIC_MAX_SECTORS;
1472 1473 dev->dev_attrib.optimal_sectors = DA_FABRIC_MAX_SECTORS;
  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);
1473 1482  
1474 1483 return dev;
1475 1484 }
drivers/target/target_core_xcopy.c
... ... @@ -401,9 +401,6 @@
401 401 struct xcopy_pt_cmd *xpt_cmd = container_of(se_cmd,
402 402 struct xcopy_pt_cmd, se_cmd);
403 403  
404   - if (xpt_cmd->remote_port)
405   - kfree(se_cmd->se_lun);
406   -
407 404 kfree(xpt_cmd);
408 405 }
409 406  
410 407  
... ... @@ -568,21 +565,10 @@
568 565 return 0;
569 566 }
570 567  
571   - pt_cmd->se_lun = kzalloc(sizeof(struct se_lun), GFP_KERNEL);
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   -
  568 + pt_cmd->se_lun = &se_dev->xcopy_lun;
582 569 pt_cmd->se_dev = se_dev;
583 570  
584 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 572 pt_cmd->se_cmd_flags |= SCF_SE_LUN_CMD | SCF_CMD_XCOPY_PASSTHROUGH;
587 573  
588 574 pr_debug("Setup emulated se_dev: %p to pt_cmd->se_lun->lun_se_dev\n",
... ... @@ -653,8 +639,6 @@
653 639 return 0;
654 640  
655 641 out:
656   - if (remote_port == true)
657   - kfree(cmd->se_lun);
658 642 return ret;
659 643 }
660 644  
include/target/target_core_base.h
... ... @@ -627,6 +627,34 @@
627 627 struct config_group da_group;
628 628 };
629 629  
  630 +struct 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 +
  637 +struct 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 +
630 658 struct se_dev_stat_grps {
631 659 struct config_group stat_group;
632 660 struct config_group scsi_dev_group;
... ... @@ -710,6 +738,7 @@
710 738 struct se_subsystem_api *transport;
711 739 /* Linked list for struct se_hba struct se_device list */
712 740 struct list_head dev_list;
  741 + struct se_lun xcopy_lun;
713 742 };
714 743  
715 744 struct se_hba {
... ... @@ -727,34 +756,6 @@
727 756 struct config_group hba_group;
728 757 struct mutex hba_access_mutex;
729 758 struct se_subsystem_api *transport;
730   -};
731   -
732   -struct 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   -
739   -struct 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 };
759 760  
760 761 struct scsi_port_stats {