diff options
author | Christoph Hellwig <hch@infradead.org> | 2012-10-08 00:03:19 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-11-06 23:55:43 -0500 |
commit | 0fd97ccf45be26fb01b3a412f1f6c6b5044b2f16 (patch) | |
tree | c642e3da11e534a311a1e998ef740a3d44b9187b /include/target | |
parent | 3d70f8c617a436c7146ecb81df2265b4626dfe89 (diff) |
target: kill struct se_subsystem_dev
Simplify the code a lot by killing the superflous struct se_subsystem_dev.
Instead se_device is allocated early on by the backend driver, which allocates
it as part of its own per-device structure, borrowing the scheme that is for
example used for inode allocation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'include/target')
-rw-r--r-- | include/target/target_core_backend.h | 25 | ||||
-rw-r--r-- | include/target/target_core_base.h | 104 |
2 files changed, 38 insertions, 91 deletions
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 2acd54018b64..6c5bfb5ac17f 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h | |||
@@ -9,6 +9,8 @@ struct se_subsystem_api { | |||
9 | struct list_head sub_api_list; | 9 | struct list_head sub_api_list; |
10 | 10 | ||
11 | char name[16]; | 11 | char name[16]; |
12 | char inquiry_prod[16]; | ||
13 | char inquiry_rev[4]; | ||
12 | struct module *owner; | 14 | struct module *owner; |
13 | 15 | ||
14 | u8 transport_type; | 16 | u8 transport_type; |
@@ -16,21 +18,20 @@ struct se_subsystem_api { | |||
16 | int (*attach_hba)(struct se_hba *, u32); | 18 | int (*attach_hba)(struct se_hba *, u32); |
17 | void (*detach_hba)(struct se_hba *); | 19 | void (*detach_hba)(struct se_hba *); |
18 | int (*pmode_enable_hba)(struct se_hba *, unsigned long); | 20 | int (*pmode_enable_hba)(struct se_hba *, unsigned long); |
19 | void *(*allocate_virtdevice)(struct se_hba *, const char *); | 21 | |
20 | struct se_device *(*create_virtdevice)(struct se_hba *, | 22 | struct se_device *(*alloc_device)(struct se_hba *, const char *); |
21 | struct se_subsystem_dev *, void *); | 23 | int (*configure_device)(struct se_device *); |
22 | void (*free_device)(void *); | 24 | void (*free_device)(struct se_device *device); |
25 | |||
26 | ssize_t (*set_configfs_dev_params)(struct se_device *, | ||
27 | const char *, ssize_t); | ||
28 | ssize_t (*show_configfs_dev_params)(struct se_device *, char *); | ||
29 | |||
23 | void (*transport_complete)(struct se_cmd *cmd, | 30 | void (*transport_complete)(struct se_cmd *cmd, |
24 | struct scatterlist *, | 31 | struct scatterlist *, |
25 | unsigned char *); | 32 | unsigned char *); |
26 | 33 | ||
27 | int (*parse_cdb)(struct se_cmd *cmd); | 34 | int (*parse_cdb)(struct se_cmd *cmd); |
28 | ssize_t (*check_configfs_dev_params)(struct se_hba *, | ||
29 | struct se_subsystem_dev *); | ||
30 | ssize_t (*set_configfs_dev_params)(struct se_hba *, | ||
31 | struct se_subsystem_dev *, const char *, ssize_t); | ||
32 | ssize_t (*show_configfs_dev_params)(struct se_hba *, | ||
33 | struct se_subsystem_dev *, char *); | ||
34 | u32 (*get_device_rev)(struct se_device *); | 35 | u32 (*get_device_rev)(struct se_device *); |
35 | u32 (*get_device_type)(struct se_device *); | 36 | u32 (*get_device_type)(struct se_device *); |
36 | sector_t (*get_blocks)(struct se_device *); | 37 | sector_t (*get_blocks)(struct se_device *); |
@@ -47,10 +48,6 @@ struct spc_ops { | |||
47 | int transport_subsystem_register(struct se_subsystem_api *); | 48 | int transport_subsystem_register(struct se_subsystem_api *); |
48 | void transport_subsystem_release(struct se_subsystem_api *); | 49 | void transport_subsystem_release(struct se_subsystem_api *); |
49 | 50 | ||
50 | struct se_device *transport_add_device_to_core_hba(struct se_hba *, | ||
51 | struct se_subsystem_api *, struct se_subsystem_dev *, u32, | ||
52 | void *, struct se_dev_limits *, const char *, const char *); | ||
53 | |||
54 | void target_complete_cmd(struct se_cmd *, u8); | 51 | void target_complete_cmd(struct se_cmd *, u8); |
55 | 52 | ||
56 | int sbc_parse_cdb(struct se_cmd *cmd, struct spc_ops *ops); | 53 | int sbc_parse_cdb(struct se_cmd *cmd, struct spc_ops *ops); |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 5be89373ceac..f6355fc325a8 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
@@ -62,20 +62,6 @@ | |||
62 | 62 | ||
63 | #define PYX_TRANSPORT_STATUS_INTERVAL 5 /* In seconds */ | 63 | #define PYX_TRANSPORT_STATUS_INTERVAL 5 /* In seconds */ |
64 | 64 | ||
65 | /* | ||
66 | * struct se_subsystem_dev->su_dev_flags | ||
67 | */ | ||
68 | #define SDF_FIRMWARE_VPD_UNIT_SERIAL 0x00000001 | ||
69 | #define SDF_EMULATED_VPD_UNIT_SERIAL 0x00000002 | ||
70 | #define SDF_USING_UDEV_PATH 0x00000004 | ||
71 | #define SDF_USING_ALIAS 0x00000008 | ||
72 | |||
73 | /* | ||
74 | * struct se_device->dev_flags | ||
75 | */ | ||
76 | #define DF_SPC2_RESERVATIONS 0x00000001 | ||
77 | #define DF_SPC2_RESERVATIONS_WITH_ISID 0x00000002 | ||
78 | |||
79 | /* struct se_dev_attrib sanity values */ | 65 | /* struct se_dev_attrib sanity values */ |
80 | /* Default max_unmap_lba_count */ | 66 | /* Default max_unmap_lba_count */ |
81 | #define DA_MAX_UNMAP_LBA_COUNT 0 | 67 | #define DA_MAX_UNMAP_LBA_COUNT 0 |
@@ -182,16 +168,6 @@ enum transport_lunflags_table { | |||
182 | TRANSPORT_LUNFLAGS_READ_WRITE = 0x04, | 168 | TRANSPORT_LUNFLAGS_READ_WRITE = 0x04, |
183 | }; | 169 | }; |
184 | 170 | ||
185 | /* struct se_device->dev_status */ | ||
186 | enum transport_device_status_table { | ||
187 | TRANSPORT_DEVICE_ACTIVATED = 0x01, | ||
188 | TRANSPORT_DEVICE_DEACTIVATED = 0x02, | ||
189 | TRANSPORT_DEVICE_QUEUE_FULL = 0x04, | ||
190 | TRANSPORT_DEVICE_SHUTDOWN = 0x08, | ||
191 | TRANSPORT_DEVICE_OFFLINE_ACTIVATED = 0x10, | ||
192 | TRANSPORT_DEVICE_OFFLINE_DEACTIVATED = 0x20, | ||
193 | }; | ||
194 | |||
195 | /* | 171 | /* |
196 | * Used by transport_send_check_condition_and_sense() and se_cmd->scsi_sense_reason | 172 | * Used by transport_send_check_condition_and_sense() and se_cmd->scsi_sense_reason |
197 | * to signal which ASC/ASCQ sense payload should be built. | 173 | * to signal which ASC/ASCQ sense payload should be built. |
@@ -246,10 +222,6 @@ enum tcm_tmrsp_table { | |||
246 | TMR_FUNCTION_REJECTED = 255, | 222 | TMR_FUNCTION_REJECTED = 255, |
247 | }; | 223 | }; |
248 | 224 | ||
249 | struct se_obj { | ||
250 | atomic_t obj_access_count; | ||
251 | }; | ||
252 | |||
253 | /* | 225 | /* |
254 | * Used by TCM Core internally to signal if ALUA emulation is enabled or | 226 | * Used by TCM Core internally to signal if ALUA emulation is enabled or |
255 | * disabled, or running in with TCM/pSCSI passthrough mode | 227 | * disabled, or running in with TCM/pSCSI passthrough mode |
@@ -288,7 +260,7 @@ struct t10_alua { | |||
288 | u16 alua_tg_pt_gps_counter; | 260 | u16 alua_tg_pt_gps_counter; |
289 | u32 alua_tg_pt_gps_count; | 261 | u32 alua_tg_pt_gps_count; |
290 | spinlock_t tg_pt_gps_lock; | 262 | spinlock_t tg_pt_gps_lock; |
291 | struct se_subsystem_dev *t10_sub_dev; | 263 | struct se_device *t10_dev; |
292 | /* Used for default ALUA Target Port Group */ | 264 | /* Used for default ALUA Target Port Group */ |
293 | struct t10_alua_tg_pt_gp *default_tg_pt_gp; | 265 | struct t10_alua_tg_pt_gp *default_tg_pt_gp; |
294 | /* Used for default ALUA Target Port Group ConfigFS group */ | 266 | /* Used for default ALUA Target Port Group ConfigFS group */ |
@@ -335,7 +307,7 @@ struct t10_alua_tg_pt_gp { | |||
335 | atomic_t tg_pt_gp_ref_cnt; | 307 | atomic_t tg_pt_gp_ref_cnt; |
336 | spinlock_t tg_pt_gp_lock; | 308 | spinlock_t tg_pt_gp_lock; |
337 | struct mutex tg_pt_gp_md_mutex; | 309 | struct mutex tg_pt_gp_md_mutex; |
338 | struct se_subsystem_dev *tg_pt_gp_su_dev; | 310 | struct se_device *tg_pt_gp_dev; |
339 | struct config_group tg_pt_gp_group; | 311 | struct config_group tg_pt_gp_group; |
340 | struct list_head tg_pt_gp_list; | 312 | struct list_head tg_pt_gp_list; |
341 | struct list_head tg_pt_gp_mem_list; | 313 | struct list_head tg_pt_gp_mem_list; |
@@ -366,7 +338,7 @@ struct t10_wwn { | |||
366 | char revision[4]; | 338 | char revision[4]; |
367 | char unit_serial[INQUIRY_VPD_SERIAL_LEN]; | 339 | char unit_serial[INQUIRY_VPD_SERIAL_LEN]; |
368 | spinlock_t t10_vpd_lock; | 340 | spinlock_t t10_vpd_lock; |
369 | struct se_subsystem_dev *t10_sub_dev; | 341 | struct se_device *t10_dev; |
370 | struct config_group t10_wwn_group; | 342 | struct config_group t10_wwn_group; |
371 | struct list_head t10_vpd_list; | 343 | struct list_head t10_vpd_list; |
372 | }; | 344 | }; |
@@ -662,15 +634,6 @@ struct se_dev_entry { | |||
662 | struct list_head ua_list; | 634 | struct list_head ua_list; |
663 | }; | 635 | }; |
664 | 636 | ||
665 | struct se_dev_limits { | ||
666 | /* Max supported HW queue depth */ | ||
667 | u32 hw_queue_depth; | ||
668 | /* Max supported virtual queue depth */ | ||
669 | u32 queue_depth; | ||
670 | /* From include/linux/blkdev.h for the other HW/SW limits. */ | ||
671 | struct queue_limits limits; | ||
672 | }; | ||
673 | |||
674 | struct se_dev_attrib { | 637 | struct se_dev_attrib { |
675 | int emulate_dpo; | 638 | int emulate_dpo; |
676 | int emulate_fua_write; | 639 | int emulate_fua_write; |
@@ -696,7 +659,7 @@ struct se_dev_attrib { | |||
696 | u32 max_unmap_block_desc_count; | 659 | u32 max_unmap_block_desc_count; |
697 | u32 unmap_granularity; | 660 | u32 unmap_granularity; |
698 | u32 unmap_granularity_alignment; | 661 | u32 unmap_granularity_alignment; |
699 | struct se_subsystem_dev *da_sub_dev; | 662 | struct se_device *da_dev; |
700 | struct config_group da_group; | 663 | struct config_group da_group; |
701 | }; | 664 | }; |
702 | 665 | ||
@@ -707,48 +670,24 @@ struct se_dev_stat_grps { | |||
707 | struct config_group scsi_lu_group; | 670 | struct config_group scsi_lu_group; |
708 | }; | 671 | }; |
709 | 672 | ||
710 | struct se_subsystem_dev { | ||
711 | /* Used for struct se_subsystem_dev-->se_dev_alias, must be less than PAGE_SIZE */ | ||
712 | #define SE_DEV_ALIAS_LEN 512 | ||
713 | unsigned char se_dev_alias[SE_DEV_ALIAS_LEN]; | ||
714 | /* Used for struct se_subsystem_dev->se_dev_udev_path[], must be less than PAGE_SIZE */ | ||
715 | #define SE_UDEV_PATH_LEN 512 | ||
716 | unsigned char se_dev_udev_path[SE_UDEV_PATH_LEN]; | ||
717 | u32 su_dev_flags; | ||
718 | struct se_hba *se_dev_hba; | ||
719 | struct se_device *se_dev_ptr; | ||
720 | struct se_dev_attrib se_dev_attrib; | ||
721 | /* T10 Asymmetric Logical Unit Assignment for Target Ports */ | ||
722 | struct t10_alua t10_alua; | ||
723 | /* T10 Inquiry and VPD WWN Information */ | ||
724 | struct t10_wwn t10_wwn; | ||
725 | /* T10 SPC-2 + SPC-3 Reservations */ | ||
726 | struct t10_reservation t10_pr; | ||
727 | spinlock_t se_dev_lock; | ||
728 | void *se_dev_su_ptr; | ||
729 | struct config_group se_dev_group; | ||
730 | /* For T10 Reservations */ | ||
731 | struct config_group se_dev_pr_group; | ||
732 | /* For target_core_stat.c groups */ | ||
733 | struct se_dev_stat_grps dev_stat_grps; | ||
734 | }; | ||
735 | |||
736 | struct se_device { | 673 | struct se_device { |
737 | /* RELATIVE TARGET PORT IDENTIFER Counter */ | 674 | /* RELATIVE TARGET PORT IDENTIFER Counter */ |
738 | u16 dev_rpti_counter; | 675 | u16 dev_rpti_counter; |
739 | /* Used for SAM Task Attribute ordering */ | 676 | /* Used for SAM Task Attribute ordering */ |
740 | u32 dev_cur_ordered_id; | 677 | u32 dev_cur_ordered_id; |
741 | u32 dev_flags; | 678 | u32 dev_flags; |
679 | #define DF_CONFIGURED 0x00000001 | ||
680 | #define DF_FIRMWARE_VPD_UNIT_SERIAL 0x00000002 | ||
681 | #define DF_EMULATED_VPD_UNIT_SERIAL 0x00000004 | ||
682 | #define DF_USING_UDEV_PATH 0x00000008 | ||
683 | #define DF_USING_ALIAS 0x00000010 | ||
742 | u32 dev_port_count; | 684 | u32 dev_port_count; |
743 | /* See transport_device_status_table */ | ||
744 | u32 dev_status; | ||
745 | /* Physical device queue depth */ | 685 | /* Physical device queue depth */ |
746 | u32 queue_depth; | 686 | u32 queue_depth; |
747 | /* Used for SPC-2 reservations enforce of ISIDs */ | 687 | /* Used for SPC-2 reservations enforce of ISIDs */ |
748 | u64 dev_res_bin_isid; | 688 | u64 dev_res_bin_isid; |
749 | t10_task_attr_index_t dev_task_attr_type; | 689 | t10_task_attr_index_t dev_task_attr_type; |
750 | /* Pointer to transport specific device structure */ | 690 | /* Pointer to transport specific device structure */ |
751 | void *dev_ptr; | ||
752 | u32 dev_index; | 691 | u32 dev_index; |
753 | u64 creation_time; | 692 | u64 creation_time; |
754 | u32 num_resets; | 693 | u32 num_resets; |
@@ -761,13 +700,13 @@ struct se_device { | |||
761 | atomic_t dev_ordered_id; | 700 | atomic_t dev_ordered_id; |
762 | atomic_t dev_ordered_sync; | 701 | atomic_t dev_ordered_sync; |
763 | atomic_t dev_qf_count; | 702 | atomic_t dev_qf_count; |
764 | struct se_obj dev_obj; | 703 | int export_count; |
765 | struct se_obj dev_access_obj; | ||
766 | struct se_obj dev_export_obj; | ||
767 | spinlock_t delayed_cmd_lock; | 704 | spinlock_t delayed_cmd_lock; |
768 | spinlock_t execute_task_lock; | 705 | spinlock_t execute_task_lock; |
769 | spinlock_t dev_reservation_lock; | 706 | spinlock_t dev_reservation_lock; |
770 | spinlock_t dev_status_lock; | 707 | unsigned int dev_reservation_flags; |
708 | #define DRF_SPC2_RESERVATIONS 0x00000001 | ||
709 | #define DRF_SPC2_RESERVATIONS_WITH_ISID 0x00000002 | ||
771 | spinlock_t se_port_lock; | 710 | spinlock_t se_port_lock; |
772 | spinlock_t se_tmr_lock; | 711 | spinlock_t se_tmr_lock; |
773 | spinlock_t qf_cmd_lock; | 712 | spinlock_t qf_cmd_lock; |
@@ -786,7 +725,20 @@ struct se_device { | |||
786 | struct list_head qf_cmd_list; | 725 | struct list_head qf_cmd_list; |
787 | /* Pointer to associated SE HBA */ | 726 | /* Pointer to associated SE HBA */ |
788 | struct se_hba *se_hba; | 727 | struct se_hba *se_hba; |
789 | struct se_subsystem_dev *se_sub_dev; | 728 | /* T10 Inquiry and VPD WWN Information */ |
729 | struct t10_wwn t10_wwn; | ||
730 | /* T10 Asymmetric Logical Unit Assignment for Target Ports */ | ||
731 | struct t10_alua t10_alua; | ||
732 | /* T10 SPC-2 + SPC-3 Reservations */ | ||
733 | struct t10_reservation t10_pr; | ||
734 | struct se_dev_attrib dev_attrib; | ||
735 | struct config_group dev_group; | ||
736 | struct config_group dev_pr_group; | ||
737 | struct se_dev_stat_grps dev_stat_grps; | ||
738 | #define SE_DEV_ALIAS_LEN 512 /* must be less than PAGE_SIZE */ | ||
739 | unsigned char dev_alias[SE_DEV_ALIAS_LEN]; | ||
740 | #define SE_UDEV_PATH_LEN 512 /* must be less than PAGE_SIZE */ | ||
741 | unsigned char udev_path[SE_UDEV_PATH_LEN]; | ||
790 | /* Pointer to template of function pointers for transport */ | 742 | /* Pointer to template of function pointers for transport */ |
791 | struct se_subsystem_api *transport; | 743 | struct se_subsystem_api *transport; |
792 | /* Linked list for struct se_hba struct se_device list */ | 744 | /* Linked list for struct se_hba struct se_device list */ |
@@ -803,8 +755,6 @@ struct se_hba { | |||
803 | u32 hba_index; | 755 | u32 hba_index; |
804 | /* Pointer to transport specific host structure. */ | 756 | /* Pointer to transport specific host structure. */ |
805 | void *hba_ptr; | 757 | void *hba_ptr; |
806 | /* Linked list for struct se_device */ | ||
807 | struct list_head hba_dev_list; | ||
808 | struct list_head hba_node; | 758 | struct list_head hba_node; |
809 | spinlock_t device_lock; | 759 | spinlock_t device_lock; |
810 | struct config_group hba_group; | 760 | struct config_group hba_group; |