From fc5236bf091981291c841fee5408d25fd8c042cd Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 21 Dec 2006 11:04:34 +0000 Subject: [PATCH] - Cleanup: masked_status deleted, use status instead - In FILEIO report in MODE SENSE if NV_CACHE enabled that no commands reordering is possible git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@69 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scsi_tgt.h | 15 ++++----------- scst/src/dev_handlers/scst_cdrom.c | 6 +++--- scst/src/dev_handlers/scst_changer.c | 2 +- scst/src/dev_handlers/scst_disk.c | 7 +++---- scst/src/dev_handlers/scst_fileio.c | 4 +--- scst/src/dev_handlers/scst_modisk.c | 7 +++---- scst/src/dev_handlers/scst_processor.c | 2 +- scst/src/dev_handlers/scst_raid.c | 2 +- scst/src/dev_handlers/scst_tape.c | 9 ++++----- scst/src/scst_lib.c | 1 - scst/src/scst_targ.c | 16 +++++----------- 11 files changed, 26 insertions(+), 45 deletions(-) diff --git a/scst/include/scsi_tgt.h b/scst/include/scsi_tgt.h index af3252221..d8072e331 100644 --- a/scst/include/scsi_tgt.h +++ b/scst/include/scsi_tgt.h @@ -1175,10 +1175,9 @@ struct scst_cmd int resp_data_len; uint8_t status; /* status byte from target device */ - uint8_t masked_status; /* set from host device by status_byte() */ uint8_t msg_status; /* return status from host adapter itself */ - uint16_t host_status; /* set by low-level driver to indicate status */ - uint16_t driver_status; /* set by mid-level */ + uint8_t host_status; /* set by low-level driver to indicate status */ + uint8_t driver_status; /* set by mid-level */ /* Used for storage of target driver private stuff */ void *tgt_priv; @@ -1872,12 +1871,6 @@ static inline uint8_t scst_cmd_get_status(struct scst_cmd *cmd) return cmd->status; } -/* Returns cmd's status byte set from host device by status_byte() */ -static inline uint8_t scst_cmd_get_masked_status(struct scst_cmd *cmd) -{ - return cmd->masked_status; -} - /* Returns cmd's status from host adapter itself */ static inline uint8_t scst_cmd_get_msg_status(struct scst_cmd *cmd) { @@ -1885,13 +1878,13 @@ static inline uint8_t scst_cmd_get_msg_status(struct scst_cmd *cmd) } /* Returns cmd's status set by low-level driver to indicate its status */ -static inline uint16_t scst_cmd_get_host_status(struct scst_cmd *cmd) +static inline uint8_t scst_cmd_get_host_status(struct scst_cmd *cmd) { return cmd->host_status; } /* Returns cmd's status set by SCSI mid-level */ -static inline uint16_t scst_cmd_get_driver_status(struct scst_cmd *cmd) +static inline uint8_t scst_cmd_get_driver_status(struct scst_cmd *cmd) { return cmd->driver_status; } diff --git a/scst/src/dev_handlers/scst_cdrom.c b/scst/src/dev_handlers/scst_cdrom.c index 235bc8eb9..531f9dbd4 100644 --- a/scst/src/dev_handlers/scst_cdrom.c +++ b/scst/src/dev_handlers/scst_cdrom.c @@ -288,7 +288,7 @@ int cdrom_parse(struct scst_cmd *cmd, const struct scst_info_cdb *info_cdb) int cdrom_done(struct scst_cmd *cmd) { int opcode = cmd->cdb[0]; - int masked_status = cmd->masked_status; + int status = cmd->status; struct cdrom_params *cdrom; int res = SCST_CMD_STATE_DEFAULT; @@ -299,11 +299,11 @@ int cdrom_done(struct scst_cmd *cmd) /* * SCST sets good defaults for cmd->tgt_resp_flags and cmd->resp_data_len - * based on cmd->masked_status and cmd->data_direction, therefore change + * based on cmd->status and cmd->data_direction, therefore change * them only if necessary */ - if ((masked_status == GOOD) || (masked_status == CONDITION_GOOD)) { + if ((status == SAM_STAT_GOOD) || (status == SAM_STAT_CONDITION_MET)) { switch (opcode) { case READ_CAPACITY: { diff --git a/scst/src/dev_handlers/scst_changer.c b/scst/src/dev_handlers/scst_changer.c index dfbece362..c2fbb7428 100644 --- a/scst/src/dev_handlers/scst_changer.c +++ b/scst/src/dev_handlers/scst_changer.c @@ -183,7 +183,7 @@ int changer_done(struct scst_cmd *cmd) /* * SCST sets good defaults for cmd->tgt_resp_flags and cmd->resp_data_len - * based on cmd->masked_status and cmd->data_direction, therefore change + * based on cmd->status and cmd->data_direction, therefore change * them only if necessary */ diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index 1b572ec34..0b5891af6 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -351,7 +351,7 @@ int disk_parse(struct scst_cmd *cmd, const struct scst_info_cdb *info_cdb) int disk_done(struct scst_cmd *cmd) { int opcode = cmd->cdb[0]; - int masked_status = cmd->masked_status; + int status = cmd->status; struct disk_params *disk; int res = SCST_CMD_STATE_DEFAULT; @@ -362,11 +362,11 @@ int disk_done(struct scst_cmd *cmd) /* * SCST sets good defaults for cmd->tgt_resp_flags and cmd->resp_data_len - * based on cmd->masked_status and cmd->data_direction, therefore change + * based on cmd->status and cmd->data_direction, therefore change * them only if necessary */ - if ((masked_status == GOOD) || (masked_status == CONDITION_GOOD)) { + if ((status == SAM_STAT_GOOD) || (status == SAM_STAT_CONDITION_MET)) { switch (opcode) { case READ_CAPACITY: { @@ -444,7 +444,6 @@ int disk_exec(struct scst_cmd *cmd) case READ_16: res = SCST_EXEC_COMPLETED; cmd->status = 0; - cmd->masked_status = 0; cmd->msg_status = 0; cmd->host_status = DID_OK; cmd->driver_status = 0; diff --git a/scst/src/dev_handlers/scst_fileio.c b/scst/src/dev_handlers/scst_fileio.c index 610ed90f7..6559a9238 100644 --- a/scst/src/dev_handlers/scst_fileio.c +++ b/scst/src/dev_handlers/scst_fileio.c @@ -893,7 +893,6 @@ static int disk_fileio_exec(struct scst_cmd *cmd) TRACE_ENTRY(); cmd->status = 0; - cmd->masked_status = 0; cmd->msg_status = 0; cmd->host_status = DID_OK; cmd->driver_status = 0; @@ -1056,7 +1055,6 @@ static int cdrom_fileio_exec(struct scst_cmd *cmd) TRACE_ENTRY(); cmd->status = 0; - cmd->masked_status = 0; cmd->msg_status = 0; cmd->host_status = DID_OK; cmd->driver_status = 0; @@ -1380,7 +1378,7 @@ static int fileio_ctrl_m_pg(unsigned char *p, int pcontrol, 0, 0, 0x2, 0x4b}; memcpy(p, ctrl_m_pg, sizeof(ctrl_m_pg)); - if (!virt_dev->wt_flag) + if (!virt_dev->wt_flag && !virt_dev->nv_cache) p[3] |= 0x10; /* Enable unrestricted reordering */ if (1 == pcontrol) memset(p + 2, 0, sizeof(ctrl_m_pg) - 2); diff --git a/scst/src/dev_handlers/scst_modisk.c b/scst/src/dev_handlers/scst_modisk.c index 8e9929f8b..e1ec071c2 100644 --- a/scst/src/dev_handlers/scst_modisk.c +++ b/scst/src/dev_handlers/scst_modisk.c @@ -375,7 +375,7 @@ int modisk_parse(struct scst_cmd *cmd, const struct scst_info_cdb *info_cdb) int modisk_done(struct scst_cmd *cmd) { int opcode = cmd->cdb[0]; - int masked_status = cmd->masked_status; + int status = cmd->status; struct modisk_params *modisk; int res = SCST_CMD_STATE_DEFAULT; @@ -386,11 +386,11 @@ int modisk_done(struct scst_cmd *cmd) /* * SCST sets good defaults for cmd->tgt_resp_flags and cmd->resp_data_len - * based on cmd->masked_status and cmd->data_direction, therefore change + * based on cmd->status and cmd->data_direction, therefore change * them only if necessary */ - if ((masked_status == GOOD) || (masked_status == CONDITION_GOOD)) { + if ((status == SAM_STAT_GOOD) || (status == SAM_STAT_CONDITION_MET)) { switch (opcode) { case READ_CAPACITY: { @@ -468,7 +468,6 @@ int modisk_exec(struct scst_cmd *cmd) case READ_16: res = SCST_EXEC_COMPLETED; cmd->status = 0; - cmd->masked_status = 0; cmd->msg_status = 0; cmd->host_status = DID_OK; cmd->driver_status = 0; diff --git a/scst/src/dev_handlers/scst_processor.c b/scst/src/dev_handlers/scst_processor.c index 8ab3dd4a5..70f342711 100644 --- a/scst/src/dev_handlers/scst_processor.c +++ b/scst/src/dev_handlers/scst_processor.c @@ -183,7 +183,7 @@ int processor_done(struct scst_cmd *cmd) /* * SCST sets good defaults for cmd->tgt_resp_flags and cmd->resp_data_len - * based on cmd->masked_status and cmd->data_direction, therefore change + * based on cmd->status and cmd->data_direction, therefore change * them only if necessary */ diff --git a/scst/src/dev_handlers/scst_raid.c b/scst/src/dev_handlers/scst_raid.c index 43a1b7fff..ad155a761 100644 --- a/scst/src/dev_handlers/scst_raid.c +++ b/scst/src/dev_handlers/scst_raid.c @@ -183,7 +183,7 @@ int raid_done(struct scst_cmd *cmd) /* * SCST sets good defaults for cmd->tgt_resp_flags and cmd->resp_data_len - * based on cmd->masked_status and cmd->data_direction, therefore change + * based on cmd->status and cmd->data_direction, therefore change * them only if necessary */ diff --git a/scst/src/dev_handlers/scst_tape.c b/scst/src/dev_handlers/scst_tape.c index 1bdd91e5d..1c13caaf4 100644 --- a/scst/src/dev_handlers/scst_tape.c +++ b/scst/src/dev_handlers/scst_tape.c @@ -348,7 +348,7 @@ int tape_parse(struct scst_cmd *cmd, const struct scst_info_cdb *info_cdb) int tape_done(struct scst_cmd *cmd) { int opcode = cmd->cdb[0]; - int masked_status = cmd->masked_status; + int status = cmd->status; struct tape_params *tape; int res = SCST_CMD_STATE_DEFAULT; @@ -359,11 +359,11 @@ int tape_done(struct scst_cmd *cmd) /* * SCST sets good defaults for cmd->tgt_resp_flags and cmd->resp_data_len - * based on cmd->masked_status and cmd->data_direction, therefore change + * based on cmd->status and cmd->data_direction, therefore change * them only if necessary */ - if ((masked_status == GOOD) || (masked_status == CONDITION_GOOD)) { + if ((status == SAM_STAT_GOOD) || (status == SAM_STAT_CONDITION_MET)) { int buffer_size; uint8_t *buffer = NULL; @@ -434,7 +434,7 @@ int tape_done(struct scst_cmd *cmd) break; } } - else if ((masked_status == CHECK_CONDITION) && + else if ((status == SAM_STAT_CHECK_CONDITION) && SCST_SENSE_VALID(cmd->sense_buffer)) { TRACE_DBG("%s", "Extended sense"); @@ -504,7 +504,6 @@ int tape_exec(struct scst_cmd *cmd) case READ_6: res = SCST_EXEC_COMPLETED; cmd->status = 0; - cmd->masked_status = 0; cmd->msg_status = 0; cmd->host_status = DID_OK; cmd->driver_status = 0; diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 0f3066a64..ec79f57d6 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -43,7 +43,6 @@ void scst_set_cmd_error_status(struct scst_cmd *cmd, int status) TRACE_ENTRY(); cmd->status = status; - cmd->masked_status = status >> 1; cmd->host_status = DID_OK; cmd->data_direction = SCST_DATA_NONE; diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 2215471c2..23cb8f93d 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1062,7 +1062,6 @@ static void scst_check_sense(struct scst_cmd *cmd, const uint8_t *rq_sense, TRACE(TRACE_MGMT, "Retrying cmd %p " "(tag %d)", cmd, cmd->tag); cmd->status = 0; - cmd->masked_status = 0; cmd->msg_status = 0; cmd->host_status = DID_OK; cmd->driver_status = 0; @@ -1127,9 +1126,8 @@ static int scst_check_auto_sense(struct scst_cmd *cmd) SCST_NO_SENSE(cmd->sense_buffer))) { TRACE(TRACE_SCSI|TRACE_MINOR, "CHECK_CONDITION, but no sense: " - "cmd->status=%x, cmd->masked_status=%x, " - "cmd->msg_status=%x, cmd->host_status=%x, " - "cmd->driver_status=%x", cmd->status, cmd->masked_status, + "cmd->status=%x, cmd->msg_status=%x, " + "cmd->host_status=%x, cmd->driver_status=%x", cmd->status, cmd->msg_status, cmd->host_status, cmd->driver_status); res = 1; } else if (unlikely(cmd->host_status)) { @@ -1158,7 +1156,6 @@ static void scst_do_cmd_done(struct scst_cmd *cmd, int result, TRACE_ENTRY(); cmd->status = result & 0xff; - cmd->masked_status = status_byte(result); cmd->msg_status = msg_byte(result); cmd->host_status = host_byte(result); cmd->driver_status = driver_byte(result); @@ -1173,10 +1170,9 @@ static void scst_do_cmd_done(struct scst_cmd *cmd, int result, } TRACE(TRACE_SCSI, "result=%x, cmd->status=%x, resid=%d, " - "cmd->masked_status=%x, cmd->msg_status=%x, cmd->host_status=%x, " + "cmd->msg_status=%x, cmd->host_status=%x, " "cmd->driver_status=%x", result, cmd->status, resid, - cmd->masked_status, cmd->msg_status, cmd->host_status, - cmd->driver_status); + cmd->msg_status, cmd->host_status, cmd->driver_status); cmd->completed = 1; @@ -1369,7 +1365,6 @@ static int scst_report_luns_local(struct scst_cmd *cmd) TRACE_ENTRY(); cmd->status = 0; - cmd->masked_status = 0; cmd->msg_status = 0; cmd->host_status = DID_OK; cmd->driver_status = 0; @@ -1581,7 +1576,6 @@ static int scst_release_local(struct scst_cmd *cmd) if (test_bit(SCST_TGT_DEV_RESERVED, &cmd->tgt_dev->tgt_dev_flags)) { res = SCST_EXEC_COMPLETED; cmd->status = 0; - cmd->masked_status = 0; cmd->msg_status = 0; cmd->host_status = DID_OK; cmd->driver_status = 0; @@ -2062,7 +2056,7 @@ static int scst_done_cmd_check(struct scst_cmd *cmd, int *pres) &cmd->tgt_dev->tgt_dev_flags)) { struct scst_tgt_dev *tgt_dev_tmp; TRACE(TRACE_SCSI, "Real RESERVE failed lun=%Ld, status=%x", - (uint64_t)cmd->lun, cmd->masked_status); + (uint64_t)cmd->lun, cmd->status); TRACE_BUFF_FLAG(TRACE_SCSI, "Sense", cmd->sense_buffer, sizeof(cmd->sense_buffer)); /* Clearing the reservation */