From c6906d2ac2eec33eaf7ef79837c83bc2e308cbc7 Mon Sep 17 00:00:00 2001 From: Chesnokov Gleb Date: Sat, 11 Dec 2021 01:53:02 +0300 Subject: [PATCH] scst: Remove support for kernel versions before 3.10 The SCST has dropped support for kernels older than 3.10.0 (RHEL 7 / Centos 7) since SCST v3.6. --- scst/include/scst.h | 33 +++---------------- scst/include/scst_const.h | 46 +------------------------- scst/include/scst_debug.h | 10 ------ scst/include/scst_event.h | 4 --- scst/src/scst_debug.c | 6 ---- scst/src/scst_event.c | 36 -------------------- scst/src/scst_main.c | 54 ------------------------------ scst/src/scst_mem.c | 34 ------------------- scst/src/scst_mem.h | 4 --- scst/src/scst_pres.c | 23 +------------ scst/src/scst_priv.h | 43 ------------------------ scst/src/scst_sysfs.c | 69 ++------------------------------------- 12 files changed, 8 insertions(+), 354 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index 3442bf2fb..cc894ad12 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1874,11 +1874,7 @@ struct scst_session { /* List entry for the sessions list inside ACG */ struct list_head acg_sess_list_entry; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)) struct delayed_work hw_pending_work; -#else - struct work_struct hw_pending_work; -#endif /* Name of attached initiator */ const char *initiator_name; @@ -1923,11 +1919,7 @@ struct scst_session { */ struct list_head sess_cm_list_id_list; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) - struct work_struct sess_cm_list_id_cleanup_work; -#else struct delayed_work sess_cm_list_id_cleanup_work; -#endif /* sysfs release completion */ struct completion *sess_kobj_release_cmpl; @@ -5169,12 +5161,11 @@ static inline gfp_t scst_cmd_get_gfp_mask(struct scst_cmd *cmd) } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) && defined(CONFIG_LOCKDEP) +#if defined(CONFIG_LOCKDEP) extern struct lockdep_map scst_suspend_dep_map; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) && \ - defined(CONFIG_DEBUG_LOCK_ALLOC) +#if defined(CONFIG_DEBUG_LOCK_ALLOC) #define scst_assert_activity_suspended() \ WARN_ON(debug_locks && !lock_is_held(&scst_suspend_dep_map)) #else @@ -5223,13 +5214,9 @@ struct scst_trace_log { extern struct mutex scst_mutex; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)) const struct sysfs_ops *scst_sysfs_get_sysfs_ops(void); -#else -struct sysfs_ops *scst_sysfs_get_sysfs_ops(void); -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) && defined(CONFIG_LOCKDEP) +#if defined(CONFIG_LOCKDEP) #define SCST_SET_DEP_MAP(work, dm) ((work)->dep_map = (dm)) #define SCST_KOBJECT_PUT_AND_WAIT(kobj, category, c, dep_map) \ scst_kobject_put_and_wait(kobj, category, c, dep_map) @@ -5541,11 +5528,9 @@ int scst_sysfs_queue_wait_work(struct scst_sysfs_work_item *work); void scst_sysfs_work_get(struct scst_sysfs_work_item *work); void scst_sysfs_work_put(struct scst_sysfs_work_item *work); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) #ifdef CONFIG_LOCKDEP extern struct lockdep_map scst_dev_dep_map; #endif -#endif char *scst_get_next_lexem(char **token_str); @@ -5557,10 +5542,8 @@ void scst_deinit_threads(struct scst_cmd_threads *cmd_threads); void scst_pass_through_cmd_done(void *data, char *sense, int result, int resid); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, void (*done)(void *data, char *sense, int result, int resid)); -#endif int scst_get_file_mode(const char *path); bool scst_parent_dir_exists(const char *path); @@ -5599,16 +5582,11 @@ void scst_write_same(struct scst_cmd *cmd, struct scst_data_descriptor *where); scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ NULL /* sshdr */, timeout, retries, flags, \ 0 /* rq_flags */, NULL /* resid */) -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) -#define scst_scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ - timeout, retries, flags) \ - scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ - timeout, retries, flags, NULL /* resid */) #else #define scst_scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ timeout, retries, flags) \ scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \ - timeout, retries, flags) + timeout, retries, flags, NULL /* resid */) #endif __be64 scst_pack_lun(const uint64_t lun, enum scst_lun_addr_method addr_method); @@ -5624,9 +5602,6 @@ int scst_read_file_transactional(const char *name, const char *name1, int scst_write_file_transactional(const char *name, const char *name1, const char *signature, int signature_len, const uint8_t *buf, int size); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) -void scst_path_put(struct nameidata *nd); -#endif int scst_remove_file(const char *name); void scst_set_tp_soft_threshold_reached_UA(struct scst_tgt_dev *tgt_dev); diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index 2bbb00b48..9b9d42aaf 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -356,15 +356,7 @@ static inline int scst_sense_response_code(const uint8_t *sense) #define INIT_ELEMENT_STATUS 0x07 #define INIT_ELEMENT_STATUS_RANGE 0x37 #define PREVENT_ALLOW_MEDIUM 0x1E -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 38) \ - && (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 <= 5) -#define READ_ATTRIBUTE 0x8C -#endif #define REQUEST_VOLUME_ADDRESS 0xB5 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 38) \ - && (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 <= 5) -#define WRITE_ATTRIBUTE 0x8D -#endif #if (!defined(__KERNEL__) || LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)) &&\ !defined(WRITE_VERIFY_16) #define WRITE_VERIFY_16 0x8E @@ -373,8 +365,7 @@ static inline int scst_sense_response_code(const uint8_t *sense) #ifndef VERIFY_12 #define VERIFY_12 0xAF #endif -#if !defined(GENERATING_UPSTREAM_PATCH) || \ - LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 38) +#if !defined(GENERATING_UPSTREAM_PATCH) /* * The constants below have been defined in the kernel header * and hence are not needed when this header file is included in kernel code. @@ -385,9 +376,6 @@ static inline int scst_sense_response_code(const uint8_t *sense) /* Upstream commit 93aae17a (v2.6.38) */ #define GET_EVENT_STATUS_NOTIFICATION 0x4a #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) -#define VARIABLE_LENGTH_CMD 0x7f -#endif #ifndef READ_16 #define READ_16 0x88 #endif @@ -397,27 +385,11 @@ static inline int scst_sense_response_code(const uint8_t *sense) #ifndef VERIFY_16 #define VERIFY_16 0x8f #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 38) -#ifndef MI_REPORT_IDENTIFYING_INFORMATION -#define MI_REPORT_IDENTIFYING_INFORMATION 0x05 -#endif -#ifndef MI_REPORT_SUPPORTED_OPERATION_CODES -#define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c -#endif -#ifndef MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS -#define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d -#endif -#endif #ifndef SAI_READ_CAPACITY_16 /* values for service action in */ #define SAI_READ_CAPACITY_16 0x10 #endif #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) -#ifndef SAI_GET_LBA_STATUS -#define SAI_GET_LBA_STATUS 0x12 -#endif -#endif #ifndef GENERATING_UPSTREAM_PATCH #ifndef REPORT_LUNS #define REPORT_LUNS 0xa0 @@ -440,14 +412,6 @@ static inline int scst_sense_response_code(const uint8_t *sense) #define SYNCHRONIZE_CACHE_16 0x91 #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) -/* - * From . See also commit - * f57e4502cea471c69782d4790c71d8414ab49a9d. - */ -#define UNMAP 0x42 -#endif - /* Subcodes of VARIABLE_LENGTH_CMD (0x7F) */ #define SUBCODE_READ_32 0x09 #define SUBCODE_VERIFY_32 0x0a @@ -475,14 +439,6 @@ static inline int scst_sense_response_code(const uint8_t *sense) #endif #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) -/* - * From . See also commit - * d30a2605be9d5132d95944916e8f578fcfe4f976. - */ -#define BLKDISCARD _IO(0x12, 119) -#endif - /************************************************************* ** SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft ** T10/1561-D Revision 4 Draft dated 7th November 2002. diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index b789252cd..8f5f4ecb8 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -21,19 +21,9 @@ #ifndef __SCST_DEBUG_H #define __SCST_DEBUG_H -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32) -#include /* for CONFIG_* */ -#else #include /* for CONFIG_* */ -#endif - -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 19) #include /* for WARN_ON_ONCE */ -#endif - -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27) #include -#endif #ifdef INSIDE_KERNEL_TREE #include diff --git a/scst/include/scst_event.h b/scst/include/scst_event.h index f18b1ea91..7ee705c63 100644 --- a/scst/include/scst_event.h +++ b/scst/include/scst_event.h @@ -61,11 +61,7 @@ struct scst_event_entry { int *pqueued_events_cnt; union { struct work_struct scst_event_queue_work; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) - struct work_struct event_timeout_work; -#else struct delayed_work event_timeout_work; -#endif }; struct scst_event event; diff --git a/scst/src/scst_debug.c b/scst/src/scst_debug.c index ab47cdfe3..d211eb87e 100644 --- a/scst/src/scst_debug.c +++ b/scst/src/scst_debug.c @@ -22,9 +22,7 @@ #ifndef INSIDE_KERNEL_TREE #include #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) #include -#endif #ifdef INSIDE_KERNEL_TREE #include @@ -44,9 +42,6 @@ static DEFINE_SPINLOCK(trace_buf_lock); static inline int get_current_tid(void) { /* Code should be the same as in sys_gettid() */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) - return current->pid; -#else if (in_interrupt()) { /* * Unfortunately, task_pid_vnr() isn't IRQ-safe, so otherwise @@ -55,7 +50,6 @@ static inline int get_current_tid(void) return current->pid; } return task_pid_vnr(current); -#endif } /* diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index 724a0e712..0a172f82f 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -95,16 +95,10 @@ out: return res; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) -static void scst_event_timeout_fn(void *p) -{ - struct scst_event_entry *event_entry = p; -#else static void scst_event_timeout_fn(struct work_struct *work) { struct scst_event_entry *event_entry = container_of(work, struct scst_event_entry, event_timeout_work.work); -#endif TRACE_ENTRY(); @@ -211,14 +205,8 @@ static void __scst_event_queue(struct scst_event_entry *event_entry) break; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) - INIT_WORK(&new_event_entry->event_timeout_work, - scst_event_timeout_fn, - new_event_entry); -#else INIT_DELAYED_WORK(&new_event_entry->event_timeout_work, scst_event_timeout_fn); -#endif if (new_event_entry->event_notify_fn != NULL) { new_event_entry->event.event_id = atomic_inc_return(&base_event_id); if (new_event_entry->event_timeout == 0) @@ -264,16 +252,10 @@ done: return; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) -static void scst_event_queue_work_fn(void *p) -{ - struct scst_event_entry *e = p; -#else static void scst_event_queue_work_fn(struct work_struct *work) { struct scst_event_entry *e = container_of(work, struct scst_event_entry, scst_event_queue_work); -#endif TRACE_ENTRY(); @@ -289,11 +271,7 @@ void scst_event_queue(uint32_t event_code, const char *issuer_name, { TRACE_ENTRY(); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) - INIT_WORK(&e->scst_event_queue_work, scst_event_queue_work_fn, e); -#else INIT_WORK(&e->scst_event_queue_work, scst_event_queue_work_fn); -#endif TRACE_DBG("Scheduling event entry %p", e); @@ -1123,11 +1101,7 @@ static const struct file_operations scst_event_fops = { int scst_event_init(void) { int res = 0; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 21) - struct class_device *class_member; -#else struct device *dev; -#endif TRACE_ENTRY(); @@ -1145,15 +1119,6 @@ int scst_event_init(void) goto out_class; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 21) - class_member = class_device_create(scst_event_sysfs_class, NULL, - MKDEV(scst_event_major, 0), NULL, - SCST_EVENT_NAME); - if (IS_ERR(class_member)) { - res = PTR_ERR(class_member); - goto out_chrdev; - } -#else dev = device_create(scst_event_sysfs_class, NULL, MKDEV(scst_event_major, 0), NULL, @@ -1162,7 +1127,6 @@ int scst_event_init(void) res = PTR_ERR(dev); goto out_chrdev; } -#endif #ifdef CONFIG_EVENTS_WAIT_TEST sysfs_create_file(kernel_kobj, &event_wait_test_attr.attr); diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 078568996..4b57d5793 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -47,12 +47,6 @@ option or use a 64-bit configuration instead. See README file for \ details. #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) && \ - !defined(CONFIG_SCST_STRICT_SERIALIZING) -#warning CONFIG_SCST_STRICT_SERIALIZING has not been defined. \ -Pass-through dev handlers will not work. -#endif - /* ** SCST global variables. They are all uninitialized to have their layout in ** memory be exactly as specified. Otherwise compiler puts zero-initialized @@ -112,9 +106,7 @@ struct kmem_cache *scst_cmd_cachep; unsigned long scst_trace_flag; #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) unsigned long scst_poll_ns = SCST_DEF_POLL_NS; -#endif int scst_max_tasklet_cmd = SCST_DEF_MAX_TASKLET_CMD; @@ -151,13 +143,11 @@ static struct task_struct *scst_mgmt_cmd_thread; * several threads simultaneously. */ static struct mutex scst_suspend_mutex; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) #ifdef CONFIG_LOCKDEP static struct lock_class_key scst_suspend_key; struct lockdep_map scst_suspend_dep_map = STATIC_LOCKDEP_MAP_INIT("scst_suspend_activity", &scst_suspend_key); #endif -#endif /* Protected by scst_suspend_mutex */ static int suspend_count; @@ -880,9 +870,7 @@ int scst_suspend_activity(unsigned long timeout) TRACE_ENTRY(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) rwlock_acquire_read(&scst_suspend_dep_map, 0, 0, _RET_IP_); -#endif if (timeout != SCST_SUSPEND_TIMEOUT_UNLIMITED) { res = mutex_lock_interruptible(&scst_suspend_mutex); @@ -914,9 +902,7 @@ int scst_suspend_activity(unsigned long timeout) scst_get_cmd_counter()); rep = true; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) lock_contended(&scst_suspend_dep_map, _RET_IP_); -#endif } res = scst_susp_wait(timeout); @@ -954,12 +940,10 @@ out_up: mutex_unlock(&scst_suspend_mutex); out: -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) if (res == 0) lock_acquired(&scst_suspend_dep_map, _RET_IP_); else rwlock_release(&scst_suspend_dep_map, _RET_IP_); -#endif TRACE_EXIT_RES(res); return res; @@ -1033,9 +1017,7 @@ void scst_resume_activity(void) { TRACE_ENTRY(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) rwlock_release(&scst_suspend_dep_map, _RET_IP_); -#endif mutex_lock(&scst_suspend_mutex); __scst_resume_activity(); @@ -1527,19 +1509,6 @@ int __scst_register_dev_driver(struct scst_dev_type *dev_type, if (res != 0) goto out; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) && \ - !defined(CONFIG_SCST_STRICT_SERIALIZING) - if (dev_type->exec == NULL) { - PRINT_ERROR("Pass-through dev handlers (handler \"%s\") not " - "supported. Consider applying on your kernel patch " - "scst_exec_req_fifo- or define " - "CONFIG_SCST_STRICT_SERIALIZING", dev_type->name); - res = -EINVAL; - goto out; - } -#endif - - res = mutex_lock_interruptible(&scst_mutex); if (res != 0) goto out; @@ -2191,22 +2160,14 @@ unsigned int scst_get_setup_id(void) } EXPORT_SYMBOL_GPL(scst_get_setup_id); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) -static int scst_add(struct class_device *cdev, struct class_interface *intf) -#else static int scst_add(struct device *cdev, struct class_interface *intf) -#endif { struct scsi_device *scsidp; int res = 0; TRACE_ENTRY(); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) - scsidp = to_scsi_device(cdev->dev); -#else scsidp = to_scsi_device(cdev->parent); -#endif if ((scsidp->host->hostt->name == NULL) || (strcmp(scsidp->host->hostt->name, SCST_LOCAL_NAME) != 0)) @@ -2216,21 +2177,13 @@ static int scst_add(struct device *cdev, struct class_interface *intf) return res; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) -static void scst_remove(struct class_device *cdev, struct class_interface *intf) -#else static void scst_remove(struct device *cdev, struct class_interface *intf) -#endif { struct scsi_device *scsidp; TRACE_ENTRY(); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) - scsidp = to_scsi_device(cdev->dev); -#else scsidp = to_scsi_device(cdev->parent); -#endif if ((scsidp->host->hostt->name == NULL) || (strcmp(scsidp->host->hostt->name, SCST_LOCAL_NAME) != 0)) @@ -2240,17 +2193,10 @@ static void scst_remove(struct device *cdev, struct class_interface *intf) return; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) -static struct class_interface scst_interface = { - .add = scst_add, - .remove = scst_remove, -}; -#else static struct class_interface scst_interface = { .add_dev = scst_add, .remove_dev = scst_remove, }; -#endif static void __init scst_print_config(void) { diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 0f4a7a0ff..2b655eaa7 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -52,13 +52,11 @@ static struct sgv_pool *sgv_norm_pool_global[NR_CPUS]; static struct sgv_pool *sgv_norm_clust_pool_main, *sgv_norm_pool_main, *sgv_dma_pool_main; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) #if defined(CONFIG_LOCKDEP) && !defined(CONFIG_SCST_PROC) static struct lock_class_key scst_pool_key; static struct lockdep_map scst_pool_dep_map = STATIC_LOCKDEP_MAP_INIT("scst_pool_kref", &scst_pool_key); #endif -#endif #ifndef CONFIG_SCST_NO_TOTAL_MEM_CHECKS static atomic_t sgv_pages_total = ATOMIC_INIT(0); @@ -80,11 +78,7 @@ static atomic_t sgv_releases_on_hiwmk_failed = ATOMIC_INIT(0); static atomic_t sgv_other_total_alloc = ATOMIC_INIT(0); #endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) -static struct shrinker *sgv_shrinker; -#else static struct shrinker sgv_shrinker; -#endif static struct kmem_cache *sgv_pool_cachep; @@ -340,17 +334,9 @@ static unsigned long sgv_scan_shrink(struct shrinker *shrinker, return freed; } #else /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0) */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) && (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 6) -static int sgv_shrink(int nr, gfp_t gfpm) -#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) -static int sgv_shrink(struct shrinker *shrinker, int nr, gfp_t gfpm) -#else static int sgv_shrink(struct shrinker *shrinker, struct shrink_control *sc) -#endif { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) int nr = sc->nr_to_scan; -#endif int freed = 0; TRACE_ENTRY(); @@ -366,19 +352,11 @@ static int sgv_shrink(struct shrinker *shrinker, struct shrink_control *sc) } #endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0) */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) -static void sgv_purge_work_fn(void *p) -#else static void sgv_purge_work_fn(struct work_struct *work) -#endif { unsigned long cur_time = jiffies; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) - struct sgv_pool *pool = (struct sgv_pool *)p; -#else struct sgv_pool *pool = container_of(work, struct sgv_pool, sgv_purge_work.work); -#endif TRACE_ENTRY(); @@ -1453,11 +1431,7 @@ static int sgv_pool_init(struct sgv_pool *pool, const char *name, for (i = 0; i < pool->max_caches; i++) INIT_LIST_HEAD(&pool->recycling_lists[i]); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)) INIT_DELAYED_WORK(&pool->sgv_purge_work, sgv_purge_work_fn); -#else - INIT_WORK(&pool->sgv_purge_work, sgv_purge_work_fn, pool); -#endif spin_lock_bh(&sgv_pools_lock); list_add_tail(&pool->sgv_pools_list_entry, &sgv_pools_list); @@ -1817,9 +1791,6 @@ int scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark) goto out_free_per_cpu_dma; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) - sgv_shrinker = set_shrinker(DEFAULT_SEEKS, sgv_shrink); -#else #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0) sgv_shrinker.count_objects = sgv_can_be_shrunk; sgv_shrinker.scan_objects = sgv_scan_shrink; @@ -1828,7 +1799,6 @@ int scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark) #endif sgv_shrinker.seeks = DEFAULT_SEEKS; register_shrinker(&sgv_shrinker); -#endif out: TRACE_EXIT_RES(res); @@ -1871,11 +1841,7 @@ void scst_sgv_pools_deinit(void) TRACE_ENTRY(); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) - remove_shrinker(sgv_shrinker); -#else unregister_shrinker(&sgv_shrinker); -#endif sgv_pool_destroy(sgv_dma_pool_main); for (i = 0; i < nr_cpu_ids; i++) diff --git a/scst/src/scst_mem.h b/scst/src/scst_mem.h index 6b64e1d72..3d6ba7cb3 100644 --- a/scst/src/scst_mem.h +++ b/scst/src/scst_mem.h @@ -108,11 +108,7 @@ struct sgv_pool { struct sgv_pool_cache_acc cache_acc[SGV_POOL_ELEMENTS]; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)) struct delayed_work sgv_purge_work; -#else - struct work_struct sgv_purge_work; -#endif atomic_t big_alloc, big_pages, big_merged; atomic_t other_alloc, other_pages, other_merged; diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index d9404bb10..4173ac7ab 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -47,14 +47,6 @@ #include #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) -#include -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) -#include -#endif - #ifdef INSIDE_KERNEL_TREE #include #include @@ -75,7 +67,7 @@ #define isblank(c) ((c) == ' ' || (c) == '\t') #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) && defined(CONFIG_LOCKDEP) +#if defined(CONFIG_LOCKDEP) #define scst_assert_pr_mutex_held(dev) \ do { \ if (dev->dev_list_entry.next && \ @@ -1013,19 +1005,7 @@ write_error: write_error_close: filp_close(file, NULL); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) - { - struct nameidata nd; - int rc; - rc = path_lookup(dev->pr_file_name, 0, &nd); - if (!rc) - scst_vfs_unlink_and_put_nd(&nd); - else - TRACE_PR("Unable to lookup '%s' - error %d", - dev->pr_file_name, rc); - } -#else { struct path path; int rc; @@ -1037,7 +1017,6 @@ write_error_close: TRACE_PR("Unable to lookup '%s' - error %d", dev->pr_file_name, rc); } -#endif goto out; } diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 9f3437c3b..297394649 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -22,9 +22,7 @@ #include #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) #include -#endif #include #include #include @@ -184,10 +182,8 @@ extern unsigned int scst_setup_id; #define SCST_DEF_MAX_TASKLET_CMD 10 extern int scst_max_tasklet_cmd; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) #define SCST_DEF_POLL_NS 0 extern unsigned long scst_poll_ns; -#endif extern spinlock_t scst_init_lock; extern struct list_head scst_init_cmd_list; @@ -230,9 +226,6 @@ struct scst_cmd_thread_t { static inline bool scst_set_io_context(struct scst_cmd *cmd, struct io_context **old) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) - return false; -#else #ifdef CONFIG_SCST_TEST_IO_IN_SIRQ return false; #else @@ -259,7 +252,6 @@ static inline bool scst_set_io_context(struct scst_cmd *cmd, return res; #endif -#endif } static inline void scst_reset_io_context(struct scst_tgt_dev *tgt_dev, @@ -425,34 +417,10 @@ static inline int scst_dlm_new_lockspace(const char *name, int namelen, uint32_t flags, int lvblen) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) - return dlm_new_lockspace((char *)name, namelen, lockspace, flags, - lvblen); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) - return dlm_new_lockspace(name, namelen, lockspace, flags, lvblen); -#else return dlm_new_lockspace(name, NULL, flags, lvblen, NULL, NULL, NULL, lockspace); -#endif } -#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 int bufflen, unsigned int nents, - int timeout, int retries, void *privdata, - void (*done)(void *, char *, int, int), gfp_t gfp) -{ -#if defined(CONFIG_SCST_STRICT_SERIALIZING) - return scsi_execute_async(sdev, cmd, cmd_len, data_direction, (void *)sgl, - bufflen, nents, timeout, retries, privdata, done, gfp); -#else - WARN_ON(1); - return -1; -#endif -} -#endif - int scst_alloc_space(struct scst_cmd *cmd); int scst_lib_init(void); @@ -498,11 +466,7 @@ void scst_tg_tgt_sysfs_del(struct scst_target_group *tg, struct scst_tg_tgt *tg_tgt); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) extern const struct sysfs_ops scst_sysfs_ops; -#else -extern struct sysfs_ops scst_sysfs_ops; -#endif int scst_sysfs_init(void); void scst_sysfs_cleanup(void); int scst_tgtt_sysfs_create(struct scst_tgt_template *tgtt); @@ -764,9 +728,6 @@ enum scst_exec_res scst_cmp_wr_local(struct scst_cmd *cmd); int scst_pr_init(struct scst_device *dev); void scst_pr_cleanup(struct scst_device *dev); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) -void scst_vfs_unlink_and_put_nd(struct nameidata *nd); -#endif void scst_vfs_unlink_and_put(struct path *path); int scst_copy_file(const char *src, const char *dest); @@ -810,11 +771,7 @@ void scst_cm_free_descriptors(struct scst_cmd *cmd); enum scst_exec_res scst_cm_ext_copy_exec(struct scst_cmd *cmd); enum scst_exec_res scst_cm_rcv_copy_res_exec(struct scst_cmd *cmd); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) -void sess_cm_list_id_cleanup_work_fn(void *p); -#else void sess_cm_list_id_cleanup_work_fn(struct work_struct *work); -#endif void scst_cm_free_pending_list_ids(struct scst_session *sess); bool scst_cm_check_block_all_devs(struct scst_cmd *cmd); diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 0205fa7f4..d5b31e5be 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -34,7 +34,6 @@ #include "scst_pres.h" #include "scst_mem.h" -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) #ifdef CONFIG_LOCKDEP static struct lock_class_key scst_tgtt_key; static struct lockdep_map scst_tgtt_dep_map = @@ -68,7 +67,6 @@ static struct lock_class_key scst_tg_key; static struct lockdep_map scst_tg_dep_map = STATIC_LOCKDEP_MAP_INIT("scst_tg_kref", &scst_tg_key); #endif -#endif static DECLARE_COMPLETION(scst_sysfs_root_release_completion); @@ -317,37 +315,6 @@ out: #endif /* defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) && \ - (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 6 || \ - (RHEL_MAJOR -0 == 6 && RHEL_MINOR -0 < 6)) -/* - ** Backported sysfs functions. - **/ - -static int sysfs_create_files(struct kobject *kobj, - const struct attribute **ptr) -{ - int err = 0; - int i; - - for (i = 0; ptr[i] && !err; i++) - err = sysfs_create_file(kobj, ptr[i]); - if (err) - while (--i >= 0) - sysfs_remove_file(kobj, ptr[i]); - return err; -} - -static void sysfs_remove_files(struct kobject *kobj, - const struct attribute **ptr) -{ - int i; - - for (i = 0; ptr[i]; i++) - sysfs_remove_file(kobj, ptr[i]); -} -#endif - /* ** Sysfs work **/ @@ -453,19 +420,15 @@ static void scst_process_sysfs_works(void) TRACE_DBG("Sysfs work %p", work); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) if (work->dep_map) { mutex_acquire(work->dep_map, 0, 0, _RET_IP_); lock_acquired(work->dep_map, _RET_IP_); } -#endif work->work_res = work->sysfs_work_fn(work); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) if (work->dep_map) mutex_release(work->dep_map, _RET_IP_); -#endif spin_lock(&sysfs_work_lock); if (!work->read_only_action) @@ -806,20 +769,12 @@ static ssize_t scst_store(struct kobject *kobj, struct attribute *attr, return -EIO; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)) const struct sysfs_ops scst_sysfs_ops = { -#else -struct sysfs_ops scst_sysfs_ops = { -#endif .show = scst_show, .store = scst_store, }; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)) const struct sysfs_ops *scst_sysfs_get_sysfs_ops(void) -#else -struct sysfs_ops *scst_sysfs_get_sysfs_ops(void) -#endif { return &scst_sysfs_ops; } @@ -1184,7 +1139,7 @@ out_del: void scst_kobject_put_and_wait(struct kobject *kobj, const char *category, struct completion *c -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) && defined(CONFIG_LOCKDEP) +#if defined(CONFIG_LOCKDEP) , struct lockdep_map *dep_map #endif ) @@ -1197,9 +1152,7 @@ void scst_kobject_put_and_wait(struct kobject *kobj, const char *category, kobject_put(kobj); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) mutex_acquire(dep_map, 0, 0, _RET_IP_); -#endif if (wait_for_completion_timeout(c, HZ) > 0) goto out_free; @@ -1211,10 +1164,8 @@ void scst_kobject_put_and_wait(struct kobject *kobj, const char *category, category, name ? : "(?)"); out_free: -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) lock_acquired(dep_map, _RET_IP_); mutex_release(dep_map, _RET_IP_); -#endif kfree(name); @@ -1960,10 +1911,7 @@ static ssize_t __scst_acg_cpu_mask_show(struct scst_acg *acg, char *buf) { int res; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) - res = cpumask_scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, - acg->acg_cpu_mask); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) res = cpumask_scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, &acg->acg_cpu_mask); #else @@ -5663,10 +5611,8 @@ int scst_acn_sysfs_create(struct scst_acn *acn) int res = 0; struct scst_acg *acg = acn->acg; struct kobj_attribute *attr = NULL; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) #ifdef CONFIG_DEBUG_LOCK_ALLOC static struct lock_class_key __key; -#endif #endif TRACE_ENTRY(); @@ -5689,13 +5635,8 @@ int scst_acn_sysfs_create(struct scst_acn *acn) goto out_free; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) - attr->attr.owner = THIS_MODULE; -#endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) #ifdef CONFIG_DEBUG_LOCK_ALLOC attr->attr.key = &__key; -#endif #endif attr->attr.mode = S_IRUGO; @@ -7261,8 +7202,6 @@ static struct kobj_attribute scst_max_tasklet_cmd_attr = __ATTR(max_tasklet_cmd, S_IRUGO | S_IWUSR, scst_max_tasklet_cmd_show, scst_max_tasklet_cmd_store); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) - static ssize_t scst_poll_us_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -7310,8 +7249,6 @@ static struct kobj_attribute scst_poll_us_attr = __ATTR(poll_us, S_IRUGO | S_IWUSR, scst_poll_us_show, scst_poll_us_store); -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) */ - static ssize_t scst_suspend_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -7619,9 +7556,7 @@ static struct attribute *scst_sysfs_root_default_attrs[] = { &scst_threads_attr.attr, &scst_setup_id_attr.attr, &scst_max_tasklet_cmd_attr.attr, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) &scst_poll_us_attr.attr, -#endif &scst_suspend_attr.attr, #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) &scst_main_trace_level_attr.attr,