From 0e04ac351aa3248c8c1c0d9b03206bd102e39517 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 14 Dec 2006 18:10:39 +0000 Subject: [PATCH] Update to work on 2.6.19. Mostly done by Ming Zhang. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@60 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla_attr.c | 26 ++++++++--- qla2x00t/qla_def.h | 5 +++ qla2x00t/qla_gbl.h | 6 +++ qla2x00t/qla_inline.h | 4 ++ qla2x00t/qla_isr.c | 15 +++++++ scst/include/scst_debug.h | 2 +- scst/src/dev_handlers/scst_fileio.c | 67 +++++++++++++++++++++++++++-- scst/src/scst.c | 7 +++ 8 files changed, 123 insertions(+), 9 deletions(-) diff --git a/qla2x00t/qla_attr.c b/qla2x00t/qla_attr.c index 3c0759335..5077276b7 100644 --- a/qla2x00t/qla_attr.c +++ b/qla2x00t/qla_attr.c @@ -681,13 +681,29 @@ void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) { struct Scsi_Host *host = ha->host; + int ret; - sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); - sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); - sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); - sysfs_create_bin_file(&host->shost_gendev.kobj, + ret = sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); + if (ret) + qla_printk(KERN_INFO, ha, "sysfs_create_bin_file() failed: " + "%d\n", ret); + ret = sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); + if (ret) + qla_printk(KERN_INFO, ha, "sysfs_create_bin_file() failed: " + "%d\n", ret); + ret = sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); + if (ret) + qla_printk(KERN_INFO, ha, "sysfs_create_bin_file() failed: " + "%d\n", ret); + ret = sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_ctl_attr); - sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_vpd_attr); + if (ret) + qla_printk(KERN_INFO, ha, "sysfs_create_bin_file() failed: " + "%d\n", ret); + ret = sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_vpd_attr); + if (ret) + qla_printk(KERN_INFO, ha, "sysfs_create_bin_file() failed: " + "%d\n", ret); } void diff --git a/qla2x00t/qla_def.h b/qla2x00t/qla_def.h index 623dda911..47e0fd302 100644 --- a/qla2x00t/qla_def.h +++ b/qla2x00t/qla_def.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -2116,7 +2117,11 @@ struct isp_operations { char * (*pci_info_str) (struct scsi_qla_host *, char *); char * (*fw_version_str) (struct scsi_qla_host *, char *); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) irqreturn_t (*intr_handler) (int, void *, struct pt_regs *); +#else + irq_handler_t intr_handler; +#endif void (*enable_intrs) (struct scsi_qla_host *); void (*disable_intrs) (struct scsi_qla_host *); diff --git a/qla2x00t/qla_gbl.h b/qla2x00t/qla_gbl.h index 91e83e2c1..efd285be7 100644 --- a/qla2x00t/qla_gbl.h +++ b/qla2x00t/qla_gbl.h @@ -213,9 +213,15 @@ qla2x00_stop_firmware(scsi_qla_host_t *); /* * Global Function Prototypes in qla_isr.c source file. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) extern irqreturn_t qla2100_intr_handler(int, void *, struct pt_regs *); extern irqreturn_t qla2300_intr_handler(int, void *, struct pt_regs *); extern irqreturn_t qla24xx_intr_handler(int, void *, struct pt_regs *); +#else +extern irqreturn_t qla2100_intr_handler(int, void *); +extern irqreturn_t qla2300_intr_handler(int, void *); +extern irqreturn_t qla24xx_intr_handler(int, void *); +#endif extern void qla2x00_process_response_queue(struct scsi_qla_host *); extern void qla24xx_process_response_queue(struct scsi_qla_host *); diff --git a/qla2x00t/qla_inline.h b/qla2x00t/qla_inline.h index 45007ee58..de71b9a82 100644 --- a/qla2x00t/qla_inline.h +++ b/qla2x00t/qla_inline.h @@ -104,7 +104,11 @@ static __inline__ void qla2x00_poll(scsi_qla_host_t *); static inline void qla2x00_poll(scsi_qla_host_t *ha) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) ha->isp_ops.intr_handler(0, ha, NULL); +#else + ha->isp_ops.intr_handler(0, ha); +#endif } static __inline__ void qla2x00_check_fabric_devices(scsi_qla_host_t *); diff --git a/qla2x00t/qla_isr.c b/qla2x00t/qla_isr.c index d803ae3b4..d2e55f6c0 100644 --- a/qla2x00t/qla_isr.c +++ b/qla2x00t/qla_isr.c @@ -32,8 +32,13 @@ static void qla24xx_ms_entry(scsi_qla_host_t *, struct ct_entry_24xx *); * * Returns handled flag. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) irqreturn_t qla2100_intr_handler(int irq, void *dev_id, struct pt_regs *regs) +#else +irqreturn_t +qla2100_intr_handler(int irq, void *dev_id) +#endif { scsi_qla_host_t *ha; struct device_reg_2xxx __iomem *reg; @@ -112,8 +117,13 @@ qla2100_intr_handler(int irq, void *dev_id, struct pt_regs *regs) * * Returns handled flag. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) irqreturn_t qla2300_intr_handler(int irq, void *dev_id, struct pt_regs *regs) +#else +irqreturn_t +qla2300_intr_handler(int irq, void *dev_id) +#endif { scsi_qla_host_t *ha; struct device_reg_2xxx __iomem *reg; @@ -1571,8 +1581,13 @@ qla24xx_process_response_queue(struct scsi_qla_host *ha) * * Returns handled flag. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) irqreturn_t qla24xx_intr_handler(int irq, void *dev_id, struct pt_regs *regs) +#else +irqreturn_t +qla24xx_intr_handler(int irq, void *dev_id) +#endif { scsi_qla_host_t *ha; struct device_reg_24xx __iomem *reg; diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index 339a9ab0d..cea7f9633 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -20,7 +20,7 @@ #ifndef __SCST_DEBUG_H #define __SCST_DEBUG_H -#include /* for CONFIG_* */ +#include /* for CONFIG_* */ #if !defined(EXTRACHECKS) && defined(CONFIG_SCSI_TARGET_EXTRACHECKS) #define EXTRACHECKS diff --git a/scst/src/dev_handlers/scst_fileio.c b/scst/src/dev_handlers/scst_fileio.c index c471ad905..205c84ded 100644 --- a/scst/src/dev_handlers/scst_fileio.c +++ b/scst/src/dev_handlers/scst_fileio.c @@ -293,15 +293,20 @@ static int fileio_attach(struct scst_device *dev) goto out; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if ((fd->f_op == NULL) || (fd->f_op->readv == NULL) || (fd->f_op->writev == NULL)) +#else + if ((fd->f_op == NULL) || (fd->f_op->aio_read == NULL) || + (fd->f_op->aio_write == NULL)) +#endif { PRINT_ERROR_PR("%s", "Wrong f_op or FS doesn't have " "required capabilities"); res = -EINVAL; goto out_close_file; } - + /* seek to end */ old_fs = get_fs(); set_fs(get_ds()); @@ -1194,7 +1199,7 @@ static void fileio_exec_inquiry(struct scst_cmd *cmd) } len = scnprintf(dev_id_str, 6, "%d", dev_id_num); TRACE_DBG("num %d, str <%s>, len %d", - dev_id_num,dev_id_str, len); + dev_id_num, dev_id_str, len); if (0 == cmd->cdb[2]) { /* supported vital product data pages */ buf[3] = 3; buf[4] = 0x0; /* this page */ @@ -1928,6 +1933,48 @@ out: return ftgt_dev->iv; } +/* + * copied from /fs/read_write.* + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19) +static void wait_on_retry_sync_kiocb(struct kiocb *iocb) +{ + set_current_state(TASK_UNINTERRUPTIBLE); + if (!kiocbIsKicked(iocb)) + schedule(); + else + kiocbClearKicked(iocb); + __set_current_state(TASK_RUNNING); +} + +typedef ssize_t (*iov_fn_t)(struct kiocb *, const struct iovec *, + unsigned long, loff_t); + +ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov, + unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn) +{ + struct kiocb kiocb; + ssize_t ret; + + init_sync_kiocb(&kiocb, filp); + kiocb.ki_pos = *ppos; + kiocb.ki_left = len; + kiocb.ki_nbytes = len; + + for (;;) { + ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos); + if (ret != -EIOCBRETRY) + break; + wait_on_retry_sync_kiocb(&kiocb); + } + + if (ret == -EIOCBQUEUED) + ret = wait_on_sync_kiocb(&kiocb); + *ppos = kiocb.ki_pos; + return ret; +} +#endif + static void fileio_exec_read(struct scst_cmd *cmd, loff_t loff) { mm_segment_t old_fs; @@ -1988,7 +2035,12 @@ static void fileio_exec_read(struct scst_cmd *cmd, loff_t loff) if (virt_dev->nullio) err = full_len; else +#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); +#endif + if ((err < 0) || (err < full_len)) { PRINT_ERROR_PR("readv() returned %Ld from %zd", (uint64_t)err, full_len); @@ -2076,7 +2128,13 @@ restart: if (virt_dev->nullio) err = full_len; else +#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); +#endif + if (err < 0) { PRINT_ERROR_PR("write() returned %Ld from %zd", (uint64_t)err, full_len); @@ -2778,14 +2836,17 @@ static int cdrom_fileio_change(char *p, char *name) virt_dev->file_name, res); goto out_free; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) if ((fd->f_op == NULL) || (fd->f_op->readv == NULL)) { +#else + if ((fd->f_op == NULL) || (fd->f_op->aio_read == NULL)) { +#endif PRINT_ERROR_PR("%s", "Wrong f_op or FS doesn't " "have required capabilities"); res = -EINVAL; filp_close(fd, NULL); goto out_free; } - /* seek to end */ old_fs = get_fs(); set_fs(get_ds()); diff --git a/scst/src/scst.c b/scst/src/scst.c index 7c04650bd..142445b16 100644 --- a/scst/src/scst.c +++ b/scst/src/scst.c @@ -1249,6 +1249,7 @@ static void __exit exit_scst(void) scst_sgv_pools_deinit(&scst_sgv); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) #define DEINIT_CACHEP(p, s) do { \ if (kmem_cache_destroy(p)) { \ PRINT_INFO_PR("kmem_cache_destroy of %s returned an "\ @@ -1256,6 +1257,12 @@ static void __exit exit_scst(void) } \ p = NULL; \ } while (0) +#else +#define DEINIT_CACHEP(p, s) do { \ + kmem_cache_destroy(p); \ + p = NULL; \ + } while (0) +#endif mempool_destroy(scst_mgmt_mempool); mempool_destroy(scst_ua_mempool);