diff --git a/scst/include/scst.h b/scst/include/scst.h index 56b4524ca..d67698ab1 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -403,7 +403,11 @@ struct scst_acg; struct scst_acg_dev; struct scst_acn; -typedef uint64_t lun_t; +/* + * SCST uses 64-bit numbers to represent LUN's internally. The value + * NO_SUCH_LUN is guaranteed to be different of every valid LUN. + */ +#define NO_SUCH_LUN ((uint64_t)-1) typedef enum dma_data_direction scst_data_direction; @@ -1122,7 +1126,7 @@ struct scst_cmd { struct scst_tgt_dev *tgt_dev; /* corresponding device for this cmd */ - lun_t lun; /* LUN for this cmd */ + uint64_t lun; /* LUN for this cmd */ unsigned long start_time; @@ -1282,7 +1286,7 @@ struct scst_mgmt_cmd { /* Number of completed commands, protected by scst_mcmd_lock */ int completed_cmd_count; - lun_t lun; /* LUN for this mgmt cmd */ + uint64_t lun; /* LUN for this mgmt cmd */ /* or (and for iSCSI) */ uint64_t tag; /* tag of the corresponding cmd */ @@ -1446,7 +1450,7 @@ struct scst_tgt_dev { struct list_head sess_tgt_dev_list_entry; struct scst_device *dev; /* to save extra dereferences */ - lun_t lun; /* to save extra dereferences */ + uint64_t lun; /* to save extra dereferences */ /* How many cmds alive on this dev in this session */ atomic_t tgt_dev_cmd_count; @@ -1510,7 +1514,7 @@ struct scst_tgt_dev { */ struct scst_acg_dev { struct scst_device *dev; /* corresponding device */ - lun_t lun; /* device's LUN in this acg */ + uint64_t lun; /* device's LUN in this acg */ unsigned int rd_only_flag:1; /* if != 0, then read only */ struct scst_acg *acg; /* parent acg */ diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index a1da67ac9..7701951f0 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -192,7 +192,7 @@ int scst_get_cmd_abnormal_done_state(const struct scst_cmd *cmd) TRACE_ENTRY(); - switch(cmd->state) { + switch (cmd->state) { case SCST_CMD_STATE_INIT_WAIT: case SCST_CMD_STATE_INIT: case SCST_CMD_STATE_PRE_PARSE: @@ -215,7 +215,7 @@ void scst_set_cmd_abnormal_done_state(struct scst_cmd *cmd) TRACE_ENTRY(); #ifdef EXTRACHECKS - switch(cmd->state) { + switch (cmd->state) { case SCST_CMD_STATE_PRE_XMIT_RESP: case SCST_CMD_STATE_XMIT_RESP: case SCST_CMD_STATE_FINISHED: @@ -347,7 +347,7 @@ void scst_init_mem_lim(struct scst_mem_lim *mem_lim) EXPORT_SYMBOL(scst_init_mem_lim); struct scst_acg_dev *scst_alloc_acg_dev(struct scst_acg *acg, - struct scst_device *dev, lun_t lun) + struct scst_device *dev, uint64_t lun) { struct scst_acg_dev *res; @@ -746,8 +746,8 @@ void scst_sess_free_tgt_devs(struct scst_session *sess) } /* The activity supposed to be suspended and scst_mutex held */ -int scst_acg_add_dev(struct scst_acg *acg, struct scst_device *dev, lun_t lun, - int read_only) +int scst_acg_add_dev(struct scst_acg *acg, struct scst_device *dev, + uint64_t lun, int read_only) { int res = 0; struct scst_acg_dev *acg_dev; @@ -1922,9 +1922,9 @@ EXPORT_SYMBOL(scst_get_cdb_info); * (see SAM-2, Section 4.12.3 page 40) * Supports 2 types of lun unpacking: peripheral and logical unit. */ -lun_t scst_unpack_lun(const uint8_t *lun, int len) +uint64_t scst_unpack_lun(const uint8_t *lun, int len) { - lun_t res = (lun_t)-1; + uint64_t res = NO_SUCH_LUN; int address_method; TRACE_ENTRY(); diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index b6efbbe33..310fcf98b 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -286,8 +286,8 @@ int scst_sess_alloc_tgt_devs(struct scst_session *sess); void scst_sess_free_tgt_devs(struct scst_session *sess); void scst_nexus_loss(struct scst_tgt_dev *tgt_dev); -int scst_acg_add_dev(struct scst_acg *acg, struct scst_device *dev, lun_t lun, - int read_only); +int scst_acg_add_dev(struct scst_acg *acg, struct scst_device *dev, + uint64_t lun, int read_only); int scst_acg_remove_dev(struct scst_acg *acg, struct scst_device *dev); int scst_acg_add_name(struct scst_acg *acg, const char *name); @@ -359,7 +359,7 @@ int scst_alloc_space(struct scst_cmd *cmd); void scst_release_space(struct scst_cmd *cmd); void scst_scsi_op_list_init(void); -lun_t scst_unpack_lun(const uint8_t *lun, int len); +uint64_t scst_unpack_lun(const uint8_t *lun, int len); struct scst_cmd *__scst_find_cmd_by_tag(struct scst_session *sess, uint64_t tag); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 3818851f1..fb9346d00 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -249,7 +249,7 @@ void scst_cmd_init_done(struct scst_cmd *cmd, int pref_context) spin_unlock_irqrestore(&sess->sess_list_lock, flags); - if (unlikely(cmd->lun == (lun_t)-1)) { + if (unlikely(cmd->lun == NO_SUCH_LUN)) { PRINT_ERROR("Wrong LUN %d, finishing cmd", -1); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_lun_not_supported)); @@ -4821,7 +4821,7 @@ int scst_rx_mgmt_fn(struct scst_session *sess, if (params->lun_set) { mcmd->lun = scst_unpack_lun(params->lun, params->lun_len); - if (mcmd->lun == (lun_t)-1) + if (mcmd->lun == NO_SUCH_LUN) goto out_free; mcmd->lun_set = 1; }