aboutsummaryrefslogtreecommitdiffstats
path: root/include/target
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2011-07-19 04:55:10 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-07-22 05:37:43 -0400
commite3d6f909ed803d92a5ac9b4a2c087e0eae9b90d0 (patch)
tree2eb65e958a2cc35c896a0e184ec09edcb9076b3b /include/target
parenta8c6da90b823fb94ca76ca0df6bb44e6e205dc87 (diff)
target: Core cleanups from AGrover (round 1)
This patch contains the squashed version of a number of cleanups and minor fixes from Andy's initial series (round 1) for target core this past spring. The condensed log looks like: target: use errno values instead of returning -1 for everything target: Rename transport_calc_sg_num to transport_init_task_sg target: Fix leak in error path in transport_init_task_sg target/pscsi: Remove pscsi_get_sh() usage target: Make two runtime checks into WARN_ONs target: Remove hba queue depth and convert to spin_lock_irq usage target: dev->dev_status_queue_obj is unused target: Make struct se_queue_req.cmd type struct se_cmd * target: Remove __transport_get_qr_from_queue() target: Rename se_dev->g_se_dev_list to se_dev_node target: Remove struct se_global target: Simplify scsi mib index table code target: Make dev_queue_obj a member of se_device instead of a pointer target: remove extraneous returns at end of void functions target: Ensure transport_dump_vpd_ident_type returns null-terminated str target: Function pointers don't need to use '&' to be assigned target: Fix comment in __transport_execute_tasks() target: Misc style cleanups target: rename struct pr_reservation_template to pr_reservation target: Remove #defines that just perform indirection target: Inline transport_get_task_from_execute_queue() target: Minor header comment fixes Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'include/target')
-rw-r--r--include/target/target_core_base.h89
-rw-r--r--include/target/target_core_transport.h12
2 files changed, 16 insertions, 85 deletions
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 561ac99def5a..b0b83edbe453 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -205,11 +205,6 @@ typedef enum {
205 SCSI_INDEX_TYPE_MAX 205 SCSI_INDEX_TYPE_MAX
206} scsi_index_t; 206} scsi_index_t;
207 207
208struct scsi_index_table {
209 spinlock_t lock;
210 u32 scsi_mib_index[SCSI_INDEX_TYPE_MAX];
211} ____cacheline_aligned;
212
213struct se_cmd; 208struct se_cmd;
214 209
215struct t10_alua { 210struct t10_alua {
@@ -235,7 +230,7 @@ struct t10_alua_lu_gp {
235 atomic_t lu_gp_ref_cnt; 230 atomic_t lu_gp_ref_cnt;
236 spinlock_t lu_gp_lock; 231 spinlock_t lu_gp_lock;
237 struct config_group lu_gp_group; 232 struct config_group lu_gp_group;
238 struct list_head lu_gp_list; 233 struct list_head lu_gp_node;
239 struct list_head lu_gp_mem_list; 234 struct list_head lu_gp_mem_list;
240} ____cacheline_aligned; 235} ____cacheline_aligned;
241 236
@@ -291,10 +286,10 @@ struct t10_vpd {
291} ____cacheline_aligned; 286} ____cacheline_aligned;
292 287
293struct t10_wwn { 288struct t10_wwn {
294 unsigned char vendor[8]; 289 char vendor[8];
295 unsigned char model[16]; 290 char model[16];
296 unsigned char revision[4]; 291 char revision[4];
297 unsigned char unit_serial[INQUIRY_VPD_SERIAL_LEN]; 292 char unit_serial[INQUIRY_VPD_SERIAL_LEN];
298 spinlock_t t10_vpd_lock; 293 spinlock_t t10_vpd_lock;
299 struct se_subsystem_dev *t10_sub_dev; 294 struct se_subsystem_dev *t10_sub_dev;
300 struct config_group t10_wwn_group; 295 struct config_group t10_wwn_group;
@@ -366,13 +361,13 @@ struct t10_reservation_ops {
366 int (*t10_pr_clear)(struct se_cmd *); 361 int (*t10_pr_clear)(struct se_cmd *);
367}; 362};
368 363
369struct t10_reservation_template { 364struct t10_reservation {
370 /* Reservation effects all target ports */ 365 /* Reservation effects all target ports */
371 int pr_all_tg_pt; 366 int pr_all_tg_pt;
372 /* Activate Persistence across Target Power Loss enabled 367 /* Activate Persistence across Target Power Loss enabled
373 * for SCSI device */ 368 * for SCSI device */
374 int pr_aptpl_active; 369 int pr_aptpl_active;
375 /* Used by struct t10_reservation_template->pr_aptpl_buf_len */ 370 /* Used by struct t10_reservation->pr_aptpl_buf_len */
376#define PR_APTPL_BUF_LEN 8192 371#define PR_APTPL_BUF_LEN 8192
377 u32 pr_aptpl_buf_len; 372 u32 pr_aptpl_buf_len;
378 u32 pr_generation; 373 u32 pr_generation;
@@ -397,7 +392,7 @@ struct t10_reservation_template {
397 392
398struct se_queue_req { 393struct se_queue_req {
399 int state; 394 int state;
400 void *cmd; 395 struct se_cmd *cmd;
401 struct list_head qr_list; 396 struct list_head qr_list;
402} ____cacheline_aligned; 397} ____cacheline_aligned;
403 398
@@ -495,9 +490,6 @@ struct se_task {
495 struct list_head t_state_list; 490 struct list_head t_state_list;
496} ____cacheline_aligned; 491} ____cacheline_aligned;
497 492
498#define TASK_CMD(task) ((task)->task_se_cmd)
499#define TASK_DEV(task) ((task)->se_dev)
500
501struct se_cmd { 493struct se_cmd {
502 /* SAM response code being sent to initiator */ 494 /* SAM response code being sent to initiator */
503 u8 scsi_status; 495 u8 scsi_status;
@@ -552,9 +544,6 @@ struct se_cmd {
552 void (*transport_complete_callback)(struct se_cmd *); 544 void (*transport_complete_callback)(struct se_cmd *);
553} ____cacheline_aligned; 545} ____cacheline_aligned;
554 546
555#define T_TASK(cmd) ((cmd)->t_task)
556#define CMD_TFO(cmd) ((cmd)->se_tfo)
557
558struct se_tmr_req { 547struct se_tmr_req {
559 /* Task Management function to be preformed */ 548 /* Task Management function to be preformed */
560 u8 function; 549 u8 function;
@@ -617,9 +606,6 @@ struct se_session {
617 struct list_head sess_acl_list; 606 struct list_head sess_acl_list;
618} ____cacheline_aligned; 607} ____cacheline_aligned;
619 608
620#define SE_SESS(cmd) ((cmd)->se_sess)
621#define SE_NODE_ACL(sess) ((sess)->se_node_acl)
622
623struct se_device; 609struct se_device;
624struct se_transform_info; 610struct se_transform_info;
625struct scatterlist; 611struct scatterlist;
@@ -640,8 +626,6 @@ struct se_lun_acl {
640 struct se_ml_stat_grps ml_stat_grps; 626 struct se_ml_stat_grps ml_stat_grps;
641} ____cacheline_aligned; 627} ____cacheline_aligned;
642 628
643#define ML_STAT_GRPS(lacl) (&(lacl)->ml_stat_grps)
644
645struct se_dev_entry { 629struct se_dev_entry {
646 bool def_pr_registered; 630 bool def_pr_registered;
647 /* See transport_lunflags_table */ 631 /* See transport_lunflags_table */
@@ -727,10 +711,10 @@ struct se_subsystem_dev {
727 /* T10 Inquiry and VPD WWN Information */ 711 /* T10 Inquiry and VPD WWN Information */
728 struct t10_wwn t10_wwn; 712 struct t10_wwn t10_wwn;
729 /* T10 SPC-2 + SPC-3 Reservations */ 713 /* T10 SPC-2 + SPC-3 Reservations */
730 struct t10_reservation_template t10_reservation; 714 struct t10_reservation t10_pr;
731 spinlock_t se_dev_lock; 715 spinlock_t se_dev_lock;
732 void *se_dev_su_ptr; 716 void *se_dev_su_ptr;
733 struct list_head g_se_dev_list; 717 struct list_head se_dev_node;
734 struct config_group se_dev_group; 718 struct config_group se_dev_group;
735 /* For T10 Reservations */ 719 /* For T10 Reservations */
736 struct config_group se_dev_pr_group; 720 struct config_group se_dev_pr_group;
@@ -738,11 +722,6 @@ struct se_subsystem_dev {
738 struct se_dev_stat_grps dev_stat_grps; 722 struct se_dev_stat_grps dev_stat_grps;
739} ____cacheline_aligned; 723} ____cacheline_aligned;
740 724
741#define T10_ALUA(su_dev) (&(su_dev)->t10_alua)
742#define T10_RES(su_dev) (&(su_dev)->t10_reservation)
743#define T10_PR_OPS(su_dev) (&(su_dev)->t10_reservation.pr_ops)
744#define DEV_STAT_GRP(dev) (&(dev)->dev_stat_grps)
745
746struct se_device { 725struct se_device {
747 /* Set to 1 if thread is NOT sleeping on thread_sem */ 726 /* Set to 1 if thread is NOT sleeping on thread_sem */
748 u8 thread_active; 727 u8 thread_active;
@@ -783,8 +762,7 @@ struct se_device {
783 struct se_obj dev_obj; 762 struct se_obj dev_obj;
784 struct se_obj dev_access_obj; 763 struct se_obj dev_access_obj;
785 struct se_obj dev_export_obj; 764 struct se_obj dev_export_obj;
786 struct se_queue_obj *dev_queue_obj; 765 struct se_queue_obj dev_queue_obj;
787 struct se_queue_obj *dev_status_queue_obj;
788 spinlock_t delayed_cmd_lock; 766 spinlock_t delayed_cmd_lock;
789 spinlock_t ordered_cmd_lock; 767 spinlock_t ordered_cmd_lock;
790 spinlock_t execute_task_lock; 768 spinlock_t execute_task_lock;
@@ -824,11 +802,6 @@ struct se_device {
824 struct list_head g_se_dev_list; 802 struct list_head g_se_dev_list;
825} ____cacheline_aligned; 803} ____cacheline_aligned;
826 804
827#define SE_DEV(cmd) ((cmd)->se_lun->lun_se_dev)
828#define SU_DEV(dev) ((dev)->se_sub_dev)
829#define DEV_ATTRIB(dev) (&(dev)->se_sub_dev->se_dev_attrib)
830#define DEV_T10_WWN(dev) (&(dev)->se_sub_dev->t10_wwn)
831
832struct se_hba { 805struct se_hba {
833 u16 hba_tpgt; 806 u16 hba_tpgt;
834 u32 hba_id; 807 u32 hba_id;
@@ -837,24 +810,17 @@ struct se_hba {
837 /* Virtual iSCSI devices attached. */ 810 /* Virtual iSCSI devices attached. */
838 u32 dev_count; 811 u32 dev_count;
839 u32 hba_index; 812 u32 hba_index;
840 atomic_t load_balance_queue;
841 atomic_t left_queue_depth;
842 /* Maximum queue depth the HBA can handle. */
843 atomic_t max_queue_depth;
844 /* Pointer to transport specific host structure. */ 813 /* Pointer to transport specific host structure. */
845 void *hba_ptr; 814 void *hba_ptr;
846 /* Linked list for struct se_device */ 815 /* Linked list for struct se_device */
847 struct list_head hba_dev_list; 816 struct list_head hba_dev_list;
848 struct list_head hba_list; 817 struct list_head hba_node;
849 spinlock_t device_lock; 818 spinlock_t device_lock;
850 spinlock_t hba_queue_lock;
851 struct config_group hba_group; 819 struct config_group hba_group;
852 struct mutex hba_access_mutex; 820 struct mutex hba_access_mutex;
853 struct se_subsystem_api *transport; 821 struct se_subsystem_api *transport;
854} ____cacheline_aligned; 822} ____cacheline_aligned;
855 823
856#define SE_HBA(dev) ((dev)->se_hba)
857
858struct se_port_stat_grps { 824struct se_port_stat_grps {
859 struct config_group stat_group; 825 struct config_group stat_group;
860 struct config_group scsi_port_group; 826 struct config_group scsi_port_group;
@@ -881,9 +847,6 @@ struct se_lun {
881 struct se_port_stat_grps port_stat_grps; 847 struct se_port_stat_grps port_stat_grps;
882} ____cacheline_aligned; 848} ____cacheline_aligned;
883 849
884#define SE_LUN(cmd) ((cmd)->se_lun)
885#define PORT_STAT_GRP(lun) (&(lun)->port_stat_grps)
886
887struct scsi_port_stats { 850struct scsi_port_stats {
888 u64 cmd_pdus; 851 u64 cmd_pdus;
889 u64 tx_data_octets; 852 u64 tx_data_octets;
@@ -930,7 +893,7 @@ struct se_portal_group {
930 spinlock_t tpg_lun_lock; 893 spinlock_t tpg_lun_lock;
931 /* Pointer to $FABRIC_MOD portal group */ 894 /* Pointer to $FABRIC_MOD portal group */
932 void *se_tpg_fabric_ptr; 895 void *se_tpg_fabric_ptr;
933 struct list_head se_tpg_list; 896 struct list_head se_tpg_node;
934 /* linked list for initiator ACL list */ 897 /* linked list for initiator ACL list */
935 struct list_head acl_node_list; 898 struct list_head acl_node_list;
936 struct se_lun *tpg_lun_list; 899 struct se_lun *tpg_lun_list;
@@ -949,8 +912,6 @@ struct se_portal_group {
949 struct config_group tpg_param_group; 912 struct config_group tpg_param_group;
950} ____cacheline_aligned; 913} ____cacheline_aligned;
951 914
952#define TPG_TFO(se_tpg) ((se_tpg)->se_tpg_tfo)
953
954struct se_wwn { 915struct se_wwn {
955 struct target_fabric_configfs *wwn_tf; 916 struct target_fabric_configfs *wwn_tf;
956 struct config_group wwn_group; 917 struct config_group wwn_group;
@@ -958,28 +919,4 @@ struct se_wwn {
958 struct config_group fabric_stat_group; 919 struct config_group fabric_stat_group;
959} ____cacheline_aligned; 920} ____cacheline_aligned;
960 921
961struct se_global {
962 u16 alua_lu_gps_counter;
963 int g_sub_api_initialized;
964 u32 in_shutdown;
965 u32 alua_lu_gps_count;
966 u32 g_hba_id_counter;
967 struct config_group target_core_hbagroup;
968 struct config_group alua_group;
969 struct config_group alua_lu_gps_group;
970 struct list_head g_lu_gps_list;
971 struct list_head g_se_tpg_list;
972 struct list_head g_hba_list;
973 struct list_head g_se_dev_list;
974 struct se_hba *g_lun0_hba;
975 struct se_subsystem_dev *g_lun0_su_dev;
976 struct se_device *g_lun0_dev;
977 struct t10_alua_lu_gp *default_lu_gp;
978 spinlock_t g_device_lock;
979 spinlock_t hba_lock;
980 spinlock_t se_tpg_lock;
981 spinlock_t lu_gps_lock;
982 spinlock_t plugin_class_lock;
983} ____cacheline_aligned;
984
985#endif /* TARGET_CORE_BASE_H */ 922#endif /* TARGET_CORE_BASE_H */
diff --git a/include/target/target_core_transport.h b/include/target/target_core_transport.h
index 24a1c6cb83c3..1dd4d1841497 100644
--- a/include/target/target_core_transport.h
+++ b/include/target/target_core_transport.h
@@ -111,9 +111,8 @@ struct se_subsystem_api;
111 111
112extern struct kmem_cache *se_mem_cache; 112extern struct kmem_cache *se_mem_cache;
113 113
114extern int init_se_global(void); 114extern int init_se_kmem_caches(void);
115extern void release_se_global(void); 115extern void release_se_kmem_caches(void);
116extern void init_scsi_index_table(void);
117extern u32 scsi_get_new_index(scsi_index_t); 116extern u32 scsi_get_new_index(scsi_index_t);
118extern void transport_init_queue_obj(struct se_queue_obj *); 117extern void transport_init_queue_obj(struct se_queue_obj *);
119extern int transport_subsystem_check_init(void); 118extern int transport_subsystem_check_init(void);
@@ -184,7 +183,7 @@ extern void transport_send_task_abort(struct se_cmd *);
184extern void transport_release_cmd_to_pool(struct se_cmd *); 183extern void transport_release_cmd_to_pool(struct se_cmd *);
185extern void transport_generic_free_cmd(struct se_cmd *, int, int, int); 184extern void transport_generic_free_cmd(struct se_cmd *, int, int, int);
186extern void transport_generic_wait_for_cmds(struct se_cmd *, int); 185extern void transport_generic_wait_for_cmds(struct se_cmd *, int);
187extern u32 transport_calc_sg_num(struct se_task *, struct se_mem *, u32); 186extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32);
188extern int transport_map_mem_to_sg(struct se_task *, struct list_head *, 187extern int transport_map_mem_to_sg(struct se_task *, struct list_head *,
189 void *, struct se_mem *, 188 void *, struct se_mem *,
190 struct se_mem **, u32 *, u32 *); 189 struct se_mem **, u32 *, u32 *);
@@ -352,9 +351,4 @@ struct se_subsystem_api {
352 unsigned char *(*get_sense_buffer)(struct se_task *); 351 unsigned char *(*get_sense_buffer)(struct se_task *);
353} ____cacheline_aligned; 352} ____cacheline_aligned;
354 353
355#define TRANSPORT(dev) ((dev)->transport)
356#define HBA_TRANSPORT(hba) ((hba)->transport)
357
358extern struct se_global *se_global;
359
360#endif /* TARGET_CORE_TRANSPORT_H */ 354#endif /* TARGET_CORE_TRANSPORT_H */