diff --git a/scst/include/scst.h b/scst/include/scst.h index 59a7109bc..3837134d1 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -34,6 +34,14 @@ #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) +#ifndef RHEL_RELEASE_CODE +typedef _Bool bool; +#endif +#define true 1 +#define false 0 +#endif + #include "scst_sgv.h" /* @@ -48,12 +56,23 @@ #define SCST_INTERFACE_VERSION \ SCST_VERSION_STRING "$Revision$" SCST_CONST_VERSION -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) -#ifndef RHEL_RELEASE_CODE -typedef _Bool bool; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)) +#define COMPLETION_INITIALIZER_ONSTACK(work) \ + ({ init_completion(&work); work; }) + +/* + * Lockdep needs to run a non-constant initializer for on-stack + * completions - so we use the _ONSTACK() variant for those that + * are on the kernel stack: + */ +#ifdef CONFIG_LOCKDEP +# define DECLARE_COMPLETION_ONSTACK(work) \ + struct completion work = COMPLETION_INITIALIZER_ONSTACK(work) +#else +# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work) #endif -#define true 1 -#define false 0 + #endif #define SCST_LOCAL_NAME "scst_lcl_drvr" diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 21213947b..064f62fb0 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -35,24 +35,6 @@ for details." #endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)) -#define COMPLETION_INITIALIZER_ONSTACK(work) \ - ({ init_completion(&work); work; }) - -/* - * Lockdep needs to run a non-constant initializer for on-stack - * completions - so we use the _ONSTACK() variant for those that - * are on the kernel stack: - */ -#ifdef CONFIG_LOCKDEP -# define DECLARE_COMPLETION_ONSTACK(work) \ - struct completion work = COMPLETION_INITIALIZER_ONSTACK(work) -#else -# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work) -#endif - -#endif - #define DEV_USER_MAJOR 237 #define DEV_USER_CMD_HASH_ORDER 6 #define DEV_USER_ATTACH_TIMEOUT (5*HZ) diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index a68fff3ee..e6ccc27ef 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -5416,18 +5416,6 @@ static int scst_init_session(struct scst_session *sess) TRACE_DBG("%s", "init_result_fn() returned"); } -#ifdef CONFIG_LOCKDEP - if (res == 0) { - /* ToDo: make it on-stack */ - sess->shutdown_compl = kmalloc(sizeof(*sess->shutdown_compl), - GFP_KERNEL); - if (sess->shutdown_compl == NULL) - res = -ENOMEM; - else - init_completion(sess->shutdown_compl); - } -#endif - spin_lock_irq(&sess->sess_list_lock); if (res == 0) @@ -5521,22 +5509,13 @@ void scst_unregister_session(struct scst_session *sess, int wait, void (*unreg_done_fn) (struct scst_session *sess)) { unsigned long flags; - struct completion *pc; -#ifndef CONFIG_LOCKDEP - DECLARE_COMPLETION(c); -#endif + DECLARE_COMPLETION_ONSTACK(c); int rc, lun; TRACE_ENTRY(); TRACE_MGMT_DBG("Unregistering session %p (wait %d)", sess, wait); -#ifdef CONFIG_LOCKDEP - pc = sess->shutdown_compl; -#else - pc = &c; -#endif - sess->unreg_done_fn = unreg_done_fn; /* Abort all outstanding commands and clear reservation, if necessary */ @@ -5553,11 +5532,7 @@ void scst_unregister_session(struct scst_session *sess, int wait, spin_lock_irqsave(&scst_mgmt_lock, flags); if (wait) - sess->shutdown_compl = pc; -#ifdef CONFIG_LOCKDEP - else - sess->shutdown_compl = NULL; -#endif + sess->shutdown_compl = &c; spin_unlock_irqrestore(&scst_mgmt_lock, flags); @@ -5565,13 +5540,9 @@ void scst_unregister_session(struct scst_session *sess, int wait, if (wait) { TRACE_DBG("Waiting for session %p to complete", sess); - wait_for_completion(pc); + wait_for_completion(&c); } -#ifdef CONFIG_LOCKDEP - kfree(pc); -#endif - TRACE_EXIT(); return; }