From e3d6f909ed803d92a5ac9b4a2c087e0eae9b90d0 Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Tue, 19 Jul 2011 08:55:10 +0000 Subject: 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 Signed-off-by: Nicholas Bellinger --- include/target/target_core_base.h | 89 +++++----------------------------- include/target/target_core_transport.h | 12 ++--- 2 files changed, 16 insertions(+), 85 deletions(-) (limited to 'include/target') 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 { SCSI_INDEX_TYPE_MAX } scsi_index_t; -struct scsi_index_table { - spinlock_t lock; - u32 scsi_mib_index[SCSI_INDEX_TYPE_MAX]; -} ____cacheline_aligned; - struct se_cmd; struct t10_alua { @@ -235,7 +230,7 @@ struct t10_alua_lu_gp { atomic_t lu_gp_ref_cnt; spinlock_t lu_gp_lock; struct config_group lu_gp_group; - struct list_head lu_gp_list; + struct list_head lu_gp_node; struct list_head lu_gp_mem_list; } ____cacheline_aligned; @@ -291,10 +286,10 @@ struct t10_vpd { } ____cacheline_aligned; struct t10_wwn { - unsigned char vendor[8]; - unsigned char model[16]; - unsigned char revision[4]; - unsigned char unit_serial[INQUIRY_VPD_SERIAL_LEN]; + char vendor[8]; + char model[16]; + char revision[4]; + char unit_serial[INQUIRY_VPD_SERIAL_LEN]; spinlock_t t10_vpd_lock; struct se_subsystem_dev *t10_sub_dev; struct config_group t10_wwn_group; @@ -366,13 +361,13 @@ struct t10_reservation_ops { int (*t10_pr_clear)(struct se_cmd *); }; -struct t10_reservation_template { +struct t10_reservation { /* Reservation effects all target ports */ int pr_all_tg_pt; /* Activate Persistence across Target Power Loss enabled * for SCSI device */ int pr_aptpl_active; - /* Used by struct t10_reservation_template->pr_aptpl_buf_len */ + /* Used by struct t10_reservation->pr_aptpl_buf_len */ #define PR_APTPL_BUF_LEN 8192 u32 pr_aptpl_buf_len; u32 pr_generation; @@ -397,7 +392,7 @@ struct t10_reservation_template { struct se_queue_req { int state; - void *cmd; + struct se_cmd *cmd; struct list_head qr_list; } ____cacheline_aligned; @@ -495,9 +490,6 @@ struct se_task { struct list_head t_state_list; } ____cacheline_aligned; -#define TASK_CMD(task) ((task)->task_se_cmd) -#define TASK_DEV(task) ((task)->se_dev) - struct se_cmd { /* SAM response code being sent to initiator */ u8 scsi_status; @@ -552,9 +544,6 @@ struct se_cmd { void (*transport_complete_callback)(struct se_cmd *); } ____cacheline_aligned; -#define T_TASK(cmd) ((cmd)->t_task) -#define CMD_TFO(cmd) ((cmd)->se_tfo) - struct se_tmr_req { /* Task Management function to be preformed */ u8 function; @@ -617,9 +606,6 @@ struct se_session { struct list_head sess_acl_list; } ____cacheline_aligned; -#define SE_SESS(cmd) ((cmd)->se_sess) -#define SE_NODE_ACL(sess) ((sess)->se_node_acl) - struct se_device; struct se_transform_info; struct scatterlist; @@ -640,8 +626,6 @@ struct se_lun_acl { struct se_ml_stat_grps ml_stat_grps; } ____cacheline_aligned; -#define ML_STAT_GRPS(lacl) (&(lacl)->ml_stat_grps) - struct se_dev_entry { bool def_pr_registered; /* See transport_lunflags_table */ @@ -727,10 +711,10 @@ struct se_subsystem_dev { /* T10 Inquiry and VPD WWN Information */ struct t10_wwn t10_wwn; /* T10 SPC-2 + SPC-3 Reservations */ - struct t10_reservation_template t10_reservation; + struct t10_reservation t10_pr; spinlock_t se_dev_lock; void *se_dev_su_ptr; - struct list_head g_se_dev_list; + struct list_head se_dev_node; struct config_group se_dev_group; /* For T10 Reservations */ struct config_group se_dev_pr_group; @@ -738,11 +722,6 @@ struct se_subsystem_dev { struct se_dev_stat_grps dev_stat_grps; } ____cacheline_aligned; -#define T10_ALUA(su_dev) (&(su_dev)->t10_alua) -#define T10_RES(su_dev) (&(su_dev)->t10_reservation) -#define T10_PR_OPS(su_dev) (&(su_dev)->t10_reservation.pr_ops) -#define DEV_STAT_GRP(dev) (&(dev)->dev_stat_grps) - struct se_device { /* Set to 1 if thread is NOT sleeping on thread_sem */ u8 thread_active; @@ -783,8 +762,7 @@ struct se_device { struct se_obj dev_obj; struct se_obj dev_access_obj; struct se_obj dev_export_obj; - struct se_queue_obj *dev_queue_obj; - struct se_queue_obj *dev_status_queue_obj; + struct se_queue_obj dev_queue_obj; spinlock_t delayed_cmd_lock; spinlock_t ordered_cmd_lock; spinlock_t execute_task_lock; @@ -824,11 +802,6 @@ struct se_device { struct list_head g_se_dev_list; } ____cacheline_aligned; -#define SE_DEV(cmd) ((cmd)->se_lun->lun_se_dev) -#define SU_DEV(dev) ((dev)->se_sub_dev) -#define DEV_ATTRIB(dev) (&(dev)->se_sub_dev->se_dev_attrib) -#define DEV_T10_WWN(dev) (&(dev)->se_sub_dev->t10_wwn) - struct se_hba { u16 hba_tpgt; u32 hba_id; @@ -837,24 +810,17 @@ struct se_hba { /* Virtual iSCSI devices attached. */ u32 dev_count; u32 hba_index; - atomic_t load_balance_queue; - atomic_t left_queue_depth; - /* Maximum queue depth the HBA can handle. */ - atomic_t max_queue_depth; /* Pointer to transport specific host structure. */ void *hba_ptr; /* Linked list for struct se_device */ struct list_head hba_dev_list; - struct list_head hba_list; + struct list_head hba_node; spinlock_t device_lock; - spinlock_t hba_queue_lock; struct config_group hba_group; struct mutex hba_access_mutex; struct se_subsystem_api *transport; } ____cacheline_aligned; -#define SE_HBA(dev) ((dev)->se_hba) - struct se_port_stat_grps { struct config_group stat_group; struct config_group scsi_port_group; @@ -881,9 +847,6 @@ struct se_lun { struct se_port_stat_grps port_stat_grps; } ____cacheline_aligned; -#define SE_LUN(cmd) ((cmd)->se_lun) -#define PORT_STAT_GRP(lun) (&(lun)->port_stat_grps) - struct scsi_port_stats { u64 cmd_pdus; u64 tx_data_octets; @@ -930,7 +893,7 @@ struct se_portal_group { spinlock_t tpg_lun_lock; /* Pointer to $FABRIC_MOD portal group */ void *se_tpg_fabric_ptr; - struct list_head se_tpg_list; + struct list_head se_tpg_node; /* linked list for initiator ACL list */ struct list_head acl_node_list; struct se_lun *tpg_lun_list; @@ -949,8 +912,6 @@ struct se_portal_group { struct config_group tpg_param_group; } ____cacheline_aligned; -#define TPG_TFO(se_tpg) ((se_tpg)->se_tpg_tfo) - struct se_wwn { struct target_fabric_configfs *wwn_tf; struct config_group wwn_group; @@ -958,28 +919,4 @@ struct se_wwn { struct config_group fabric_stat_group; } ____cacheline_aligned; -struct se_global { - u16 alua_lu_gps_counter; - int g_sub_api_initialized; - u32 in_shutdown; - u32 alua_lu_gps_count; - u32 g_hba_id_counter; - struct config_group target_core_hbagroup; - struct config_group alua_group; - struct config_group alua_lu_gps_group; - struct list_head g_lu_gps_list; - struct list_head g_se_tpg_list; - struct list_head g_hba_list; - struct list_head g_se_dev_list; - struct se_hba *g_lun0_hba; - struct se_subsystem_dev *g_lun0_su_dev; - struct se_device *g_lun0_dev; - struct t10_alua_lu_gp *default_lu_gp; - spinlock_t g_device_lock; - spinlock_t hba_lock; - spinlock_t se_tpg_lock; - spinlock_t lu_gps_lock; - spinlock_t plugin_class_lock; -} ____cacheline_aligned; - #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; extern struct kmem_cache *se_mem_cache; -extern int init_se_global(void); -extern void release_se_global(void); -extern void init_scsi_index_table(void); +extern int init_se_kmem_caches(void); +extern void release_se_kmem_caches(void); extern u32 scsi_get_new_index(scsi_index_t); extern void transport_init_queue_obj(struct se_queue_obj *); extern int transport_subsystem_check_init(void); @@ -184,7 +183,7 @@ extern void transport_send_task_abort(struct se_cmd *); extern void transport_release_cmd_to_pool(struct se_cmd *); extern void transport_generic_free_cmd(struct se_cmd *, int, int, int); extern void transport_generic_wait_for_cmds(struct se_cmd *, int); -extern u32 transport_calc_sg_num(struct se_task *, struct se_mem *, u32); +extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32); extern int transport_map_mem_to_sg(struct se_task *, struct list_head *, void *, struct se_mem *, struct se_mem **, u32 *, u32 *); @@ -352,9 +351,4 @@ struct se_subsystem_api { unsigned char *(*get_sense_buffer)(struct se_task *); } ____cacheline_aligned; -#define TRANSPORT(dev) ((dev)->transport) -#define HBA_TRANSPORT(hba) ((hba)->transport) - -extern struct se_global *se_global; - #endif /* TARGET_CORE_TRANSPORT_H */ -- cgit v1.2.3-59-g8ed1b