diff --git a/scst/include/scst.h b/scst/include/scst.h index 3759a9272..ad390b3b2 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -2015,8 +2015,8 @@ static inline int scst_cmd_atomic(struct scst_cmd *cmd) { int res = cmd->atomic; #ifdef CONFIG_SCST_EXTRACHECKS - if (unlikely(in_atomic() && !res)) { - printk(KERN_ERR "ERROR: in_atomic() and non-atomic cmd\n"); + if (unlikely((in_atomic() || in_interrupt()) && !res)) { + printk(KERN_ERR "ERROR: atomic context and non-atomic cmd\n"); dump_stack(); cmd->atomic = 1; res = 1; diff --git a/scst/src/dev_handlers/scst_cdrom.c b/scst/src/dev_handlers/scst_cdrom.c index 1808c796e..356dbf329 100644 --- a/scst/src/dev_handlers/scst_cdrom.c +++ b/scst/src/dev_handlers/scst_cdrom.c @@ -61,7 +61,7 @@ static struct scst_dev_type cdrom_devtype = CDROM_TYPE; * * Description: *************************************************************/ -int cdrom_attach(struct scst_device *dev) +static int cdrom_attach(struct scst_device *dev) { int res = 0; uint8_t cmd[10]; @@ -132,7 +132,8 @@ int cdrom_attach(struct scst_device *dev) if (sector_size == 0) params->block_shift = CDROM_DEF_BLOCK_SHIFT; else - params->block_shift = scst_calc_block_shift(sector_size); + params->block_shift = + scst_calc_block_shift(sector_size); TRACE_DBG("Sector size is %i scsi_level %d(SCSI_2 %d)", sector_size, dev->scsi_dev->scsi_level, SCSI_2); } else { @@ -172,7 +173,7 @@ out: * * Description: Called to detach this device type driver ************************************************************/ -void cdrom_detach(struct scst_device *dev) +static void cdrom_detach(struct scst_device *dev) { struct cdrom_params *params = (struct cdrom_params *)dev->dh_priv; @@ -207,7 +208,7 @@ 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) +static int cdrom_parse(struct scst_cmd *cmd) { int res = SCST_CMD_STATE_DEFAULT; @@ -243,7 +244,7 @@ static void cdrom_set_block_shift(struct scst_cmd *cmd, int block_shift) * it is used to extract any necessary information * about a command. ********************************************************************/ -int cdrom_done(struct scst_cmd *cmd) +static int cdrom_done(struct scst_cmd *cmd) { int res = SCST_CMD_STATE_DEFAULT; diff --git a/scst/src/dev_handlers/scst_changer.c b/scst/src/dev_handlers/scst_changer.c index c7d42dcca..49d85e70c 100644 --- a/scst/src/dev_handlers/scst_changer.c +++ b/scst/src/dev_handlers/scst_changer.c @@ -172,9 +172,9 @@ int changer_done(struct scst_cmd *cmd) TRACE_ENTRY(); /* - * SCST sets good defaults for cmd->is_send_status and cmd->resp_data_len - * based on cmd->status and cmd->data_direction, therefore change - * them only if necessary + * SCST sets good defaults for cmd->is_send_status and + * cmd->resp_data_len based on cmd->status and cmd->data_direction, + * therefore change them only if necessary */ #if 0 diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index bc33da2e8..4fd907683 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -137,7 +137,7 @@ module_exit(exit_scst_disk_driver); * * Description: *************************************************************/ -int disk_attach(struct scst_device *dev) +static int disk_attach(struct scst_device *dev) { int res = 0; uint8_t cmd[10]; @@ -206,7 +206,8 @@ int disk_attach(struct scst_device *dev) if (sector_size == 0) params->block_shift = DISK_DEF_BLOCK_SHIFT; else - params->block_shift = scst_calc_block_shift(sector_size); + params->block_shift = + scst_calc_block_shift(sector_size); } else { TRACE_BUFFER("Sense set", sbuff, SCST_SENSE_BUFFERSIZE); res = -ENODEV; @@ -245,7 +246,7 @@ out: * * Description: Called to detach this device type driver ************************************************************/ -void disk_detach(struct scst_device *dev) +static void disk_detach(struct scst_device *dev) { struct disk_params *params = (struct disk_params *)dev->dh_priv; @@ -280,7 +281,7 @@ 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) +static int disk_parse(struct scst_cmd *cmd) { int res = SCST_CMD_STATE_DEFAULT; @@ -316,7 +317,7 @@ static void disk_set_block_shift(struct scst_cmd *cmd, int block_shift) * it is used to extract any necessary information * about a command. ********************************************************************/ -int disk_done(struct scst_cmd *cmd) +static int disk_done(struct scst_cmd *cmd) { int res = SCST_CMD_STATE_DEFAULT; @@ -338,7 +339,7 @@ int disk_done(struct scst_cmd *cmd) * Description: Make SCST do nothing for data READs and WRITES. * Intended for raw line performance testing ********************************************************************/ -int disk_exec(struct scst_cmd *cmd) +static int disk_exec(struct scst_cmd *cmd) { int res = SCST_EXEC_NOT_COMPLETED, rc; int opcode = cmd->cdb[0]; diff --git a/scst/src/dev_handlers/scst_modisk.c b/scst/src/dev_handlers/scst_modisk.c index 3e4e82473..81483ff32 100644 --- a/scst/src/dev_handlers/scst_modisk.c +++ b/scst/src/dev_handlers/scst_modisk.c @@ -137,7 +137,7 @@ module_exit(exit_scst_modisk_driver); * * Description: *************************************************************/ -int modisk_attach(struct scst_device *dev) +static int modisk_attach(struct scst_device *dev) { int res = 0; uint8_t cmd[10]; @@ -218,7 +218,8 @@ int modisk_attach(struct scst_device *dev) if (sector_size == 0) params->block_shift = MODISK_DEF_BLOCK_SHIFT; else - params->block_shift = scst_calc_block_shift(sector_size); + params->block_shift = + scst_calc_block_shift(sector_size); TRACE_DBG("Sector size is %i scsi_level %d(SCSI_2 %d)", sector_size, dev->scsi_dev->scsi_level, SCSI_2); } else { @@ -262,7 +263,7 @@ out: * * Description: Called to detach this device type driver ************************************************************/ -void modisk_detach(struct scst_device *dev) +static void modisk_detach(struct scst_device *dev) { struct modisk_params *params = (struct modisk_params *)dev->dh_priv; @@ -278,7 +279,8 @@ void modisk_detach(struct scst_device *dev) static int modisk_get_block_shift(struct scst_cmd *cmd) { - struct modisk_params *params = (struct modisk_params *)cmd->dev->dh_priv; + struct modisk_params *params = + (struct modisk_params *)cmd->dev->dh_priv; /* * No need for locks here, since *_detach() can not be * called, when there are existing commands. @@ -297,7 +299,7 @@ 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) +static int modisk_parse(struct scst_cmd *cmd) { int res = SCST_CMD_STATE_DEFAULT; @@ -310,7 +312,8 @@ int modisk_parse(struct scst_cmd *cmd) static void modisk_set_block_shift(struct scst_cmd *cmd, int block_shift) { - struct modisk_params *params = (struct modisk_params *)cmd->dev->dh_priv; + struct modisk_params *params = + (struct modisk_params *)cmd->dev->dh_priv; /* * No need for locks here, since *_detach() can not be * called, when there are existing commands. @@ -333,7 +336,7 @@ static void modisk_set_block_shift(struct scst_cmd *cmd, int block_shift) * it is used to extract any necessary information * about a command. ********************************************************************/ -int modisk_done(struct scst_cmd *cmd) +static int modisk_done(struct scst_cmd *cmd) { int res; @@ -355,7 +358,7 @@ int modisk_done(struct scst_cmd *cmd) * Description: Make SCST do nothing for data READs and WRITES. * Intended for raw line performance testing ********************************************************************/ -int modisk_exec(struct scst_cmd *cmd) +static int modisk_exec(struct scst_cmd *cmd) { int res = SCST_EXEC_NOT_COMPLETED, rc; int opcode = cmd->cdb[0]; diff --git a/scst/src/dev_handlers/scst_processor.c b/scst/src/dev_handlers/scst_processor.c index 4f187f44d..7b24e9c04 100644 --- a/scst/src/dev_handlers/scst_processor.c +++ b/scst/src/dev_handlers/scst_processor.c @@ -172,9 +172,9 @@ int processor_done(struct scst_cmd *cmd) TRACE_ENTRY(); /* - * SCST sets good defaults for cmd->is_send_status and cmd->resp_data_len - * based on cmd->status and cmd->data_direction, therefore change - * them only if necessary + * SCST sets good defaults for cmd->is_send_status and + * cmd->resp_data_len based on cmd->status and cmd->data_direction, + * therefore change them only if necessary. */ #if 0 diff --git a/scst/src/dev_handlers/scst_raid.c b/scst/src/dev_handlers/scst_raid.c index 746ba0a2f..38a38cb82 100644 --- a/scst/src/dev_handlers/scst_raid.c +++ b/scst/src/dev_handlers/scst_raid.c @@ -142,7 +142,7 @@ void raid_detach(struct scst_device *dev) * * Note: Not all states are allowed on return ********************************************************************/ -int raid_parse(struct scst_cmd *cmd) +static int raid_parse(struct scst_cmd *cmd) { int res = SCST_CMD_STATE_DEFAULT; @@ -172,9 +172,9 @@ int raid_done(struct scst_cmd *cmd) TRACE_ENTRY(); /* - * SCST sets good defaults for cmd->is_send_status and cmd->resp_data_len - * based on cmd->status and cmd->data_direction, therefore change - * them only if necessary + * SCST sets good defaults for cmd->is_send_status and + * cmd->resp_data_len based on cmd->status and cmd->data_direction, + * therefore change them only if necessary. */ #if 0 diff --git a/scst/src/dev_handlers/scst_tape.c b/scst/src/dev_handlers/scst_tape.c index e80a03709..0422e5d0c 100644 --- a/scst/src/dev_handlers/scst_tape.c +++ b/scst/src/dev_handlers/scst_tape.c @@ -142,7 +142,7 @@ module_exit(exit_scst_tape_driver); * * Description: *************************************************************/ -int tape_attach(struct scst_device *dev) +static int tape_attach(struct scst_device *dev) { int res = 0; int retries; @@ -255,7 +255,7 @@ out: * * Description: Called to detach this device type driver ************************************************************/ -void tape_detach(struct scst_device *dev) +static void tape_detach(struct scst_device *dev) { struct tape_params *params = (struct tape_params *)dev->dh_priv; @@ -290,7 +290,7 @@ 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) +static int tape_parse(struct scst_cmd *cmd) { int res = SCST_CMD_STATE_DEFAULT; @@ -323,7 +323,7 @@ static void tape_set_block_size(struct scst_cmd *cmd, int block_size) * it is used to extract any necessary information * about a command. ********************************************************************/ -int tape_done(struct scst_cmd *cmd) +static int tape_done(struct scst_cmd *cmd) { int opcode = cmd->cdb[0]; int status = cmd->status; @@ -342,7 +342,8 @@ int tape_done(struct scst_cmd *cmd) /* EOF, EOM, or ILI */ int TransferLength, Residue = 0; if ((cmd->sense[2] & 0x0f) == BLANK_CHECK) - cmd->sense[2] &= 0xcf; /* No need for EOM in this case */ + /* No need for EOM in this case */ + cmd->sense[2] &= 0xcf; TransferLength = ((cmd->cdb[2] << 16) | (cmd->cdb[3] << 8) | cmd->cdb[4]); /* Compute the residual count */ @@ -353,9 +354,9 @@ int tape_done(struct scst_cmd *cmd) cmd->sense[6]); } TRACE_DBG("Checking the sense key " - "sn[2]=%x cmd->cdb[0,1]=%x,%x TransLen/Resid %d/%d", - (int) cmd->sense[2], cmd->cdb[0], cmd->cdb[1], - TransferLength, Residue); + "sn[2]=%x cmd->cdb[0,1]=%x,%x TransLen/Resid" + " %d/%d", (int)cmd->sense[2], cmd->cdb[0], + cmd->cdb[1], TransferLength, Residue); if (TransferLength > Residue) { int resp_data_len = TransferLength - Residue; if (cmd->cdb[1] & SCST_TRANSFER_LEN_TYPE_FIXED) { @@ -364,7 +365,8 @@ int tape_done(struct scst_cmd *cmd) * *_detach() can not be called, when * there are existing commands. */ - params = (struct tape_params *)cmd->dev->dh_priv; + params = (struct tape_params *) + cmd->dev->dh_priv; resp_data_len *= params->block_size; } scst_set_resp_data_len(cmd, resp_data_len); @@ -389,7 +391,7 @@ int tape_done(struct scst_cmd *cmd) * Description: Make SCST do nothing for data READs and WRITES. * Intended for raw line performance testing ********************************************************************/ -int tape_exec(struct scst_cmd *cmd) +static int tape_exec(struct scst_cmd *cmd) { int res = SCST_EXEC_NOT_COMPLETED, rc; int opcode = cmd->cdb[0]; diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index dd08614c7..ce51be0de 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -564,7 +564,8 @@ static int dev_user_alloc_sg(struct scst_user_cmd *ucmd, int cached_buff) if (ll < 10) { PRINT_INFO("Unable to complete command due to " "SG IO count limitation (requested %d, " - "available %d, tgt lim %d)", cmd->sg_cnt, + "available %d, tgt lim %d)", + cmd->sg_cnt, cmd->tgt_dev->max_sg_cnt, cmd->tgt->sg_tablesize); ll++; @@ -611,7 +612,8 @@ static int dev_user_alloc_space(struct scst_user_cmd *ucmd) if (unlikely(ucmd->cmd->data_buf_tgt_alloc)) { PRINT_ERROR("Target driver %s requested own memory " "allocation", ucmd->cmd->tgtt->name); - scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); res = scst_get_cmd_abnormal_done_state(cmd); goto out; } @@ -908,7 +910,7 @@ static void dev_user_on_free_cmd(struct scst_cmd *cmd) ucmd->buff_cached, ucmd->ubuff); ucmd->cmd = NULL; - if ((cmd->data_direction == SCST_DATA_WRITE) && (ucmd->buf_ucmd != NULL)) + if (cmd->data_direction == SCST_DATA_WRITE && ucmd->buf_ucmd != NULL) ucmd->buf_ucmd->buf_dirty = 1; if (ucmd->dev->on_free_cmd_type == SCST_USER_ON_FREE_CMD_IGNORE) { @@ -1027,12 +1029,13 @@ static void dev_user_add_to_ready(struct scst_user_cmd *ucmd) &dev->ready_cmd_list); do_wake = 1; } else if ((ucmd->cmd != NULL) && - unlikely((ucmd->cmd->queue_type == SCST_CMD_QUEUE_HEAD_OF_QUEUE))) { + unlikely((ucmd->cmd->queue_type == SCST_CMD_QUEUE_HEAD_OF_QUEUE))) { TRACE_DBG("Adding HQ ucmd %p to head of ready cmd list", ucmd); list_add(&ucmd->ready_cmd_list_entry, &dev->ready_cmd_list); } else { TRACE_DBG("Adding ucmd %p to ready cmd list", ucmd); - list_add_tail(&ucmd->ready_cmd_list_entry, &dev->ready_cmd_list); + list_add_tail(&ucmd->ready_cmd_list_entry, + &dev->ready_cmd_list); } if (do_wake) { @@ -1061,8 +1064,9 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff, ucmd->num_data_pages = num_pg; - ucmd->data_pages = kmalloc(sizeof(*ucmd->data_pages)*ucmd->num_data_pages, - GFP_KERNEL); + ucmd->data_pages = + kmalloc(sizeof(*ucmd->data_pages) * ucmd->num_data_pages, + GFP_KERNEL); if (ucmd->data_pages == NULL) { TRACE(TRACE_OUT_OF_MEM, "Unable to allocate data_pages array " "(num_data_pages=%d)", ucmd->num_data_pages); @@ -1070,8 +1074,8 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff, goto out_nomem; } - TRACE_MEM("Mapping buffer (ucmd %p, ubuff %lx, ucmd->num_data_pages %d, " - "first_page_offset %d, len %d)", ucmd, ubuff, + TRACE_MEM("Mapping buffer (ucmd %p, ubuff %lx, ucmd->num_data_pages %d," + " first_page_offset %d, len %d)", ucmd, ubuff, ucmd->num_data_pages, (int)(ubuff & ~PAGE_MASK), ucmd->cmd->bufflen); @@ -1129,12 +1133,14 @@ static int dev_user_process_reply_alloc(struct scst_user_cmd *ucmd, if (ucmd->buff_cached) { if (unlikely((reply->alloc_reply.pbuf & ~PAGE_MASK) != 0)) { PRINT_ERROR("Supplied pbuf %llx isn't " - "page aligned", reply->alloc_reply.pbuf); + "page aligned", + reply->alloc_reply.pbuf); goto out_hwerr; } pages = cmd->sg_cnt; } else - pages = calc_num_pg(reply->alloc_reply.pbuf, cmd->bufflen); + pages = calc_num_pg(reply->alloc_reply.pbuf, + cmd->bufflen); res = dev_user_map_buf(ucmd, reply->alloc_reply.pbuf, pages); } else { scst_set_busy(ucmd->cmd); @@ -1340,7 +1346,8 @@ out_hwerr_res_set: ucmd_put(ucmd); goto out; } else { - scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); goto out_compl; } @@ -1531,7 +1538,8 @@ static struct scst_user_cmd *__dev_user_get_next_cmd(struct list_head *cmd_list) again: u = NULL; if (!list_empty(cmd_list)) { - u = list_entry(cmd_list->next, typeof(*u), ready_cmd_list_entry); + u = list_entry(cmd_list->next, typeof(*u), + ready_cmd_list_entry); TRACE_DBG("Found ready ucmd %p", u); list_del(&u->ready_cmd_list_entry); @@ -1736,7 +1744,8 @@ static long dev_user_ioctl(struct file *file, unsigned int cmd, res = -ENOMEM; goto out; } - res = copy_from_user(dev_desc, (void __user *)arg, sizeof(*dev_desc)); + res = copy_from_user(dev_desc, (void __user *)arg, + sizeof(*dev_desc)); if (res < 0) { kfree(dev_desc); goto out; @@ -1826,7 +1835,7 @@ out: } /* - * Called under cmd_lists.cmd_list_lock, but can drop it inside, then reaquire. + * Called under cmd_lists.cmd_list_lock, but can drop it inside, then reacquire. */ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, unsigned long *flags) @@ -1856,7 +1865,7 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, scst_set_busy(ucmd->cmd); else scst_set_cmd_error(ucmd->cmd, - SCST_LOAD_SENSE(scst_sense_hardw_error)); + SCST_LOAD_SENSE(scst_sense_hardw_error)); } scst_set_cmd_abnormal_done_state(ucmd->cmd); @@ -1868,7 +1877,8 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, case UCMD_STATE_EXECING: if (flags != NULL) - spin_unlock_irqrestore(&dev->cmd_lists.cmd_list_lock, *flags); + spin_unlock_irqrestore(&dev->cmd_lists.cmd_list_lock, + *flags); else spin_unlock_irq(&dev->cmd_lists.cmd_list_lock); @@ -1881,14 +1891,15 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, scst_set_busy(ucmd->cmd); else scst_set_cmd_error(ucmd->cmd, - SCST_LOAD_SENSE(scst_sense_hardw_error)); + SCST_LOAD_SENSE(scst_sense_hardw_error)); } ucmd->cmd->scst_cmd_done(ucmd->cmd, SCST_CMD_STATE_DEFAULT); /* !! At this point cmd and ucmd can be already freed !! */ if (flags != NULL) - spin_lock_irqsave(&dev->cmd_lists.cmd_list_lock, *flags); + spin_lock_irqsave(&dev->cmd_lists.cmd_list_lock, + *flags); else spin_lock_irq(&dev->cmd_lists.cmd_list_lock); break; @@ -1900,7 +1911,8 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, case UCMD_STATE_DETACH_SESS: { if (flags != NULL) - spin_unlock_irqrestore(&dev->cmd_lists.cmd_list_lock, *flags); + spin_unlock_irqrestore(&dev->cmd_lists.cmd_list_lock, + *flags); else spin_unlock_irq(&dev->cmd_lists.cmd_list_lock); @@ -1914,7 +1926,8 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, break; case UCMD_STATE_TM_EXECING: - dev_user_process_reply_tm_exec(ucmd, SCST_MGMT_STATUS_FAILED); + dev_user_process_reply_tm_exec(ucmd, + SCST_MGMT_STATUS_FAILED); break; case UCMD_STATE_ATTACH_SESS: @@ -1924,7 +1937,8 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy, } if (flags != NULL) - spin_lock_irqsave(&dev->cmd_lists.cmd_list_lock, *flags); + spin_lock_irqsave(&dev->cmd_lists.cmd_list_lock, + *flags); else spin_lock_irq(&dev->cmd_lists.cmd_list_lock); break; @@ -2048,7 +2062,8 @@ static int dev_user_task_mgmt_fn(struct scst_mgmt_cmd *mcmd, struct scst_tgt_dev *tgt_dev) { struct scst_user_cmd *ucmd; - struct scst_user_dev *dev = (struct scst_user_dev *)tgt_dev->dev->dh_priv; + struct scst_user_dev *dev = + (struct scst_user_dev *)tgt_dev->dev->dh_priv; struct scst_user_cmd *ucmd_to_abort = NULL; TRACE_ENTRY(); @@ -2104,7 +2119,8 @@ static int dev_user_task_mgmt_fn(struct scst_mgmt_cmd *mcmd, ucmd->user_cmd.tm_cmd.cmd_sn_set = mcmd->cmd_sn_set; if (mcmd->cmd_to_abort != NULL) { - ucmd_to_abort = (struct scst_user_cmd *)mcmd->cmd_to_abort->dh_priv; + ucmd_to_abort = + (struct scst_user_cmd *)mcmd->cmd_to_abort->dh_priv; if (ucmd_to_abort != NULL) ucmd->user_cmd.tm_cmd.cmd_h_to_abort = ucmd_to_abort->h; } @@ -2372,8 +2388,9 @@ static int dev_user_check_version(const struct scst_user_dev_desc *dev_desc) char ver[sizeof(DEV_USER_VERSION)+1]; int res; - res = copy_from_user(ver, (void __user *)(unsigned long)dev_desc->version_str, - sizeof(ver)); + res = copy_from_user(ver, + (void __user *)(unsigned long)dev_desc->version_str, + sizeof(ver)); if (res < 0) { PRINT_ERROR("%s", "Unable to get version string"); goto out; @@ -2410,7 +2427,8 @@ static int dev_user_register_dev(struct file *file, case TYPE_ROM: case TYPE_MOD: if (dev_desc->block_size == 0) { - PRINT_ERROR("Wrong block size %d", dev_desc->block_size); + PRINT_ERROR("Wrong block size %d", + dev_desc->block_size); res = -EINVAL; goto out; } @@ -2565,10 +2583,10 @@ static int __dev_user_set_opt(struct scst_user_dev *dev, opt->on_free_cmd_type, opt->memory_reuse_type, opt->partial_transfers_type, opt->partial_len); - if ((opt->parse_type > SCST_USER_MAX_PARSE_OPT) || - (opt->on_free_cmd_type > SCST_USER_MAX_ON_FREE_CMD_OPT) || - (opt->memory_reuse_type > SCST_USER_MAX_MEM_REUSE_OPT) || - (opt->partial_transfers_type > SCST_USER_MAX_PARTIAL_TRANSFERS_OPT)) { + if (opt->parse_type > SCST_USER_MAX_PARSE_OPT || + opt->on_free_cmd_type > SCST_USER_MAX_ON_FREE_CMD_OPT || + opt->memory_reuse_type > SCST_USER_MAX_MEM_REUSE_OPT || + opt->partial_transfers_type > SCST_USER_MAX_PARTIAL_TRANSFERS_OPT) { PRINT_ERROR("%s", "Invalid option"); res = -EINVAL; goto out; @@ -2579,9 +2597,10 @@ static int __dev_user_set_opt(struct scst_user_dev *dev, ((opt->queue_alg != SCST_CONTR_MODE_QUEUE_ALG_RESTRICTED_REORDER) && (opt->queue_alg != SCST_CONTR_MODE_QUEUE_ALG_UNRESTRICTED_REORDER)) || (opt->swp > 1) || (opt->tas > 1) || (opt->has_own_order_mgmt > 1)) { - PRINT_ERROR("Invalid SCSI option (tst %x, queue_alg %x, swp %x, " - "tas %x, has_own_order_mgmt %x)", opt->tst, - opt->queue_alg, opt->swp, opt->tas, opt->has_own_order_mgmt); + PRINT_ERROR("Invalid SCSI option (tst %x, queue_alg %x, swp %x," + " tas %x, has_own_order_mgmt %x)", opt->tst, + opt->queue_alg, opt->swp, opt->tas, + opt->has_own_order_mgmt); res = -EINVAL; goto out; } @@ -2965,7 +2984,8 @@ static int __init init_scst_user(void) res = register_chrdev(DEV_USER_MAJOR, DEV_USER_NAME, &dev_user_fops); if (res) { - PRINT_ERROR("Unable to get major %d for SCSI tapes", DEV_USER_MAJOR); + PRINT_ERROR("Unable to get major %d for SCSI tapes", + DEV_USER_MAJOR); goto out_class; } @@ -2977,7 +2997,8 @@ static int __init init_scst_user(void) goto out_chrdev; } #else - dev = device_create(dev_user_sysfs_class, NULL, MKDEV(DEV_USER_MAJOR, 0), + dev = device_create(dev_user_sysfs_class, NULL, + MKDEV(DEV_USER_MAJOR, 0), #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) NULL, #endif diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 8e46ad09f..4eb1e5634 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -95,12 +95,12 @@ static struct scst_proc_log vdisk_proc_local_trace_tbl[] = * Since we can't control backstorage device's reordering, we have to always * report unrestricted reordering. */ -#define DEF_QUEUE_ALG_WT SCST_CONTR_MODE_QUEUE_ALG_UNRESTRICTED_REORDER -#define DEF_QUEUE_ALG SCST_CONTR_MODE_QUEUE_ALG_UNRESTRICTED_REORDER -#define DEF_SWP 0 -#define DEF_TAS 0 +#define DEF_QUEUE_ALG_WT SCST_CONTR_MODE_QUEUE_ALG_UNRESTRICTED_REORDER +#define DEF_QUEUE_ALG SCST_CONTR_MODE_QUEUE_ALG_UNRESTRICTED_REORDER +#define DEF_SWP 0 +#define DEF_TAS 0 -#define VDISK_PROC_HELP "help" +#define VDISK_PROC_HELP "help" static unsigned int random_values[256] = { 9862592UL, 3744545211UL, 2348289082UL, 4036111983UL, @@ -245,10 +245,12 @@ static void vdisk_exec_read_toc(struct scst_cmd *cmd); static void vdisk_exec_prevent_allow_medium_removal(struct scst_cmd *cmd); static int vdisk_fsync(struct scst_vdisk_thr *thr, loff_t loff, loff_t len, struct scst_cmd *cmd); -static int vdisk_read_proc(struct seq_file *seq, struct scst_dev_type *dev_type); +static int vdisk_read_proc(struct seq_file *seq, + struct scst_dev_type *dev_type); static int vdisk_write_proc(char *buffer, char **start, off_t offset, int length, int *eof, struct scst_dev_type *dev_type); -static int vcdrom_read_proc(struct seq_file *seq, struct scst_dev_type *dev_type); +static int vcdrom_read_proc(struct seq_file *seq, + struct scst_dev_type *dev_type); static int vcdrom_write_proc(char *buffer, char **start, off_t offset, int length, int *eof, struct scst_dev_type *dev_type); static int vdisk_task_mgmt_fn(struct scst_mgmt_cmd *mcmd, @@ -379,7 +381,8 @@ static struct file *vdisk_open(const struct scst_vdisk_dev *virt_dev) open_flags |= O_DIRECT; if (virt_dev->wt_flag && !virt_dev->nv_cache) open_flags |= O_SYNC; - TRACE_DBG("Opening file %s, flags 0x%x", virt_dev->file_name, open_flags); + TRACE_DBG("Opening file %s, flags 0x%x", + virt_dev->file_name, open_flags); fd = filp_open(virt_dev->file_name, O_LARGEFILE | open_flags, 0600); TRACE_EXIT(); @@ -448,7 +451,7 @@ static int vdisk_attach(struct scst_device *dev) fd = vdisk_open(virt_dev); if (IS_ERR(fd)) { res = PTR_ERR(fd); - PRINT_ERROR("filp_open(%s) returned an error %d", + PRINT_ERROR("filp_open(%s) returned error %d", virt_dev->file_name, res); goto out; } @@ -460,9 +463,9 @@ static int vdisk_attach(struct scst_device *dev) if ((fd->f_op == NULL) || (fd->f_op->aio_read == NULL) || (fd->f_op->aio_write == NULL)) { #endif - PRINT_ERROR("%s", "Wrong f_op or FS doesn't have " - "required capabilities"); - res = -EINVAL; + PRINT_ERROR("%s", "Wrong f_op or FS doesn't " + "have required capabilities"); + res = -EINVAL; filp_close(fd, NULL); goto out; } @@ -478,7 +481,7 @@ static int vdisk_attach(struct scst_device *dev) } if (S_ISREG(inode->i_mode)) - ; + /* Nothing to do*/; else if (S_ISBLK(inode->i_mode)) inode = inode->i_bdev->bd_inode; else { @@ -496,22 +499,26 @@ static int vdisk_attach(struct scst_device *dev) virt_dev->file_size = 0; if (dev->handler->type == TYPE_DISK) { - virt_dev->nblocks = virt_dev->file_size >> virt_dev->block_shift; + virt_dev->nblocks = + virt_dev->file_size >> virt_dev->block_shift; } else { virt_dev->block_size = DEF_CDROM_BLOCKSIZE; virt_dev->block_shift = DEF_CDROM_BLOCKSIZE_SHIFT; - virt_dev->nblocks = virt_dev->file_size >> DEF_CDROM_BLOCKSIZE_SHIFT; + virt_dev->nblocks = + virt_dev->file_size >> DEF_CDROM_BLOCKSIZE_SHIFT; } if (!virt_dev->cdrom_empty) { PRINT_INFO("Attached SCSI target virtual %s %s " - "(file=\"%s\", fs=%lldMB, bs=%d, nblocks=%lld, cyln=%lld%s)", + "(file=\"%s\", fs=%lldMB, bs=%d, nblocks=%lld," + " cyln=%lld%s)", (dev->handler->type == TYPE_DISK) ? "disk" : "cdrom", virt_dev->name, virt_dev->file_name, virt_dev->file_size >> 20, virt_dev->block_size, (long long unsigned int)virt_dev->nblocks, (long long unsigned int)virt_dev->nblocks/64/32, - virt_dev->nblocks < 64*32 ? " !WARNING! cyln less than 1" : ""); + virt_dev->nblocks < 64*32 + ? " !WARNING! cyln less than 1" : ""); } else { PRINT_INFO("Attached empty SCSI target virtual cdrom %s", virt_dev->name); @@ -562,7 +569,8 @@ static void vdisk_detach(struct scst_device *dev) static void vdisk_free_thr_data(struct scst_thr_data_hdr *d) { - struct scst_vdisk_thr *thr = container_of(d, struct scst_vdisk_thr, hdr); + struct scst_vdisk_thr *thr = + container_of(d, struct scst_vdisk_thr, hdr); TRACE_ENTRY(); @@ -838,10 +846,12 @@ static int vdisk_do_job(struct scst_cmd *cmd) enum scst_cmd_queue_type last_queue_type = ftgt_dev->last_write_cmd_queue_type; ftgt_dev->last_write_cmd_queue_type = cmd->queue_type; - if (vdisk_need_pre_sync(cmd->queue_type, last_queue_type)) { + if (vdisk_need_pre_sync(cmd->queue_type, + last_queue_type)) { TRACE(TRACE_ORDER, "ORDERED " "WRITE(%d): loff=%lld, data_len=%lld", - cmd->queue_type, (long long unsigned int)loff, + cmd->queue_type, + (long long unsigned int)loff, (long long unsigned int)data_len); do_fsync = 1; if (vdisk_fsync(thr, 0, 0, cmd) != 0) @@ -873,10 +883,12 @@ static int vdisk_do_job(struct scst_cmd *cmd) enum scst_cmd_queue_type last_queue_type = ftgt_dev->last_write_cmd_queue_type; ftgt_dev->last_write_cmd_queue_type = cmd->queue_type; - if (vdisk_need_pre_sync(cmd->queue_type, last_queue_type)) { + if (vdisk_need_pre_sync(cmd->queue_type, + last_queue_type)) { TRACE(TRACE_ORDER, "ORDERED " - "WRITE_VERIFY(%d): loff=%lld, data_len=%lld", - cmd->queue_type, (long long unsigned int)loff, + "WRITE_VERIFY(%d): loff=%lld," + " data_len=%lld", cmd->queue_type, + (long long unsigned int)loff, (long long unsigned int)data_len); do_fsync = 1; if (vdisk_fsync(thr, 0, 0, cmd) != 0) @@ -900,7 +912,8 @@ static int vdisk_do_job(struct scst_cmd *cmd) { int immed = cdb[1] & 0x2; TRACE(TRACE_ORDER, "SYNCHRONIZE_CACHE: " - "loff=%lld, data_len=%lld, immed=%d", (long long unsigned int)loff, + "loff=%lld, data_len=%lld, immed=%d", + (long long unsigned int)loff, (long long unsigned int)data_len, immed); if (immed) { scst_cmd_get(cmd); @@ -1132,8 +1145,10 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) int dev_id_num; char dev_id_str[6]; - for (dev_id_num = 0, i = 0; i < (int)strlen(virt_dev->name); i++) { - unsigned int rv = random_values[(int)(virt_dev->name[i])]; + for (dev_id_num = 0, i = 0; i < (int)strlen(virt_dev->name); + i++) { + unsigned int rv = + random_values[(int)(virt_dev->name[i])]; /* * Device name maximum length = 16, * do some rotating of the bits. @@ -1196,7 +1211,7 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) buf[num + 1] = 0x3; buf[num + 2] = 0x0; buf[num + 3] = 0x8; - buf[num + 4] = 0x51; /* ieee company id=0x123456 (faked) */ + buf[num + 4] = 0x51; /* IEEE OUI=0x123456 (faked) */ buf[num + 5] = 0x23; buf[num + 6] = 0x45; buf[num + 7] = 0x60; @@ -1224,24 +1239,34 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) goto out_put; } - buf[2] = 4; /* Device complies to this standard - SPC-2 */ - buf[3] = 0x12; /* HiSup + data in format specified in SPC-2 */ - buf[4] = 31; /* n - 4 = 35 - 4 = 31 for full 36 byte data */ - buf[6] = 0; buf[7] = 2; /* BQue = 0, CMDQUE = 1 commands queuing supported */ + buf[2] = 4; /* Device complies to this standard - SPC-2 */ + buf[3] = 0x12; /* HiSup + data in format specified in SPC-2 */ + buf[4] = 31; /* n - 4 = 35 - 4 = 31 for full 36 byte data */ + /* BQue = 0, CMDQUE = 1 commands queuing supported */ + buf[6] = 0; buf[7] = 2; - /* 8 byte ASCII Vendor Identification of the target - left aligned */ + /* + * 8 byte ASCII Vendor Identification of the target + * - left aligned. + */ if (virt_dev->blockio) memcpy(&buf[8], SCST_BIO_VENDOR, 8); else memcpy(&buf[8], SCST_FIO_VENDOR, 8); - /* 16 byte ASCII Product Identification of the target - left aligned */ + /* + * 16 byte ASCII Product Identification of the target - left + * aligned. + */ memset(&buf[16], ' ', 16); len = strlen(virt_dev->name); len = len < 16 ? len : 16; memcpy(&buf[16], virt_dev->name, len); - /* 4 byte ASCII Product Revision Level of the target - left aligned */ + /* + * 4 byte ASCII Product Revision Level of the target - left + * aligned. + */ memcpy(&buf[32], SCST_FIO_REV, 4); resp_len = buf[4] + 5; } @@ -1485,7 +1510,8 @@ static void vdisk_exec_mode_sense(struct scst_cmd *cmd) buf[offset + 2] = 0xFF; buf[offset + 3] = 0xFF; } else { - buf[offset + 0] = (nblocks >> (BYTE * 3)) & 0xFF;/* num blks */ + /* num blks */ + buf[offset + 0] = (nblocks >> (BYTE * 3)) & 0xFF; buf[offset + 1] = (nblocks >> (BYTE * 2)) & 0xFF; buf[offset + 2] = (nblocks >> (BYTE * 1)) & 0xFF; buf[offset + 3] = (nblocks >> (BYTE * 0)) & 0xFF; @@ -1863,16 +1889,20 @@ static void vdisk_exec_read_toc(struct scst_cmd *cmd) off = 4; if (cmd->cdb[6] <= 1) { /* Fistr TOC Track Descriptor */ - buffer[off+1] = 0x14; /* ADDR 0x10 - Q Sub-channel encodes current position data - CONTROL 0x04 - Data track, recoreded uninterrupted */ - buffer[off+2] = 0x01; /* Track Number */ + /* ADDR 0x10 - Q Sub-channel encodes current position data + CONTROL 0x04 - Data track, recoreded uninterrupted */ + buffer[off+1] = 0x14; + /* Track Number */ + buffer[off+2] = 0x01; off += 8; } if (!(cmd->cdb[2] & 0x01)) { /* Lead-out area TOC Track Descriptor */ buffer[off+1] = 0x14; - buffer[off+2] = 0xAA; /* Track Number */ - buffer[off+4] = (nblocks >> (BYTE * 3)) & 0xFF; /* Track Start Address */ + /* Track Number */ + buffer[off+2] = 0xAA; + /* Track Start Address */ + buffer[off+4] = (nblocks >> (BYTE * 3)) & 0xFF; buffer[off+5] = (nblocks >> (BYTE * 2)) & 0xFF; buffer[off+6] = (nblocks >> (BYTE * 1)) & 0xFF; buffer[off+7] = (nblocks >> (BYTE * 0)) & 0xFF; @@ -1956,7 +1986,7 @@ static struct iovec *vdisk_alloc_iv(struct scst_cmd *cmd, iv_count = scst_get_buf_count(cmd); if (iv_count > thr->iv_count) { kfree(thr->iv); - thr->iv = kmalloc(sizeof(*thr->iv) * iv_count, + thr->iv = kmalloc(sizeof(*thr->iv) * iv_count, scst_cmd_atomic(cmd) ? GFP_ATOMIC : GFP_KERNEL); if (thr->iv == NULL) { PRINT_ERROR("Unable to allocate iv (%d)", iv_count); @@ -2066,14 +2096,16 @@ static void vdisk_exec_read(struct scst_cmd *cmd, PRINT_ERROR("lseek trouble %lld != %lld", (long long unsigned int)err, (long long unsigned int)loff); - scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); goto out_set_fs; } /* READ */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) err = fd->f_op->readv(fd, iv, iv_count, &fd->f_pos); #else - err = do_sync_readv_writev(fd, iv, iv_count, full_len, &fd->f_pos, fd->f_op->aio_read); + err = do_sync_readv_writev(fd, iv, iv_count, full_len, + &fd->f_pos, fd->f_op->aio_read); #endif } @@ -2167,8 +2199,8 @@ restart: #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) err = fd->f_op->writev(fd, eiv, eiv_count, &fd->f_pos); #else - err = do_sync_readv_writev(fd, iv, iv_count, full_len, &fd->f_pos, - fd->f_op->aio_write); + err = do_sync_readv_writev(fd, iv, iv_count, full_len, + &fd->f_pos, fd->f_op->aio_write); #endif } @@ -2451,7 +2483,8 @@ static void vdisk_exec_verify(struct scst_cmd *cmd, PRINT_ERROR("lseek trouble %lld != %lld", (long long unsigned int)err, (long long unsigned int)loff); - scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error)); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_hardw_error)); goto out_set_fs; } } @@ -2478,7 +2511,8 @@ static void vdisk_exec_verify(struct scst_cmd *cmd, TRACE_DBG("Verify: length %zd - len_mem %zd", length, len_mem); if (!virt_dev->nullio) - err = fd->f_op->read(fd, (char *)mem_verify, len_mem, &fd->f_pos); + err = fd->f_op->read(fd, (char *)mem_verify, len_mem, + &fd->f_pos); else err = len_mem; if ((err < 0) || (err < len_mem)) { @@ -2579,7 +2613,7 @@ static int vdisk_read_proc(struct seq_file *seq, struct scst_dev_type *dev_type) } seq_printf(seq, "%-17s %-11s %-11s %-15s %s\n", - "Name", "Size(MB)", "Block size", "Options", "File name"); + "Name", "Size(MB)", "Block size", "Options", "File name"); list_for_each_entry(virt_dev, &vdisk_dev_list, vdisk_dev_list_entry) { int c; @@ -2806,15 +2840,15 @@ static int vdisk_write_proc(char *buffer, char **start, off_t offset, TRACE_DBG("%s", "READ_ONLY"); } else if (!strncmp("O_DIRECT", p, 8)) { p += 8; - #if 0 +#if 0 virt_dev->o_direct_flag = 1; TRACE_DBG("%s", "O_DIRECT"); - #else +#else PRINT_INFO("%s flag doesn't currently" " work, ignoring it, use fileio_tgt " "in O_DIRECT mode instead", "O_DIRECT"); - #endif +#endif } else if (!strncmp("NULLIO", p, 6)) { p += 6; virt_dev->nullio = 1; @@ -2866,12 +2900,12 @@ static int vdisk_write_proc(char *buffer, char **start, off_t offset, } else if (virt_dev->nullio) { vdisk_report_registering("NULLIO", virt_dev); virt_dev->virt_id = - scst_register_virtual_device(&vdisk_null_devtype, + scst_register_virtual_device(&vdisk_null_devtype, virt_dev->name); } else { vdisk_report_registering("FILEIO", virt_dev); virt_dev->virt_id = - scst_register_virtual_device(&vdisk_file_devtype, + scst_register_virtual_device(&vdisk_file_devtype, virt_dev->name); } if (virt_dev->virt_id < 0) { @@ -3172,8 +3206,8 @@ static int vcdrom_change(char *p, char *name) if (!virt_dev->cdrom_empty) { PRINT_INFO("Changed SCSI target virtual cdrom %s " - "(file=\"%s\", fs=%lldMB, bs=%d, nblocks=%lld, cyln=%lld%s)", - virt_dev->name, virt_dev->file_name, + "(file=\"%s\", fs=%lldMB, bs=%d, nblocks=%lld," + " cyln=%lld%s)", virt_dev->name, virt_dev->file_name, virt_dev->file_size >> 20, virt_dev->block_size, (long long unsigned int)virt_dev->nblocks, (long long unsigned int)virt_dev->nblocks/64/32, @@ -3206,7 +3240,8 @@ out_free_resume: /* * Called when a file in the /proc/VCDROM_NAME/VCDROM_NAME is read */ -static int vcdrom_read_proc(struct seq_file *seq, struct scst_dev_type *dev_type) +static int vcdrom_read_proc(struct seq_file *seq, + struct scst_dev_type *dev_type) { int res = 0; struct scst_vdisk_dev *virt_dev; @@ -3340,7 +3375,8 @@ static int vdisk_proc_help_build(struct scst_dev_type *dev_type) vdisk_help_proc_data.data = (dev_type->type == TYPE_DISK) ? vdisk_proc_help_string : vcdrom_proc_help_string; - p = scst_create_proc_entry(root, VDISK_PROC_HELP, &vdisk_help_proc_data); + p = scst_create_proc_entry(root, VDISK_PROC_HELP, + &vdisk_help_proc_data); if (p == NULL) { PRINT_ERROR("Not enough memory to register dev " "handler %s entry %s in /proc",