Commit 5dd7ed2e authored by Dan Carpenter's avatar Dan Carpenter Committed by James Bottomley

[SCSI] target: Minor sparse warning fixes and annotations

This patch addresses the majority of sparse warnings and adds
proper locking annotations.  It also fixes the dubious one-bit signed
bitfield, for which the signed one-bit types can be 0 or -1 which can
cause a problem if someone ever checks if (foo->lu_gp_assoc == 1).
The current code is fine because everyone just checks zero vs non-zero.
But Sparse complains about it so lets change it.  The warnings look like
this:

include/target/target_core_base.h:228:26: error: dubious one-bit signed bitfield
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarFubo Chen <fubo.chen@gmail.com>
Signed-off-by: default avatarNicholas A. Bellinger <nab@linux-iscsi.org>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 05aea6e7
...@@ -589,6 +589,7 @@ static void core_export_port( ...@@ -589,6 +589,7 @@ static void core_export_port(
* Called with struct se_device->se_port_lock spinlock held. * Called with struct se_device->se_port_lock spinlock held.
*/ */
static void core_release_port(struct se_device *dev, struct se_port *port) static void core_release_port(struct se_device *dev, struct se_port *port)
__releases(&dev->se_port_lock) __acquires(&dev->se_port_lock)
{ {
/* /*
* Wait for any port reference for PR ALL_TG_PT=1 operation * Wait for any port reference for PR ALL_TG_PT=1 operation
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <target/target_core_base.h> #include <target/target_core_base.h>
#include <target/target_core_device.h> #include <target/target_core_device.h>
#include <target/target_core_transport.h> #include <target/target_core_transport.h>
#include <target/target_core_fabric_lib.h>
#include <target/target_core_fabric_ops.h> #include <target/target_core_fabric_ops.h>
#include <target/target_core_configfs.h> #include <target/target_core_configfs.h>
......
...@@ -441,6 +441,7 @@ static struct se_device *pscsi_create_type_disk( ...@@ -441,6 +441,7 @@ static struct se_device *pscsi_create_type_disk(
struct pscsi_dev_virt *pdv, struct pscsi_dev_virt *pdv,
struct se_subsystem_dev *se_dev, struct se_subsystem_dev *se_dev,
struct se_hba *hba) struct se_hba *hba)
__releases(sh->host_lock)
{ {
struct se_device *dev; struct se_device *dev;
struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr; struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr;
...@@ -488,6 +489,7 @@ static struct se_device *pscsi_create_type_rom( ...@@ -488,6 +489,7 @@ static struct se_device *pscsi_create_type_rom(
struct pscsi_dev_virt *pdv, struct pscsi_dev_virt *pdv,
struct se_subsystem_dev *se_dev, struct se_subsystem_dev *se_dev,
struct se_hba *hba) struct se_hba *hba)
__releases(sh->host_lock)
{ {
struct se_device *dev; struct se_device *dev;
struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr; struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr;
...@@ -522,6 +524,7 @@ static struct se_device *pscsi_create_type_other( ...@@ -522,6 +524,7 @@ static struct se_device *pscsi_create_type_other(
struct pscsi_dev_virt *pdv, struct pscsi_dev_virt *pdv,
struct se_subsystem_dev *se_dev, struct se_subsystem_dev *se_dev,
struct se_hba *hba) struct se_hba *hba)
__releases(sh->host_lock)
{ {
struct se_device *dev; struct se_device *dev;
struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr; struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr;
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#define RD_BLOCKSIZE 512 #define RD_BLOCKSIZE 512
#define RD_MAX_SECTORS 1024 #define RD_MAX_SECTORS 1024
extern struct kmem_cache *se_mem_cache;
/* Used in target_core_init_configfs() for virtual LUN 0 access */ /* Used in target_core_init_configfs() for virtual LUN 0 access */
int __init rd_module_init(void); int __init rd_module_init(void);
void rd_module_exit(void); void rd_module_exit(void);
......
...@@ -227,8 +227,6 @@ static void transport_remove_cmd_from_queue(struct se_cmd *cmd, ...@@ -227,8 +227,6 @@ static void transport_remove_cmd_from_queue(struct se_cmd *cmd,
static int transport_set_sense_codes(struct se_cmd *cmd, u8 asc, u8 ascq); static int transport_set_sense_codes(struct se_cmd *cmd, u8 asc, u8 ascq);
static void transport_stop_all_task_timers(struct se_cmd *cmd); static void transport_stop_all_task_timers(struct se_cmd *cmd);
int transport_emulate_control_cdb(struct se_task *task);
int init_se_global(void) int init_se_global(void)
{ {
struct se_global *global; struct se_global *global;
...@@ -4395,7 +4393,7 @@ transport_generic_get_mem(struct se_cmd *cmd, u32 length, u32 dma_size) ...@@ -4395,7 +4393,7 @@ transport_generic_get_mem(struct se_cmd *cmd, u32 length, u32 dma_size)
return -1; return -1;
} }
extern u32 transport_calc_sg_num( u32 transport_calc_sg_num(
struct se_task *task, struct se_task *task,
struct se_mem *in_se_mem, struct se_mem *in_se_mem,
u32 task_offset) u32 task_offset)
......
...@@ -239,7 +239,7 @@ struct t10_alua_lu_gp { ...@@ -239,7 +239,7 @@ struct t10_alua_lu_gp {
} ____cacheline_aligned; } ____cacheline_aligned;
struct t10_alua_lu_gp_member { struct t10_alua_lu_gp_member {
int lu_gp_assoc:1; bool lu_gp_assoc;
atomic_t lu_gp_mem_ref_cnt; atomic_t lu_gp_mem_ref_cnt;
spinlock_t lu_gp_mem_lock; spinlock_t lu_gp_mem_lock;
struct t10_alua_lu_gp *lu_gp; struct t10_alua_lu_gp *lu_gp;
...@@ -271,7 +271,7 @@ struct t10_alua_tg_pt_gp { ...@@ -271,7 +271,7 @@ struct t10_alua_tg_pt_gp {
} ____cacheline_aligned; } ____cacheline_aligned;
struct t10_alua_tg_pt_gp_member { struct t10_alua_tg_pt_gp_member {
int tg_pt_gp_assoc:1; bool tg_pt_gp_assoc;
atomic_t tg_pt_gp_mem_ref_cnt; atomic_t tg_pt_gp_mem_ref_cnt;
spinlock_t tg_pt_gp_mem_lock; spinlock_t tg_pt_gp_mem_lock;
struct t10_alua_tg_pt_gp *tg_pt_gp; struct t10_alua_tg_pt_gp *tg_pt_gp;
...@@ -336,7 +336,7 @@ struct t10_pr_registration { ...@@ -336,7 +336,7 @@ struct t10_pr_registration {
int pr_res_type; int pr_res_type;
int pr_res_scope; int pr_res_scope;
/* Used for fabric initiator WWPNs using a ISID */ /* Used for fabric initiator WWPNs using a ISID */
int isid_present_at_reg:1; bool isid_present_at_reg;
u32 pr_res_mapped_lun; u32 pr_res_mapped_lun;
u32 pr_aptpl_target_lun; u32 pr_aptpl_target_lun;
u32 pr_res_generation; u32 pr_res_generation;
...@@ -418,7 +418,7 @@ struct se_transport_task { ...@@ -418,7 +418,7 @@ struct se_transport_task {
unsigned long long t_task_lba; unsigned long long t_task_lba;
int t_tasks_failed; int t_tasks_failed;
int t_tasks_fua; int t_tasks_fua;
int t_tasks_bidi:1; bool t_tasks_bidi;
u32 t_task_cdbs; u32 t_task_cdbs;
u32 t_tasks_check; u32 t_tasks_check;
u32 t_tasks_no; u32 t_tasks_no;
...@@ -470,7 +470,7 @@ struct se_task { ...@@ -470,7 +470,7 @@ struct se_task {
u8 task_flags; u8 task_flags;
int task_error_status; int task_error_status;
int task_state_flags; int task_state_flags;
int task_padded_sg:1; bool task_padded_sg;
unsigned long long task_lba; unsigned long long task_lba;
u32 task_no; u32 task_no;
u32 task_sectors; u32 task_sectors;
...@@ -583,7 +583,7 @@ struct se_ua { ...@@ -583,7 +583,7 @@ struct se_ua {
struct se_node_acl { struct se_node_acl {
char initiatorname[TRANSPORT_IQN_LEN]; char initiatorname[TRANSPORT_IQN_LEN];
/* Used to signal demo mode created ACL, disabled by default */ /* Used to signal demo mode created ACL, disabled by default */
int dynamic_node_acl:1; bool dynamic_node_acl;
u32 queue_depth; u32 queue_depth;
u32 acl_index; u32 acl_index;
u64 num_cmds; u64 num_cmds;
...@@ -632,7 +632,7 @@ struct se_lun_acl { ...@@ -632,7 +632,7 @@ struct se_lun_acl {
} ____cacheline_aligned; } ____cacheline_aligned;
struct se_dev_entry { struct se_dev_entry {
int def_pr_registered:1; bool def_pr_registered;
/* See transport_lunflags_table */ /* See transport_lunflags_table */
u32 lun_flags; u32 lun_flags;
u32 deve_cmds; u32 deve_cmds;
......
...@@ -8,7 +8,7 @@ struct target_core_fabric_ops { ...@@ -8,7 +8,7 @@ struct target_core_fabric_ops {
* for scatterlist chaining using transport_do_task_sg_link(), * for scatterlist chaining using transport_do_task_sg_link(),
* disabled by default * disabled by default
*/ */
int task_sg_chaining:1; bool task_sg_chaining;
char *(*get_fabric_name)(void); char *(*get_fabric_name)(void);
u8 (*get_fabric_proto_ident)(struct se_portal_group *); u8 (*get_fabric_proto_ident)(struct se_portal_group *);
char *(*tpg_get_wwn)(struct se_portal_group *); char *(*tpg_get_wwn)(struct se_portal_group *);
......
...@@ -109,6 +109,8 @@ ...@@ -109,6 +109,8 @@
struct se_mem; struct se_mem;
struct se_subsystem_api; struct se_subsystem_api;
extern struct kmem_cache *se_mem_cache;
extern int init_se_global(void); extern int init_se_global(void);
extern void release_se_global(void); extern void release_se_global(void);
extern void init_scsi_index_table(void); extern void init_scsi_index_table(void);
...@@ -190,6 +192,8 @@ extern void transport_generic_process_write(struct se_cmd *); ...@@ -190,6 +192,8 @@ extern void transport_generic_process_write(struct se_cmd *);
extern int transport_generic_do_tmr(struct se_cmd *); extern int transport_generic_do_tmr(struct se_cmd *);
/* From target_core_alua.c */ /* From target_core_alua.c */
extern int core_alua_check_nonop_delay(struct se_cmd *); extern int core_alua_check_nonop_delay(struct se_cmd *);
/* From target_core_cdb.c */
extern int transport_emulate_control_cdb(struct se_task *);
/* /*
* Each se_transport_task_t can have N number of possible struct se_task's * Each se_transport_task_t can have N number of possible struct se_task's
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment