diff --git a/scst/include/backport.h b/scst/include/backport.h index c28298034..4b5dcbc81 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -88,8 +88,10 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q) typedef cpumask_t cpumask_var_t[1]; #define cpumask_bits(maskp) ((maskp)->bits) #ifdef CONFIG_CPUMASK_OFFSTACK -/* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also, - * not all bits may be allocated. */ +/* + * Assuming NR_CPUS is huge, a runtime limit is more efficient. Also, + * not all bits may be allocated. + */ #define nr_cpumask_bits nr_cpu_ids #else #define nr_cpumask_bits NR_CPUS @@ -341,7 +343,7 @@ static inline bool list_entry_in_list(const struct list_head *entry) /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) -#define lockdep_assert_held(l) do { (void)(l); } while (0) +#define lockdep_assert_held(l) (void)(l) #endif /* */ diff --git a/scst/include/scst.h b/scst/include/scst.h index 4dc8db2ff..c1dffdd98 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1819,7 +1819,7 @@ struct scst_tgt { /* Divide two 64-bit numbers with reasonably accuracy. */ static inline void __scst_time_per_cmd(uint64_t *t, uint64_t n) { - unsigned shift; + unsigned int shift; if (!n) return; diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index f670ad632..30c8f5115 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -481,7 +481,7 @@ static inline int scst_sense_response_code(const uint8_t *sense) * From . See also commit * d30a2605be9d5132d95944916e8f578fcfe4f976. */ -#define BLKDISCARD _IO(0x12,119) +#define BLKDISCARD _IO(0x12, 119) #endif /************************************************************* diff --git a/scst/src/dev_handlers/scst_cdrom.c b/scst/src/dev_handlers/scst_cdrom.c index ce6d3d1fc..92697b5bb 100644 --- a/scst/src/dev_handlers/scst_cdrom.c +++ b/scst/src/dev_handlers/scst_cdrom.c @@ -99,7 +99,7 @@ static int cdrom_attach(struct scst_device *dev) rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, buffer_size, sense_buffer, SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) , NULL #endif ); diff --git a/scst/src/dev_handlers/scst_dev_handler.h b/scst/src/dev_handlers/scst_dev_handler.h index 5e65480f6..6810224f8 100644 --- a/scst/src/dev_handlers/scst_dev_handler.h +++ b/scst/src/dev_handlers/scst_dev_handler.h @@ -81,6 +81,7 @@ static int scst_dev_handler_build_std_proc(struct scst_dev_type *dev_type) /* Create the proc file entry for the device */ /* Workaround to keep /proc ABI intact */ const char *name; + if (strcmp(dev_type->name, "vdisk_fileio") == 0) name = "vdisk"; else diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index 13edb3528..a6f00be1f 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -196,7 +196,7 @@ static int disk_attach(struct scst_device *dev) rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, buffer_size, sense_buffer, SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) , NULL #endif ); diff --git a/scst/src/dev_handlers/scst_modisk.c b/scst/src/dev_handlers/scst_modisk.c index fe87e39dc..5dd8271c0 100644 --- a/scst/src/dev_handlers/scst_modisk.c +++ b/scst/src/dev_handlers/scst_modisk.c @@ -200,7 +200,7 @@ static int modisk_attach(struct scst_device *dev) rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer, buffer_size, sense_buffer, SCST_GENERIC_MODISK_REG_TIMEOUT, 3, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) , NULL #endif ); diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 40b1a902b..643e0ade8 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -4048,11 +4048,13 @@ static int dev_user_read_proc(struct seq_file *seq, struct scst_dev_type *dev_ty list_for_each_entry(dev, &dev_list, dev_list_entry) { int i; + seq_printf(seq, "Device %s commands:\n", dev->name); spin_lock_irqsave(&dev->udev_cmd_threads.cmd_list_lock, flags); for (i = 0; i < (int)ARRAY_SIZE(dev->ucmd_hash); i++) { struct list_head *head = &dev->ucmd_hash[i]; struct scst_user_cmd *ucmd; + list_for_each_entry(ucmd, head, hash_list_entry) { seq_printf(seq, "ucmd %p (state %x, ref %d), " "sent_to_user %d, seen_by_user %d, " diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index ceb0c26a5..a667c4f34 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -22,6 +22,9 @@ * GNU General Public License for more details. */ +#ifndef INSIDE_KERNEL_TREE +#include +#endif #include #include #include @@ -34,14 +37,15 @@ #include #include #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) +#include +#else #include +#endif #include #include #include #include -#ifndef INSIDE_KERNEL_TREE -#include -#endif #include #include #include @@ -3318,7 +3322,8 @@ err: * @small_sg_size: size of @small_sg * @p_sg_cnt: pointer to an int where the sg vector size will be written */ -static struct scatterlist *alloc_sg(size_t size, unsigned off, gfp_t gfp_mask, +static struct scatterlist *alloc_sg(size_t size, unsigned int off, + gfp_t gfp_mask, struct scatterlist *small_sg, int small_sg_size, int *p_sg_cnt) { @@ -6447,6 +6452,7 @@ static inline void blockio_check_finish(struct scst_blockio_work *blockio_work) static void blockio_bio_destructor(struct bio *bio) { struct scst_blockio_work *blockio_work = bio->bi_private; + bio_free(bio, blockio_work->bioset); blockio_check_finish(blockio_work); } @@ -7000,6 +7006,7 @@ struct bio_priv_sync { static void blockio_bio_destructor_sync(struct bio *bio) { struct bio_priv_sync *s = bio->bi_private; + bio_free(bio, s->bs); complete(&s->c1); } @@ -7053,7 +7060,7 @@ static void blockio_end_sync_io(struct bio *bio) * Increments *@loff with the number of bytes transferred upon success. */ static ssize_t blockio_rw_sync(struct scst_vdisk_dev *virt_dev, void *buf, - size_t len, loff_t *loff, unsigned rw) + size_t len, loff_t *loff, unsigned int rw) { struct bio_priv_sync s = { COMPLETION_INITIALIZER_ONSTACK(s.c), 0, @@ -7068,7 +7075,7 @@ static ssize_t blockio_rw_sync(struct scst_vdisk_dev *virt_dev, void *buf, void *p; struct page *q; int max_nr_vecs, rc; - unsigned bytes, off; + unsigned int bytes, off; ssize_t ret = -ENOMEM; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)) && (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 6, 0)) bool submitted = false; @@ -10114,6 +10121,7 @@ static int vdisk_write_proc(char *buffer, char **start, off_t offset, if (isdigit(*p)) { char *pp; + block_size = simple_strtoul(p, &pp, 0); p = pp; if ((*p != '\0') && !isspace(*p)) { diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index bd64f477d..80ca7e8cb 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -3025,9 +3025,8 @@ static int scst_cm_add_to_descr_list(struct scst_cmd *ec_cmd, fcmd = __scst_create_prepare_internal_cmd(ec_cmd->cdb, ec_cmd->cdb_len, SCST_CMD_QUEUE_SIMPLE, tgt_dev, GFP_KERNEL, true); - if (fcmd == NULL) { + if (fcmd == NULL) goto out_enomem_free_e; - } fcmd->expected_data_direction = ec_cmd->expected_data_direction; fcmd->expected_transfer_len_full = ec_cmd->expected_transfer_len_full; @@ -3073,8 +3072,9 @@ skip_fcmd_create: if (tp != NULL) { if (((unsigned long)t->cm_fcmd->dev) <= ((unsigned long)tp->cm_fcmd->dev)) { list_for_each_entry(t, &priv->cm_sorted_devs_list, cm_sorted_devs_list_entry) { - printk(KERN_EMERG "%s: t %p, cm dev %p\n", __func__, - t, t->cm_fcmd->dev); + pr_emerg("%s: t %p, cm dev %p\n", + __func__, t, + t->cm_fcmd->dev); } sBUG(); break; diff --git a/scst/src/scst_dlm.c b/scst/src/scst_dlm.c index b8f2e890f..5b4f79cf5 100644 --- a/scst/src/scst_dlm.c +++ b/scst/src/scst_dlm.c @@ -525,11 +525,11 @@ struct scst_dlm_readdir_context { /* Append the name of each directory entry to the buffer @arg points to. */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) static int scst_dlm_filldir(void *arg, const char *name_arg, int name_len, - loff_t curr_pos, u64 inode, unsigned dtype) + loff_t curr_pos, u64 inode, unsigned int dtype) #else static int scst_dlm_filldir(struct dir_context *arg, const char *name_arg, int name_len, loff_t curr_pos, u64 inode, - unsigned dtype) + unsigned int dtype) #endif { char *p, *q, name[64]; diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index 11de3c1be..49805dbd7 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -27,7 +27,7 @@ static struct class *scst_event_sysfs_class; static int scst_event_major; #define SCST_MAX_EVENTS 2048 -#define SCST_MAX_PAYLOAD 3*1024 +#define SCST_MAX_PAYLOAD (3*1024) #define SCST_DEFAULT_EVENT_TIMEOUT (60*HZ) struct scst_event_priv { diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 4e4cd6bbd..973c7f1f1 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4533,7 +4533,7 @@ out: */ int scst_acg_repl_lun(struct scst_acg *acg, struct kobject *parent, struct scst_device *dev, uint64_t lun, - unsigned flags) + unsigned int flags) { struct scst_acg_dev *acg_dev; bool del_gen_ua = false; @@ -6759,7 +6759,7 @@ static void scst_send_release(struct scst_device *dev) "SCSI mid-level"); rc = scsi_execute(scsi_dev, cdb, SCST_DATA_NONE, NULL, 0, sense, 15, 0, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) , NULL #endif ); @@ -13172,7 +13172,7 @@ int scst_obtain_device_parameters(struct scst_device *dev, TRACE(TRACE_SCSI, "%s", "Doing internal MODE_SENSE"); rc = scsi_execute(dev->scsi_dev, cmd, SCST_DATA_READ, buffer, sizeof(buffer), sense_buffer, 15, 0, 0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) , NULL #endif ); @@ -14472,7 +14472,7 @@ out_unlock: #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) void scst_vfs_unlink_and_put(struct nameidata *nd) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) vfs_unlink(nd->dentry->d_parent->d_inode, nd->dentry); dput(nd->dentry); mntput(nd->mnt); @@ -14500,7 +14500,7 @@ void scst_vfs_unlink_and_put(struct path *path) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) void scst_path_put(struct nameidata *nd) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) dput(nd->dentry); mntput(nd->mnt); #else diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index b8fafe2f8..dbf6431b0 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -725,7 +725,7 @@ static const char *const scst_cmd_state_name[] = { [SCST_CMD_STATE_XMIT_WAIT] = "XMIT_WAIT", }; -char *scst_get_cmd_state_name(char *name, int len, unsigned state) +char *scst_get_cmd_state_name(char *name, int len, unsigned int state) { if (state < ARRAY_SIZE(scst_cmd_state_name) && scst_cmd_state_name[state]) @@ -804,7 +804,7 @@ static const char *const scst_tm_fn_name[] = { [SCST_PR_ABORT_ALL] = "PR_ABORT_ALL", }; -char *scst_get_tm_fn_name(char *name, int len, unsigned fn) +char *scst_get_tm_fn_name(char *name, int len, unsigned int fn) { if (fn < ARRAY_SIZE(scst_tm_fn_name) && scst_tm_fn_name[fn]) strlcpy(name, scst_tm_fn_name[fn], len); @@ -823,7 +823,7 @@ static const char *const scst_mcmd_state_name[] = { [SCST_MCMD_STATE_FINISHED] = "FINISHED", }; -char *scst_get_mcmd_state_name(char *name, int len, unsigned state) +char *scst_get_mcmd_state_name(char *name, int len, unsigned int state) { if (state < ARRAY_SIZE(scst_mcmd_state_name) && scst_mcmd_state_name[state]) diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 1cc85396b..5ac78d112 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -47,7 +47,7 @@ #include #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) #include #endif diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 5a5c63a30..694d9e395 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -277,9 +277,9 @@ extern void scst_tgt_dev_stop_threads(struct scst_tgt_dev *tgt_dev); extern struct scst_dev_type scst_null_devtype; -char *scst_get_cmd_state_name(char *name, int len, unsigned state); -char *scst_get_mcmd_state_name(char *name, int len, unsigned state); -char *scst_get_tm_fn_name(char *name, int len, unsigned fn); +char *scst_get_cmd_state_name(char *name, int len, unsigned int state); +char *scst_get_mcmd_state_name(char *name, int len, unsigned int state); +char *scst_get_tm_fn_name(char *name, int len, unsigned int fn); extern struct scst_cmd *__scst_check_deferred_commands_locked( struct scst_order_data *order_data, bool return_first); @@ -375,7 +375,7 @@ int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, bool gen_report_luns_changed); int scst_acg_repl_lun(struct scst_acg *acg, struct kobject *parent, struct scst_device *dev, uint64_t lun, - unsigned flags); + unsigned int flags); int scst_acg_add_acn(struct scst_acg *acg, const char *name); #ifdef CONFIG_SCST_PROC @@ -428,7 +428,7 @@ static inline int scst_dlm_new_lockspace(const char *name, int namelen, #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) static inline int scst_exec_req(struct scsi_device *sdev, const unsigned char *cmd, int cmd_len, int data_direction, - struct scatterlist *sgl, unsigned bufflen, unsigned nents, + struct scatterlist *sgl, unsigned int bufflen, unsigned int nents, int timeout, int retries, void *privdata, void (*done)(void *, char *, int, int), gfp_t gfp) { diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index 9d44a2782..ebd12d5e8 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -235,6 +235,7 @@ static DEFINE_MUTEX(scst_proc_mutex); static int strcasecmp(const char *s1, const char *s2) { int c1, c2; + do { c1 = tolower(*s1++); c2 = tolower(*s2++); @@ -246,6 +247,7 @@ static int strcasecmp(const char *s1, const char *s2) static int strncasecmp(const char *s1, const char *s2, size_t n) { int c1, c2; + do { c1 = tolower(*s1++); c2 = tolower(*s2++); @@ -595,6 +597,7 @@ static int lat_info_show(struct seq_file *seq, void *v) struct list_head *head = &sess->sess_tgt_dev_list[t]; struct scst_tgt_dev *tgt_dev; + list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) { @@ -763,6 +766,7 @@ static ssize_t scst_proc_scsi_tgt_gen_write_lat(struct file *file, struct list_head *head = &sess->sess_tgt_dev_list[t]; struct scst_tgt_dev *tgt_dev; + list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) { tgt_dev->scst_time = 0; @@ -2106,6 +2110,7 @@ static ssize_t scst_proc_groups_devices_write(struct file *file, * procfs is now obsoleted. */ struct scst_acg_dev *a; + list_for_each_entry(a, &acg->acg_dev_list, acg_dev_list_entry) { if (a->dev == dev) { rc = scst_acg_del_lun(acg, a->lun, true); @@ -2254,6 +2259,7 @@ static ssize_t scst_proc_groups_names_write(struct file *file, { struct scst_acg *a, *new_acg = NULL; char *name = p; + p = pp; while (!isspace(*pp) && *pp != '\0') pp++; @@ -2429,10 +2435,12 @@ static int scst_sessions_info_show(struct seq_file *seq, void *v) list_for_each_entry(sess, &acg->acg_sess_list, acg_sess_list_entry) { int active_cmds = 0, t; + for (t = SESS_TGT_DEV_LIST_HASH_SIZE-1; t >= 0; t--) { struct list_head *head = &sess->sess_tgt_dev_list[t]; struct scst_tgt_dev *tgt_dev; + list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) { active_cmds += atomic_read(&tgt_dev->tgt_dev_cmd_count); diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 73abe11f4..5556b5735 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -2802,7 +2802,7 @@ static int scst_tgt_sysfs_##attr##_show_work_fn( \ int res; \ uint64_t c = 0; \ \ - BUILD_BUG_ON((unsigned)(dir) >= ARRAY_SIZE(sess->io_stats)); \ + BUILD_BUG_ON((unsigned int)(dir) >= ARRAY_SIZE(sess->io_stats));\ \ res = mutex_lock_interruptible(&scst_mutex); \ if (res) \ @@ -3046,7 +3046,7 @@ static ssize_t scst_dev_sysfs_type_show(struct kobject *kobj, dev = container_of(kobj, struct scst_device, dev_kobj); pos = scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, "%d - %s\n", dev->type, - (unsigned)dev->type >= ARRAY_SIZE(scst_dev_handler_types) ? + (unsigned int)dev->type >= ARRAY_SIZE(scst_dev_handler_types) ? "unknown" : scst_dev_handler_types[dev->type]); return pos; @@ -5744,7 +5744,7 @@ static ssize_t scst_devt_type_show(struct kobject *kobj, devt = container_of(kobj, struct scst_dev_type, devt_kobj); pos = sprintf(buf, "%d - %s\n", devt->type, - (unsigned)devt->type >= ARRAY_SIZE(scst_dev_handler_types) ? + (unsigned int)devt->type >= ARRAY_SIZE(scst_dev_handler_types) ? "unknown" : scst_dev_handler_types[devt->type]); return pos; diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 47698297f..52aa7066c 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -5210,6 +5210,7 @@ static void scst_ioctx_get(struct scst_cmd_threads *p_cmd_threads) #warning IO context sharing functionality disabled on 3.5 kernels due to bug in them. \ See "http://lkml.org/lkml/2012/7/17/515" for more details. static int q; + if (q == 0) { q++; PRINT_WARNING("IO context sharing functionality "