Post r227 fixes and cleanups. Particulary, fixes brocken by it scst_user functionalit...
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Mon, 10 Dec 2007 12:09:07 +0000 (12:09 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Mon, 10 Dec 2007 12:09:07 +0000 (12:09 +0000)
git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@230 d57e44dd-8a1f-0410-8b47-8ef2f437770f

15 files changed:
scst/include/scsi_tgt.h
scst/src/dev_handlers/scst_cdrom.c
scst/src/dev_handlers/scst_changer.c
scst/src/dev_handlers/scst_dev_handler.h
scst/src/dev_handlers/scst_disk.c
scst/src/dev_handlers/scst_modisk.c
scst/src/dev_handlers/scst_processor.c
scst/src/dev_handlers/scst_raid.c
scst/src/dev_handlers/scst_tape.c
scst/src/dev_handlers/scst_user.c
scst/src/dev_handlers/scst_vdisk.c
scst/src/scst_lib.c
scst/src/scst_main.c
scst/src/scst_targ.c
usr/fileio/fileio.c

index 73be939..f3a4417 100644 (file)
@@ -385,7 +385,6 @@ struct scst_mgmt_cmd;
 struct scst_device;
 struct scst_tgt_dev;
 struct scst_dev_type;
-struct scst_info_cdb;
 struct scst_acg;
 struct scst_acg_dev;
 struct scst_acn;
@@ -394,6 +393,15 @@ typedef uint64_t lun_t;
 
 typedef enum dma_data_direction scst_data_direction;
 
+enum scst_cdb_flags
+{
+       SCST_TRANSFER_LEN_TYPE_FIXED = 0x01, /* must be equviv 1 (FIXED_BIT in cdb) */
+       SCST_SMALL_TIMEOUT = 0x02,
+       SCST_LONG_TIMEOUT = 0x04,
+       SCST_UNKNOWN_LENGTH = 0x08,
+       SCST_INFO_INVALID = 0x10,
+};
+
 /* 
  * Scsi_Target_Template: defines what functions a target driver will
  * have to provide in order to work with the target mid-level. 
@@ -688,7 +696,7 @@ struct scst_dev_type
         *
         * MUST HAVE
         */
-       int (*parse) (struct scst_cmd *cmd, struct scst_info_cdb *cdb_info);
+       int (*parse) (struct scst_cmd *cmd);
 
        /* 
         * Called to execute CDB. Useful, for instance, to implement 
@@ -1120,6 +1128,9 @@ struct scst_cmd
        uint8_t cdb[SCST_MAX_CDB_SIZE];
        int cdb_len;
 
+       enum scst_cdb_flags op_flags;
+       const char *op_name;
+
        enum scst_cmd_queue_type queue_type;
 
        int timeout;    /* CDB execution timeout */
@@ -1505,24 +1516,6 @@ struct scst_tgt_dev_UA
        uint8_t UA_sense_buffer[SCST_SENSE_BUFFERSIZE];
 };
 
-enum scst_cdb_flags
-{
-       SCST_TRANSFER_LEN_TYPE_FIXED = 0x01, /* must be equviv 1 (FIXED_BIT in cdb) */
-       SCST_SMALL_TIMEOUT = 0x02,
-       SCST_LONG_TIMEOUT = 0x04,
-       SCST_UNKNOWN_LENGTH = 0x08,
-       SCST_INFO_INVALID = 0x10,
-};
-
-struct scst_info_cdb
-{
-       enum scst_cdb_flags flags;
-       scst_data_direction direction;
-       unsigned int transfer_len;
-       unsigned short cdb_len;
-       const char *op_name;
-};
-
 #ifndef smp_mb__after_set_bit
 /* There is no smp_mb__after_set_bit() in the kernel */
 #define smp_mb__after_set_bit()                 smp_mb();
@@ -1785,11 +1778,12 @@ static inline int scst_rx_mgmt_fn_lun(struct scst_session *sess, int fn,
  * Parameters:
  *   cdb_p - pointer to CDB
  *   dev_type - SCSI device type
- *   info_p - the result structure (output)
+ *   op_flags, direction, transfer_len, cdb_len, op_name - the result (output)
  * Returns 0 on success, -1 otherwise
  */
 int scst_get_cdb_info(const uint8_t *cdb_p, int dev_type,
-                     struct scst_info_cdb *info_p);
+       enum scst_cdb_flags *op_flags, scst_data_direction *direction,
+       unsigned int *transfer_len, int *cdb_len, const char **op_name);
 
 /* 
  * Set error SCSI status in the command and prepares it for returning it
@@ -2470,37 +2464,30 @@ int scst_calc_block_shift(int sector_size);
 
 /* Generic parse() for SBC (disk) devices */
 int scst_sbc_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*get_block_shift)(struct scst_cmd *cmd));
 
 /* Generic parse() for MMC (cdrom) devices */
 int scst_cdrom_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*get_block_shift)(struct scst_cmd *cmd));
 
 /* Generic parse() for MO disk devices */
 int scst_modisk_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*get_block_shift)(struct scst_cmd *cmd));
 
 /* Generic parse() for tape devices */
 int scst_tape_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*get_block_size)(struct scst_cmd *cmd));
 
 /* Generic parse() for changer devices */
 int scst_changer_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*nothing)(struct scst_cmd *cmd));
 
 /* Generic parse() for "processor" devices */
 int scst_processor_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*nothing)(struct scst_cmd *cmd));
 
 /* Generic parse() for RAID devices */
 int scst_raid_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*nothing)(struct scst_cmd *cmd));
 
 /**
index a9f6569..67201ff 100644 (file)
@@ -51,7 +51,7 @@ struct cdrom_params
 
 int cdrom_attach(struct scst_device *);
 void cdrom_detach(struct scst_device *);
-int cdrom_parse(struct scst_cmd *, struct scst_info_cdb *);
+int cdrom_parse(struct scst_cmd *);
 int cdrom_done(struct scst_cmd *);
 
 static struct scst_dev_type cdrom_devtype = CDROM_TYPE;
@@ -205,21 +205,21 @@ static int cdrom_get_block_shift(struct scst_cmd *cmd)
  *
  *  Note:  Not all states are allowed on return
  ********************************************************************/
