mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-22 05:01:27 +00:00
Cleanup: sess->shutdown_compl made on stack
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@916 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -34,6 +34,14 @@
|
||||
|
||||
#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"
|
||||
|
||||
/*
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user