Cleanup: sess->shutdown_compl made on stack
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Tue, 23 Jun 2009 12:15:49 +0000 (12:15 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Tue, 23 Jun 2009 12:15:49 +0000 (12:15 +0000)
git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@916 d57e44dd-8a1f-0410-8b47-8ef2f437770f

scst/include/scst.h
scst/src/dev_handlers/scst_user.c
scst/src/scst_targ.c

index 59a7109..3837134 100644 (file)
 
 #include <scst_const.h>
 
+#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"
 
 /*
 #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"
index 2121394..064f62f 100644 (file)
  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)
index a68fff3..e6ccc27 100644 (file)
@@ -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;
 }