-int cdrom_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
+int cdrom_parse(struct scst_cmd *cmd)
 {
        int res = SCST_CMD_STATE_DEFAULT;
 
-       scst_cdrom_generic_parse(cmd, info_cdb, cdrom_get_block_shift);
+       scst_cdrom_generic_parse(cmd, cdrom_get_block_shift);
 
        cmd->retries = SCST_PASSTHROUGH_RETRIES;
 
-       if (info_cdb->flags & SCST_SMALL_TIMEOUT) {
+       if ((cmd->op_flags & (SCST_SMALL_TIMEOUT | SCST_LONG_TIMEOUT)) == 0)
+               cmd->timeout = CDROM_REG_TIMEOUT;
+       else if (cmd->op_flags & SCST_SMALL_TIMEOUT)
                cmd->timeout = CDROM_SMALL_TIMEOUT;
-       } else if (info_cdb->flags & SCST_LONG_TIMEOUT) {
+       else if (cmd->op_flags & SCST_LONG_TIMEOUT)
                cmd->timeout = CDROM_LONG_TIMEOUT;
-       } else {
-               cmd->timeout = CDROM_REG_TIMEOUT;
-       }
+
        return res;
 }
 
index 09eef66..97b9e59 100644 (file)
@@ -44,7 +44,7 @@
 
 int changer_attach(struct scst_device *);
 void changer_detach(struct scst_device *);
-int changer_parse(struct scst_cmd *, struct scst_info_cdb *);
+int changer_parse(struct scst_cmd *);
 int changer_done(struct scst_cmd *);
 
 static struct scst_dev_type changer_devtype = CHANGER_TYPE;
@@ -126,15 +126,15 @@ void changer_detach(struct scst_device *dev)
  *
  *  Note:  Not all states are allowed on return
  ********************************************************************/
