diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index a801a8bb5..48b70d7c8 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -2859,6 +2859,9 @@ static void blockio_exec_rw(struct scst_cmd *cmd, struct scst_vdisk_thr *thr, struct scst_blockio_work *blockio_work; int bios = 0; gfp_t gfp_mask = (cmd->noio_mem_alloc ? GFP_NOIO : GFP_KERNEL); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) + struct blk_plug plug; +#endif TRACE_ENTRY(); @@ -2964,6 +2967,9 @@ static void blockio_exec_rw(struct scst_cmd *cmd, struct scst_vdisk_thr *thr, /* +1 to prevent erroneous too early command completion */ atomic_set(&blockio_work->bios_inflight, bios+1); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) + blk_start_plug(&plug); +#endif while (hbio) { bio = hbio; hbio = hbio->bi_next; @@ -2971,8 +2977,12 @@ static void blockio_exec_rw(struct scst_cmd *cmd, struct scst_vdisk_thr *thr, submit_bio((write != 0), bio); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) if (q && q->unplug_fn) q->unplug_fn(q); +#else + blk_finish_plug(&plug); +#endif blockio_check_finish(blockio_work); diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index f0b0f0495..412122c3e 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -568,28 +568,33 @@ out: #ifndef CONFIG_SCST_PROC /* Abstract vfs_unlink & path_put for different kernel versions */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) static inline void scst_pr_vfs_unlink_and_put(struct nameidata *nd) { -#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); -#else - vfs_unlink(nd->path.dentry->d_parent->d_inode, - nd->path.dentry); - path_put(&nd->path); -#endif } +#else +static inline void scst_pr_vfs_unlink_and_put(struct path *path) +{ + vfs_unlink(path->dentry->d_parent->d_inode, path->dentry); + path_put(path); +} +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) static inline void scst_pr_path_put(struct nameidata *nd) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) dput(nd->dentry); mntput(nd->mnt); -#else - path_put(&nd->path); -#endif } +#else +static inline void scst_pr_path_put(struct path *path) +{ + path_put(path); +} +#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) static int scst_pr_vfs_fsync(struct file *file, loff_t loff, loff_t len) @@ -902,27 +907,59 @@ out: return res; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) \ + && LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 26) +static int kern_path(const char *name, unsigned int flags, struct path *path) +{ + struct nameidata nd; + int res = do_path_lookup(AT_FDCWD, name, flags, &nd); + if (!res) + *path = nd.path; + return res; +} +#endif + static void scst_pr_remove_device_files(struct scst_tgt_dev *tgt_dev) { int res = 0; struct scst_device *dev = tgt_dev->dev; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) struct nameidata nd; +#else + struct path path; +#endif mm_segment_t old_fs = get_fs(); TRACE_ENTRY(); set_fs(KERNEL_DS); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) res = path_lookup(dev->pr_file_name, 0, &nd); +#else + res = kern_path(dev->pr_file_name, 0, &path); +#endif if (!res) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) scst_pr_vfs_unlink_and_put(&nd); +#else + scst_pr_vfs_unlink_and_put(&path); +#endif else TRACE_DBG("Unable to lookup file '%s' - error %d", dev->pr_file_name, res); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) res = path_lookup(dev->pr_file_name1, 0, &nd); +#else + res = kern_path(dev->pr_file_name1, 0, &path); +#endif if (!res) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) scst_pr_vfs_unlink_and_put(&nd); +#else + scst_pr_vfs_unlink_and_put(&path); +#endif else TRACE_DBG("Unable to lookup file '%s' - error %d", dev->pr_file_name1, res); @@ -1105,12 +1142,24 @@ write_error: write_error_close: filp_close(file, NULL); { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) struct nameidata nd; +#else + struct path path; +#endif int rc; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) rc = path_lookup(dev->pr_file_name, 0, &nd); +#else + rc = kern_path(dev->pr_file_name, 0, &path); +#endif if (!rc) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) scst_pr_vfs_unlink_and_put(&nd); +#else + scst_pr_vfs_unlink_and_put(&path); +#endif else TRACE_PR("Unable to lookup '%s' - error %d", dev->pr_file_name, rc); @@ -1121,14 +1170,22 @@ write_error_close: static int scst_pr_check_pr_path(void) { int res; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) struct nameidata nd; +#else + struct path path; +#endif mm_segment_t old_fs = get_fs(); TRACE_ENTRY(); set_fs(KERNEL_DS); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) res = path_lookup(SCST_PR_DIR, 0, &nd); +#else + res = kern_path(SCST_PR_DIR, 0, &path); +#endif if (res != 0) { PRINT_ERROR("Unable to find %s (err %d), you should create " "this directory manually or reinstall SCST", @@ -1136,7 +1193,11 @@ static int scst_pr_check_pr_path(void) goto out_setfs; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) scst_pr_path_put(&nd); +#else + scst_pr_path_put(&path); +#endif out_setfs: set_fs(old_fs); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index bcbb7bea5..3950b0709 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -2629,9 +2629,11 @@ static inline int scst_real_exec(struct scst_cmd *cmd) res = scst_do_real_exec(cmd); if (likely(res == SCST_EXEC_COMPLETED)) { scst_post_exec_sn(cmd, true); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) if (cmd->dev->scsi_dev != NULL) generic_unplug_device( cmd->dev->scsi_dev->request_queue); +#endif } else sBUG(); @@ -2734,7 +2736,6 @@ static int scst_exec(struct scst_cmd **active_cmd) { struct scst_cmd *cmd = *active_cmd; struct scst_cmd *ref_cmd; - struct scst_device *dev = cmd->dev; int res = SCST_CMD_STATE_RES_CONT_NEXT, count; TRACE_ENTRY(); @@ -2795,8 +2796,10 @@ done: if (count == 0) goto out_put; - if (dev->scsi_dev != NULL) - generic_unplug_device(dev->scsi_dev->request_queue); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) + if (cmd->dev->scsi_dev != NULL) + generic_unplug_device(cmd->dev->scsi_dev->request_queue); +#endif out_put: __scst_cmd_put(ref_cmd);