-int changer_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
+int changer_parse(struct scst_cmd *cmd)
 {
        int res = SCST_CMD_STATE_DEFAULT;
 
-       scst_changer_generic_parse(cmd, info_cdb, 0);
+       scst_changer_generic_parse(cmd, 0);
 
        cmd->retries = SCST_PASSTHROUGH_RETRIES;
 
-       if (info_cdb->flags & SCST_LONG_TIMEOUT) {
+       if (cmd->op_flags & SCST_LONG_TIMEOUT) {
                cmd->timeout = CHANGER_LONG_TIMEOUT;
        } else {
                cmd->timeout = CHANGER_TIMEOUT;
index a70267d..29580c2 100644 (file)
@@ -8,6 +8,7 @@
 #include "scst_debug.h"
 
 #define SCST_DEV_UA_RETRIES 5
+#define SCST_PASSTHROUGH_RETRIES       0
 
 #if defined(DEBUG) || defined(TRACING)
 
@@ -29,8 +30,6 @@ static unsigned long dh_trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS;
 #define trace_log_tbl  NULL
 #endif
 
-#define SCST_PASSTHROUGH_RETRIES       0
-
 static struct scst_proc_data dev_handler_log_proc_data;
 
 static int dev_handler_log_info_show(struct seq_file *seq, void *v)
index e0fdd99..f766882 100644 (file)
@@ -70,7 +70,7 @@ struct disk_params
 
 int disk_attach(struct scst_device *dev);
 void disk_detach(struct scst_device *dev);
-int disk_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cmd);
+int disk_parse(struct scst_cmd *cmd);
 int disk_done(struct scst_cmd *cmd);
 int disk_exec(struct scst_cmd *cmd);
 
@@ -277,21 +277,20 @@ static int disk_get_block_shift(struct scst_cmd *cmd)
  *
  *  Note:  Not all states are allowed on return
  ********************************************************************/
-int disk_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
+int disk_parse(struct scst_cmd *cmd)
 {
        int res = SCST_CMD_STATE_DEFAULT;
 
-       scst_sbc_generic_parse(cmd, info_cdb, disk_get_block_shift);
+       scst_sbc_generic_parse(cmd, disk_get_block_shift);
 
        cmd->retries = SCST_PASSTHROUGH_RETRIES;
 
-       if (info_cdb->flags & SCST_SMALL_TIMEOUT) {
+       if ((cmd->op_flags & (SCST_SMALL_TIMEOUT | SCST_LONG_TIMEOUT)) == 0)
+               cmd->timeout = DISK_REG_TIMEOUT;
+       else if (cmd->op_flags & SCST_SMALL_TIMEOUT)
                cmd->timeout = DISK_SMALL_TIMEOUT;
-       } else if (info_cdb->flags & SCST_LONG_TIMEOUT) {
+       else if (cmd->op_flags & SCST_LONG_TIMEOUT)
                cmd->timeout = DISK_LONG_TIMEOUT;
-       } else {
-               cmd->timeout = DISK_REG_TIMEOUT;
-       }
 
        return res;
 }
index 9258468..a829939 100644 (file)
@@ -70,7 +70,7 @@ struct modisk_params
 
 int modisk_attach(struct scst_device *);
 void modisk_detach(struct scst_device *);
-int modisk_parse(struct scst_cmd *, struct scst_info_cdb *);
+int modisk_parse(struct scst_cmd *);
 int modisk_done(struct scst_cmd *);
 int modisk_exec(struct scst_cmd *);
 
@@ -292,21 +292,21 @@ static int modisk_get_block_shift(struct scst_cmd *cmd)
  *
  *  Note:  Not all states are allowed on return
  ********************************************************************/
-int modisk_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
+int modisk_parse(struct scst_cmd *cmd)
 {
        int res = SCST_CMD_STATE_DEFAULT;
 
-       scst_modisk_generic_parse(cmd, info_cdb, modisk_get_block_shift);
+       scst_modisk_generic_parse(cmd, modisk_get_block_shift);
 
        cmd->retries = SCST_PASSTHROUGH_RETRIES;
 
-       if (info_cdb->flags & SCST_SMALL_TIMEOUT) {
+       if ((cmd->op_flags & (SCST_SMALL_TIMEOUT | SCST_LONG_TIMEOUT)) == 0)
+               cmd->timeout = MODISK_REG_TIMEOUT;
+       else if (cmd->op_flags & SCST_SMALL_TIMEOUT)
                cmd->timeout = MODISK_SMALL_TIMEOUT;
-       } else if (info_cdb->flags & SCST_LONG_TIMEOUT) {
+       else if (cmd->op_flags & SCST_LONG_TIMEOUT)
                cmd->timeout = MODISK_LONG_TIMEOUT;
-       } else {
-               cmd->timeout = MODISK_REG_TIMEOUT;
-       }
+
        return res;
 }
 
index efa75a2..a237043 100644 (file)
@@ -44,7 +44,7 @@
 
 int processor_attach(struct scst_device *);
 void processor_detach(struct scst_device *);
-int processor_parse(struct scst_cmd *, struct scst_info_cdb *);
+int processor_parse(struct scst_cmd *);
 int processor_done(struct scst_cmd *);
 
 static struct scst_dev_type processor_devtype = PROCESSOR_TYPE;
@@ -126,15 +126,15 @@ void processor_detach(struct scst_device *dev)
  *
  *  Note:  Not all states are allowed on return
  ********************************************************************/
-int processor_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
+int processor_parse(struct scst_cmd *cmd)
 {
        int res = SCST_CMD_STATE_DEFAULT;
 
-       scst_processor_generic_parse(cmd, info_cdb, 0);
+       scst_processor_generic_parse(cmd, 0);
 
        cmd->retries = SCST_PASSTHROUGH_RETRIES;
 
-       if (info_cdb->flags & SCST_LONG_TIMEOUT) {
+       if (cmd->op_flags & SCST_LONG_TIMEOUT) {
                cmd->timeout = PROCESSOR_LONG_TIMEOUT;
        } else {
                cmd->timeout = PROCESSOR_TIMEOUT;
index 2527f2c..2ae93d8 100644 (file)
@@ -44,7 +44,7 @@
 
 int raid_attach(struct scst_device *);
 void raid_detach(struct scst_device *);
-int raid_parse(struct scst_cmd *, struct scst_info_cdb *);
+int raid_parse(struct scst_cmd *);
 int raid_done(struct scst_cmd *);
 
 static struct scst_dev_type raid_devtype = RAID_TYPE;
@@ -126,15 +126,15 @@ void raid_detach(struct scst_device *dev)
  *
  *  Note:  Not all states are allowed on return
  ********************************************************************/
-int raid_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
+int raid_parse(struct scst_cmd *cmd)
 {
        int res = SCST_CMD_STATE_DEFAULT;
 
-       scst_raid_generic_parse(cmd, info_cdb, 0);
+       scst_raid_generic_parse(cmd, 0);
 
        cmd->retries = SCST_PASSTHROUGH_RETRIES;
 
-       if (info_cdb->flags & SCST_LONG_TIMEOUT) {
+       if (cmd->op_flags & SCST_LONG_TIMEOUT) {
                cmd->timeout = RAID_LONG_TIMEOUT;
        } else {
                cmd->timeout = RAID_TIMEOUT;
index cc50926..0e14841 100644 (file)
@@ -75,7 +75,7 @@ struct tape_params
 
 int tape_attach(struct scst_device *);
 void tape_detach(struct scst_device *);
-int tape_parse(struct scst_cmd *, struct scst_info_cdb *);
+int tape_parse(struct scst_cmd *);
 int tape_done(struct scst_cmd *);
 int tape_exec(struct scst_cmd *);
 
@@ -280,21 +280,21 @@ static int tape_get_block_size(struct scst_cmd *cmd)
  *
  *  Note:  Not all states are allowed on return
  ********************************************************************/
-int tape_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
+int tape_parse(struct scst_cmd *cmd)
 {
        int res = SCST_CMD_STATE_DEFAULT;
 
-       scst_tape_generic_parse(cmd, info_cdb, tape_get_block_size);
+       scst_tape_generic_parse(cmd, tape_get_block_size);
 
        cmd->retries = SCST_PASSTHROUGH_RETRIES;
 
-       if (info_cdb->flags & SCST_SMALL_TIMEOUT) {
+       if ((cmd->op_flags & (SCST_SMALL_TIMEOUT | SCST_LONG_TIMEOUT)) == 0)
+               cmd->timeout = TAPE_REG_TIMEOUT;
+       else if (cmd->op_flags & SCST_SMALL_TIMEOUT)
                cmd->timeout = TAPE_SMALL_TIMEOUT;
-       } else if (info_cdb->flags & SCST_LONG_TIMEOUT) {
+       else if (cmd->op_flags & SCST_LONG_TIMEOUT)
                cmd->timeout = TAPE_LONG_TIMEOUT;
-       } else {
-               cmd->timeout = TAPE_REG_TIMEOUT;
-       }
+
        return res;
 }
 
index 3d395ac..b04ec37 100644 (file)
@@ -67,7 +67,7 @@ struct scst_user_dev
 
        unsigned short detach_cmd_count;
 
-       int (*generic_parse)(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb,
+       int (*generic_parse)(struct scst_cmd *cmd,
                int (*get_block)(struct scst_cmd *cmd));
 
        int block;
@@ -154,7 +154,7 @@ static struct scst_user_cmd *dev_user_alloc_ucmd(struct scst_user_dev *dev,
        int gfp_mask);
 static void dev_user_free_ucmd(struct scst_user_cmd *ucmd);
 
-static int dev_user_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb);
+static int dev_user_parse(struct scst_cmd *cmd);
 static int dev_user_exec(struct scst_cmd *cmd);
 static void dev_user_on_free_cmd(struct scst_cmd *cmd);
 static int dev_user_task_mgmt_fn(struct scst_mgmt_cmd *mcmd, 
@@ -648,7 +648,7 @@ static int dev_user_get_block(struct scst_cmd *cmd)
        return dev->block;
 }
 
-static int dev_user_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
+static int dev_user_parse(struct scst_cmd *cmd)
 {
        int rc, res = SCST_CMD_STATE_DEFAULT;
        struct scst_user_cmd *ucmd;
@@ -684,15 +684,15 @@ static int dev_user_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
        switch(dev->parse_type) {
        case SCST_USER_PARSE_STANDARD:
                TRACE_DBG("PARSE STANDARD: ucmd %p", ucmd);
-               rc = dev->generic_parse(cmd, info_cdb, dev_user_get_block);
-               if ((rc != 0) || (info_cdb->flags & SCST_INFO_INVALID))
+               rc = dev->generic_parse(cmd, dev_user_get_block);
+               if ((rc != 0) || (cmd->op_flags & SCST_INFO_INVALID))
                        goto out_invalid;
                break;
 
        case SCST_USER_PARSE_EXCEPTION:
                TRACE_DBG("PARSE EXCEPTION: ucmd %p", ucmd);
-               rc = dev->generic_parse(cmd, info_cdb, dev_user_get_block);
-               if ((rc == 0) && (!(info_cdb->flags & SCST_INFO_INVALID)))
+               rc = dev->generic_parse(cmd, dev_user_get_block);
+               if ((rc == 0) && (!(cmd->op_flags & SCST_INFO_INVALID)))
                        break;
                else if (rc == SCST_CMD_STATE_NEED_THREAD_CTX) {
                        TRACE_MEM("Restarting PARSE to thread context "
@@ -742,7 +742,7 @@ out:
 
 out_invalid:
        PRINT_ERROR("PARSE failed (ucmd %p, rc %d, invalid %d)", ucmd, rc,
-               info_cdb->flags & SCST_INFO_INVALID);
+               cmd->op_flags & SCST_INFO_INVALID);
        scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_opcode));
 
 out_error:
@@ -2854,7 +2854,7 @@ out:
        return res;
 }
 
-static int dev_usr_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
+static int dev_usr_parse(struct scst_cmd *cmd)
 {
        sBUG();
        return SCST_CMD_STATE_DEFAULT;
index ef11097..886f8c9 100644 (file)
@@ -219,9 +219,9 @@ static int vdisk_attach(struct scst_device *dev);
 static void vdisk_detach(struct scst_device *dev);
 static int vdisk_attach_tgt(struct scst_tgt_dev *tgt_dev);
 static void vdisk_detach_tgt(struct scst_tgt_dev *tgt_dev);
-static int vdisk_parse(struct scst_cmd *, struct scst_info_cdb *info_cdb);
+static int vdisk_parse(struct scst_cmd *);
 static int vdisk_do_job(struct scst_cmd *cmd);
-static int vcdrom_parse(struct scst_cmd *, struct scst_info_cdb *info_cdb);
+static int vcdrom_parse(struct scst_cmd *);
 static int vcdrom_exec(struct scst_cmd *cmd);
 static void vdisk_exec_read(struct scst_cmd *cmd,
        struct scst_vdisk_thr *thr, loff_t loff);
@@ -971,10 +971,9 @@ static int vdisk_get_block_shift(struct scst_cmd *cmd)
  *
  *  Note:  Not all states are allowed on return
  ********************************************************************/
-static int vdisk_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb)
+static int vdisk_parse(struct scst_cmd *cmd)
 {
-       scst_sbc_generic_parse(cmd, info_cdb, vdisk_get_block_shift);
+       scst_sbc_generic_parse(cmd, vdisk_get_block_shift);
        return SCST_CMD_STATE_DEFAULT;
 }
 
@@ -989,10 +988,9 @@ static int vdisk_parse(struct scst_cmd *cmd,
  *
  *  Note:  Not all states are allowed on return
  ********************************************************************/
-static int vcdrom_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb)
+static int vcdrom_parse(struct scst_cmd *cmd)
 {
-       scst_cdrom_generic_parse(cmd, info_cdb, vdisk_get_block_shift);
+       scst_cdrom_generic_parse(cmd, vdisk_get_block_shift);
        return SCST_CMD_STATE_DEFAULT;
 }
 
index 319ea91..ca28755 100644 (file)
@@ -1681,7 +1681,8 @@ static uint32_t get_trans_len_none(const uint8_t *cdb, uint8_t off)
 }
 
 int scst_get_cdb_info(const uint8_t *cdb_p, int dev_type,
-                     struct scst_info_cdb *info_p)
+       enum scst_cdb_flags *op_flags, scst_data_direction *direction,
+       unsigned int *transfer_len, int *cdb_len, const char **op_name)
 {
        int i, res = 0;
        uint8_t op;
@@ -1725,24 +1726,23 @@ int scst_get_cdb_info(const uint8_t *cdb_p, int dev_type,
                TRACE(TRACE_SCSI, "Unknown opcode 0x%x for type %d", op,
                      dev_type);
                res = -1;
-               memset(info_p, 0, sizeof(*info_p));
-               info_p->flags = SCST_INFO_INVALID;
+               *op_flags = SCST_INFO_INVALID;
                goto out;
        }
 
-       info_p->cdb_len = SCST_GET_CDB_LEN(op);
-       info_p->op_name = ptr->op_name;
-       info_p->direction = ptr->direction;
-       info_p->flags = ptr->flags;
-       info_p->transfer_len = (*ptr->get_trans_len)(cdb_p, ptr->off);
+       *cdb_len = SCST_GET_CDB_LEN(op);
+       *op_name = ptr->op_name;
+       *direction = ptr->direction;
+       *op_flags = ptr->flags;
+       *transfer_len = (*ptr->get_trans_len)(cdb_p, ptr->off);
 
 #ifdef EXTRACHECKS
-       if (unlikely((info_p->transfer_len == 0) &&
-                    (info_p->direction != SCST_DATA_NONE) &&
-           ((info_p->flags & SCST_UNKNOWN_LENGTH) == 0))) {
+       if (unlikely((*transfer_len == 0) &&
+                    (*direction != SCST_DATA_NONE) &&
+           ((*op_flags & SCST_UNKNOWN_LENGTH) == 0))) {
                PRINT_ERROR("transfer_len 0, direction %d, flags %x, changing "
-                       "direction on NONE", info_p->direction, info_p->flags);
-               info_p->direction = SCST_DATA_NONE;
+                       "direction on NONE", *direction, *op_flags);
+               *direction = SCST_DATA_NONE;
        }
 #endif
 
@@ -1871,7 +1871,6 @@ int scst_calc_block_shift(int sector_size)
 }
 
 int scst_sbc_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*get_block_shift)(struct scst_cmd *cmd))
 {
        int res = 0;
@@ -1879,13 +1878,12 @@ int scst_sbc_generic_parse(struct scst_cmd *cmd,
        TRACE_ENTRY();
        
        /*
-        * SCST sets good defaults for cmd->data_direction and cmd->bufflen
-        * based on info_cdb, therefore change them only if necessary
+        * SCST sets good defaults for cmd->data_direction and cmd->bufflen,
+        * therefore change them only if necessary
         */
 
        TRACE_DBG("op_name <%s> direct %d flags %d transfer_len %d",
-             info_cdb->op_name,
-             info_cdb->direction, info_cdb->flags, info_cdb->transfer_len);
+             cmd->op_name, cmd->data_direction, cmd->op_flags, cmd->bufflen);
 
        switch (cmd->cdb[0]) {
        case SERVICE_ACTION_IN:
@@ -1899,11 +1897,10 @@ int scst_sbc_generic_parse(struct scst_cmd *cmd,
        case VERIFY_12:
        case VERIFY_16:
                if ((cmd->cdb[1] & BYTCHK) == 0) {
-                       cmd->data_len = 
-                           info_cdb->transfer_len << get_block_shift(cmd);
+                       cmd->data_len = cmd->bufflen << get_block_shift(cmd);
                        cmd->bufflen = 0;
                        cmd->data_direction = SCST_DATA_NONE;
-                       info_cdb->flags &= ~SCST_TRANSFER_LEN_TYPE_FIXED;
+                       cmd->op_flags &= ~SCST_TRANSFER_LEN_TYPE_FIXED;
                } else
                        cmd->data_len = 0;
                break;
@@ -1912,12 +1909,12 @@ int scst_sbc_generic_parse(struct scst_cmd *cmd,
                break;
        }
 
-       if (info_cdb->flags & SCST_TRANSFER_LEN_TYPE_FIXED) {
+       if (cmd->op_flags & SCST_TRANSFER_LEN_TYPE_FIXED) {
                /* 
                 * No need for locks here, since *_detach() can not be
                 * called, when there are existing commands.
                 */
-               cmd->bufflen = info_cdb->transfer_len << get_block_shift(cmd);
+               cmd->bufflen = cmd->bufflen << get_block_shift(cmd);
        }
 
        TRACE_DBG("res %d, bufflen %d, data_len %d, direct %d",
@@ -1928,7 +1925,6 @@ int scst_sbc_generic_parse(struct scst_cmd *cmd,
 }
 
 int scst_cdrom_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*get_block_shift)(struct scst_cmd *cmd))
 {
        int res = 0;
@@ -1936,15 +1932,12 @@ int scst_cdrom_generic_parse(struct scst_cmd *cmd,
        TRACE_ENTRY();
 
        /*
-        * SCST sets good defaults for cmd->data_direction and cmd->bufflen
-        * based on info_cdb, therefore change them only if necessary
+        * SCST sets good defaults for cmd->data_direction and cmd->bufflen,
+        * therefore change them only if necessary
         */
 
-       TRACE_DBG("op_name <%s> direct %d flags %d transfer_len %d lun %Ld(%d)",
-             info_cdb->op_name,
-             info_cdb->direction,
-             info_cdb->flags,
-             info_cdb->transfer_len, cmd->lun, (cmd->cdb[1] >> 5) & 7);
+       TRACE_DBG("op_name <%s> direct %d flags %d transfer_len %d",
+             cmd->op_name, cmd->data_direction, cmd->op_flags, cmd->bufflen);
 
        cmd->cdb[1] &= 0x1f;
 
@@ -1954,11 +1947,10 @@ int scst_cdrom_generic_parse(struct scst_cmd *cmd,
        case VERIFY_12:
        case VERIFY_16:
                if ((cmd->cdb[1] & BYTCHK) == 0) {
-                       cmd->data_len = 
-                           info_cdb->transfer_len << get_block_shift(cmd);
+                       cmd->data_len = cmd->bufflen << get_block_shift(cmd);
                        cmd->bufflen = 0;
                        cmd->data_direction = SCST_DATA_NONE;
-                       info_cdb->flags &= ~SCST_TRANSFER_LEN_TYPE_FIXED;
+                       cmd->op_flags &= ~SCST_TRANSFER_LEN_TYPE_FIXED;
                }
                break;
        default:
@@ -1966,8 +1958,8 @@ int scst_cdrom_generic_parse(struct scst_cmd *cmd,
                break;
        }
 
-       if (info_cdb->flags & SCST_TRANSFER_LEN_TYPE_FIXED)
-               cmd->bufflen = info_cdb->transfer_len << get_block_shift(cmd);
+       if (cmd->op_flags & SCST_TRANSFER_LEN_TYPE_FIXED)
+               cmd->bufflen = cmd->bufflen << get_block_shift(cmd);
 
        TRACE_DBG("res %d bufflen %d direct %d",
              res, cmd->bufflen, cmd->data_direction);
@@ -1977,7 +1969,6 @@ int scst_cdrom_generic_parse(struct scst_cmd *cmd,
 }
 
 int scst_modisk_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*get_block_shift)(struct scst_cmd *cmd))
 {
        int res = 0;
@@ -1985,15 +1976,12 @@ int scst_modisk_generic_parse(struct scst_cmd *cmd,
        TRACE_ENTRY();
 
        /*
-        * SCST sets good defaults for cmd->data_direction and cmd->bufflen
-        * based on info_cdb, therefore change them only if necessary
+        * SCST sets good defaults for cmd->data_direction and cmd->bufflen,
+        * therefore change them only if necessary
         */
 
-       TRACE_DBG("op_name <%s> direct %d flags %d transfer_len %d lun %Ld(%d)",
-             info_cdb->op_name,
-             info_cdb->direction,
-             info_cdb->flags,
-             info_cdb->transfer_len, cmd->lun, (cmd->cdb[1] >> 5) & 7);
+       TRACE_DBG("op_name <%s> direct %d flags %d transfer_len %d",
+             cmd->op_name, cmd->data_direction, cmd->op_flags, cmd->bufflen);
 
        cmd->cdb[1] &= 0x1f;
 
@@ -2003,11 +1991,10 @@ int scst_modisk_generic_parse(struct scst_cmd *cmd,
        case VERIFY_12:
        case VERIFY_16:
                if ((cmd->cdb[1] & BYTCHK) == 0) {
-                       cmd->data_len = 
-                           info_cdb->transfer_len << get_block_shift(cmd);
+                       cmd->data_len = cmd->bufflen << get_block_shift(cmd);
                        cmd->bufflen = 0;
                        cmd->data_direction = SCST_DATA_NONE;
-                       info_cdb->flags &= ~SCST_TRANSFER_LEN_TYPE_FIXED;
+                       cmd->op_flags &= ~SCST_TRANSFER_LEN_TYPE_FIXED;
                }
                break;
        default:
@@ -2015,8 +2002,8 @@ int scst_modisk_generic_parse(struct scst_cmd *cmd,
                break;
        }
 
-       if (info_cdb->flags & SCST_TRANSFER_LEN_TYPE_FIXED)
-               cmd->bufflen = info_cdb->transfer_len << get_block_shift(cmd);
+       if (cmd->op_flags & SCST_TRANSFER_LEN_TYPE_FIXED)
+               cmd->bufflen = cmd->bufflen << get_block_shift(cmd);
 
        TRACE_DBG("res %d bufflen %d direct %d",
              res, cmd->bufflen, cmd->data_direction);
@@ -2026,7 +2013,6 @@ int scst_modisk_generic_parse(struct scst_cmd *cmd,
 }
 
 int scst_tape_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*get_block_size)(struct scst_cmd *cmd))
 {
        int res = 0;
@@ -2034,13 +2020,12 @@ int scst_tape_generic_parse(struct scst_cmd *cmd,
        TRACE_ENTRY();
 
        /*
-        * SCST sets good defaults for cmd->data_direction and cmd->bufflen
-        * based on info_cdb, therefore change them only if necessary
+        * SCST sets good defaults for cmd->data_direction and cmd->bufflen,
+        * therefore change them only if necessary
         */
 
        TRACE_DBG("op_name <%s> direct %d flags %d transfer_len %d",
-             info_cdb->op_name,
-             info_cdb->direction, info_cdb->flags, info_cdb->transfer_len);
+             cmd->op_name, cmd->data_direction, cmd->op_flags, cmd->bufflen);
 
        if (cmd->cdb[0] == READ_POSITION) {
                int tclp = cmd->cdb[1] & TCLP_BIT;
@@ -2057,27 +2042,26 @@ int scst_tape_generic_parse(struct scst_cmd *cmd,
                }
        }
 
-       if (info_cdb->flags & SCST_TRANSFER_LEN_TYPE_FIXED & cmd->cdb[1])
-               cmd->bufflen = info_cdb->transfer_len * get_block_size(cmd);
+       if (cmd->op_flags & SCST_TRANSFER_LEN_TYPE_FIXED & cmd->cdb[1])
+               cmd->bufflen = cmd->bufflen * get_block_size(cmd);
 
        TRACE_EXIT_RES(res);
        return res;
 }
 
-static int scst_null_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
+static int scst_null_parse(struct scst_cmd *cmd)
 {
        int res = 0;
 
        TRACE_ENTRY();
 
        /*
-        * SCST sets good defaults for cmd->data_direction and cmd->bufflen
-        * based on info_cdb, therefore change them only if necessary
+        * SCST sets good defaults for cmd->data_direction and cmd->bufflen,
+        * therefore change them only if necessary
         */
 
        TRACE_DBG("op_name <%s> direct %d flags %d transfer_len %d",
-             info_cdb->op_name,
-             info_cdb->direction, info_cdb->flags, info_cdb->transfer_len);
+             cmd->op_name, cmd->data_direction, cmd->op_flags, cmd->bufflen);
 #if 0
        switch (cmd->cdb[0]) {
        default:
@@ -2093,24 +2077,21 @@ static int scst_null_parse(struct scst_cmd *cmd, struct scst_info_cdb *info_cdb)
 }
 
 int scst_changer_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*nothing)(struct scst_cmd *cmd))
 {
-       return scst_null_parse(cmd, info_cdb);
+       return scst_null_parse(cmd);
 }
 
 int scst_processor_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*nothing)(struct scst_cmd *cmd))
 {
-       return scst_null_parse(cmd, info_cdb);
+       return scst_null_parse(cmd);
 }
 
 int scst_raid_generic_parse(struct scst_cmd *cmd,
-       struct scst_info_cdb *info_cdb,
        int (*nothing)(struct scst_cmd *cmd))
 {
-       return scst_null_parse(cmd, info_cdb);
+       return scst_null_parse(cmd);
 }
 
 int scst_block_generic_dev_done(struct scst_cmd *cmd,
@@ -3020,7 +3001,12 @@ void scst_xmit_process_aborted_cmd(struct scst_cmd *cmd)
                if (cmd->dev->tas) {
                        scst_set_cmd_error_status(cmd, SAM_STAT_TASK_ABORTED);
                } else {
-                       /* Abort without delivery or notification */
+                       /*
+                        * Abort without delivery or notification.
+                        * There is no need to check/requeue possible UA,
+                        * because, if it exists, it will be delivered
+                        * by the "completed" branch.
+                        */
                        clear_bit(SCST_CMD_ABORTED_OTHER,
                                &cmd->cmd_flags);
                }
index 3172994..bf72489 100644 (file)
@@ -135,7 +135,7 @@ MODULE_PARM_DESC(scst_threads, "SCSI target threads count");
 
 module_param_named(scst_max_cmd_mem, scst_max_cmd_mem, long, 0);
 MODULE_PARM_DESC(scst_max_cmd_mem, "Maximum memory allowed to be consumed by "
-       "the SCST commands at any given time in Mb");
+       "the SCST commands at any given time in MB");
 
 struct scst_dev_type scst_null_devtype = 
 {
@@ -1768,7 +1768,7 @@ EXPORT_SYMBOL(scst_random);
 module_init(init_scst);
 module_exit(exit_scst);
 
-MODULE_AUTHOR("Vladislav Bolkhovitin & Leonid Stoljar");
+MODULE_AUTHOR("Vladislav Bolkhovitin");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("SCSI target core");
 MODULE_VERSION(SCST_VERSION_STRING);
index d2d617d..d4108a1 100644 (file)
@@ -284,7 +284,6 @@ static int scst_pre_parse(struct scst_cmd *cmd)
 {
        int res = SCST_CMD_STATE_RES_CONT_SAME;
        struct scst_device *dev = cmd->dev;
-       struct scst_info_cdb cdb_info;
 
        TRACE_ENTRY();
 
@@ -300,7 +299,8 @@ static int scst_pre_parse(struct scst_cmd *cmd)
         */
 
        if (unlikely(scst_get_cdb_info(cmd->cdb, dev->handler->type, 
-                       &cdb_info) != 0)) {
+                       &cmd->op_flags, &cmd->data_direction,
+                       &cmd->bufflen, &cmd->cdb_len, &cmd->op_name) != 0)) {
                PRINT_ERROR("Unknown opcode 0x%02x for %s. "
                        "Should you update scst_scsi_op_table?",
                        cmd->cdb[0], dev->handler->name);
@@ -339,15 +339,12 @@ static int scst_pre_parse(struct scst_cmd *cmd)
        } else {
                TRACE(TRACE_SCSI, "op_name <%s>, direction=%d (expected %d, "
                        "set %s), transfer_len=%d (expected len %d), flags=%d",
-                       cdb_info.op_name, cdb_info.direction,
+                       cmd->op_name, cmd->data_direction,
                        cmd->expected_data_direction,
                        scst_cmd_is_expected_set(cmd) ? "yes" : "no",
-                       cdb_info.transfer_len, cmd->expected_transfer_len,
-                       cdb_info.flags);
+                       cmd->bufflen, cmd->expected_transfer_len, cmd->op_flags);
 
-               cmd->data_direction = cdb_info.direction;
-
-               if (unlikely((cdb_info.flags & SCST_UNKNOWN_LENGTH) != 0)) {
+               if (unlikely((cmd->op_flags & SCST_UNKNOWN_LENGTH) != 0)) {
                        if (scst_cmd_is_expected_set(cmd)) {
                                /*
                                 * Command data length can't be easily
@@ -360,11 +357,7 @@ static int scst_pre_parse(struct scst_cmd *cmd)
                                                        15*1024*1024);
                        } else
                                cmd->bufflen = 0;
-               } else
-                       cmd->bufflen = cdb_info.transfer_len;
-
-               /* Restore (likely) lost CDB length */
-               cmd->cdb_len = cdb_info.cdb_len;
+               }
        }
 
        if (unlikely(cmd->cdb[cmd->cdb_len - 1] & CONTROL_BYTE_NACA_BIT)) {
@@ -400,9 +393,9 @@ static int scst_parse_cmd(struct scst_cmd *cmd)
        int res = SCST_CMD_STATE_RES_CONT_SAME;
        int state;
        struct scst_device *dev = cmd->dev;
-       struct scst_info_cdb cdb_info;
        int atomic = scst_cmd_atomic(cmd);
-       int orig_bufflen;
+       int orig_bufflen = cmd->bufflen;
+       scst_data_direction orig_data_direction = cmd->data_direction;
 
        TRACE_ENTRY();
 
@@ -414,13 +407,11 @@ static int scst_parse_cmd(struct scst_cmd *cmd)
                goto out;
        }
 
-       orig_bufflen = cmd->bufflen;
-
        if (likely(!scst_is_cmd_local(cmd))) {
                TRACE_DBG("Calling dev handler %s parse(%p)",
                      dev->handler->name, cmd);
                TRACE_BUFF_FLAG(TRACE_SEND_BOT, "Parsing: ", cmd->cdb, cmd->cdb_len);
-               state = dev->handler->parse(cmd, &cdb_info);
+               state = dev->handler->parse(cmd);
                /* Caution: cmd can be already dead here */
                TRACE_DBG("Dev handler %s parse() returned %d",
                        dev->handler->name, state);
@@ -485,12 +476,12 @@ static int scst_parse_cmd(struct scst_cmd *cmd)
                cmd->data_direction = cmd->expected_data_direction;
                cmd->bufflen = cmd->expected_transfer_len;
 #else
-               if (unlikely(cmd->data_direction != cdb_info.direction)) {
+               if (unlikely(cmd->data_direction != orig_data_direction)) {
                        PRINT_ERROR("Expected data direction %d for opcode "
                                "0x%02x (handler %s, target %s) doesn't match "
                                "decoded value %d", cmd->data_direction,
                                cmd->cdb[0], dev->handler->name,
-                               cmd->tgtt->name, cdb_info.direction);
+                               cmd->tgtt->name, orig_data_direction);
                        scst_set_cmd_error(cmd,
                                SCST_LOAD_SENSE(scst_sense_invalid_message));
                        goto out_dev_done;
index facbc67..a210113 100644 (file)
@@ -53,7 +53,7 @@ char *app_name;
 #else /* DEBUG */
 
 # ifdef TRACING
-#define DEFAULT_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_MINOR | TRACE_MGMT \
+#define DEFAULT_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_MINOR | TRACE_MGMT \
        TRACE_TIME | TRACE_SPECIAL)
 # else
 #define DEFAULT_LOG_FLAGS 0