*/
void (*preprocessing_done) (struct scst_cmd *cmd);
+ /*
+ * This function informs the driver that the said command is about
+ * to be executed.
+ *
+ * Returns one of the SCST_PREPROCESS_* constants.
+ *
+ * This command is expected to be NON-BLOCKING.
+ *
+ * Pay attention to "atomic" attribute of the cmd, which can be get
+ * by scst_cmd_atomic(): it is true if the function called in the
+ * atomic (non-sleeping) context.
+ *
+ * OPTIONAL
+ */
+ int (*pre_exec) (struct scst_cmd *cmd);
+
/*
* This function informs the driver that a
* received task management function has been completed. This
} \
} while(0)
+#define TRACE_DBG_SPECIAL(format, args...) \
+do { \
+ if (trace_flag & (TRACE_DEBUG|TRACE_SPECIAL)) \
+ { \
+ char *__tflag = LOG_FLAG; \
+ if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \
+ { \
+ __tflag = NO_FLAG; \
+ } \
+ PRINT(NO_FLAG, "%s" format, __tflag, args); \
+ } \
+} while(0)
+
#define TRACE_MGMT_DBG(format, args...) \
do { \
if (trace_flag & TRACE_MGMT_DEBUG) \
} \
} while(0)
+#define TRACE_MGMT_DBG_SPECIAL(format, args...) \
+do { \
+ if (trace_flag & (TRACE_MGMT_DEBUG|TRACE_SPECIAL)) \
+ { \
+ char *__tflag = LOG_FLAG; \
+ if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \
+ { \
+ __tflag = NO_FLAG; \
+ } \
+ PRINT(NO_FLAG, "%s" format, __tflag, args); \
+ } \
+} while(0)
+
#define PRINT_ERROR_PR(format, args...) \
do { \
if (ERROR_FLAG != LOG_FLAG) \
#define TRACE_MEM(format, args...) {}
#define TRACE_DBG(format, args...) {}
+#define TRACE_DBG_SPECIAL(format, args...) {}
#define TRACE_MGMT_DBG(format, args...) {}
+#define TRACE_MGMT_DBG_SPECIAL(format, args...) {}
#define TRACE_ENTRY() {}
#define TRACE_EXIT() {}
#define TRACE_EXIT_RES(res) {}
write_proc: vcdrom_write_proc, \
}
-static DECLARE_MUTEX(scst_vdisk_mutex);
+static DEFINE_MUTEX(scst_vdisk_mutex);
static LIST_HEAD(vdisk_dev_list);
static LIST_HEAD(vcdrom_dev_list);
TRACE_ENTRY();
- if (down_interruptible(&scst_vdisk_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_vdisk_mutex) != 0) {
res = -EINTR;
goto out;
}
}
seq_printf(seq, "%s\n", virt_dev->file_name);
}
- up(&scst_vdisk_mutex);
+ mutex_unlock(&scst_vdisk_mutex);
out:
TRACE_EXIT_RES(res);
return res;
if (buffer[0] == '\0')
goto out;
- if (down_interruptible(&scst_vdisk_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_vdisk_mutex) != 0) {
res = -EINTR;
goto out;
}
res = length;
out_up:
- up(&scst_vdisk_mutex);
+ mutex_unlock(&scst_vdisk_mutex);
out:
TRACE_EXIT_RES(res);
TRACE_ENTRY();
- if (down_interruptible(&scst_vdisk_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_vdisk_mutex) != 0) {
res = -EINTR;
goto out;
}
virt_dev->file_name);
}
- up(&scst_vdisk_mutex);
+ mutex_unlock(&scst_vdisk_mutex);
out:
TRACE_EXIT_RES(res);
TRACE_ENTRY();
- if (down_interruptible(&scst_vdisk_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_vdisk_mutex) != 0) {
res = -EINTR;
goto out;
}
res = length;
out_up:
- up(&scst_vdisk_mutex);
+ mutex_unlock(&scst_vdisk_mutex);
out:
TRACE_EXIT_RES(res);
{
TRACE_ENTRY();
- down(&scst_vdisk_mutex);
+ mutex_lock(&scst_vdisk_mutex);
while (1) {
struct scst_vdisk_dev *virt_dev;
kfree(virt_dev->file_name);
kfree(virt_dev);
}
- up(&scst_vdisk_mutex);
+ mutex_unlock(&scst_vdisk_mutex);
if (!devtype->no_proc) {
vdisk_proc_help_destroy(devtype);
#endif
/* All targets, devices and dev_types management is done under this mutex */
-DECLARE_MUTEX(scst_mutex);
+DEFINE_MUTEX(scst_mutex);
LIST_HEAD(scst_template_list);
LIST_HEAD(scst_dev_list);
DECLARE_WAIT_QUEUE_HEAD(scst_dev_cmd_waitQ);
-DECLARE_MUTEX(scst_suspend_mutex);
+DEFINE_MUTEX(scst_suspend_mutex);
LIST_HEAD(scst_cmd_lists_list); /* protected by scst_suspend_mutex */
static int scst_threads;
{
int res = 0;
struct scst_tgt_template *t;
- static DECLARE_MUTEX(m);
+ static DEFINE_MUTEX(m);
TRACE_ENTRY();
if (vtt->preprocessing_done == NULL)
vtt->preprocessing_done_atomic = 1;
- if (down_interruptible(&m) != 0)
+ if (mutex_lock_interruptible(&m) != 0)
goto out_err;
- if (down_interruptible(&scst_mutex) != 0)
+ if (mutex_lock_interruptible(&scst_mutex) != 0)
goto out_m_up;
list_for_each_entry(t, &scst_template_list, scst_template_list_entry) {
if (strcmp(t->name, vtt->name) == 0) {
PRINT_ERROR_PR("Target driver %s already registered",
vtt->name);
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
goto out_cleanup;
}
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
TRACE_DBG("%s", "Calling target driver's detect()");
res = vtt->detect(vtt);
goto out_cleanup;
}
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_add_tail(&vtt->scst_template_list_entry, &scst_template_list);
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
res = 0;
PRINT_INFO_PR("Target template %s registered successfully", vtt->name);
- up(&m);
+ mutex_unlock(&m);
out:
TRACE_EXIT_RES(res);
return res;
out_m_up:
- up(&m);
+ mutex_unlock(&m);
out_cleanup:
scst_cleanup_proc_target_dir_entries(vtt);
TRACE_ENTRY();
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_for_each_entry(t, &scst_template_list, scst_template_list_entry) {
if (strcmp(t->name, vtt->name) == 0) {
restart:
list_for_each_entry(tgt, &vtt->tgt_list, tgt_list_entry) {
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_unregister(tgt);
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
goto restart;
}
list_del(&vtt->scst_template_list_entry);
PRINT_INFO_PR("Target template %s unregistered successfully", vtt->name);
out_up:
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_cleanup_proc_target_dir_entries(vtt);
tgt->retry_timer.function = scst_tgt_retry_timer_fn;
scst_suspend_activity();
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
if (target_name != NULL) {
int len = strlen(target_name) + 1 +
else
list_add_tail(&tgt->tgt_list_entry, &vtt->tgt_list);
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
PRINT_INFO_PR("Target %s for template %s registered successfully",
kfree(tgt->default_group_name);
out_free_err:
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
kfree(tgt);
static inline int test_sess_list(struct scst_tgt *tgt)
{
int res;
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
res = list_empty(&tgt->sess_list);
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
return res;
}
tgt->tgtt->release(tgt);
TRACE_DBG("%s", "Target driver's release() returned");
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_for_each_entry(sess, &tgt->sess_list, sess_list_entry) {
sBUG_ON(!sess->shutting_down);
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
TRACE_DBG("%s", "Waiting for sessions shutdown");
wait_event(tgt->unreg_waitQ, test_sess_list(tgt));
TRACE_DBG("%s", "wait_event() returned");
scst_suspend_activity();
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_del(&tgt->tgt_list_entry);
if (tgt->default_group_name)
kfree(tgt->default_group_name);
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
del_timer_sync(&tgt->retry_timer);
{
TRACE_ENTRY();
- down(&scst_suspend_mutex);
+ mutex_lock(&scst_suspend_mutex);
TRACE_MGMT_DBG("suspend_count %d", suspend_count);
suspend_count++;
TRACE_MGMT_DBG("%s", "wait_event() returned");
out_up:
- up(&scst_suspend_mutex);
+ mutex_unlock(&scst_suspend_mutex);
TRACE_EXIT();
return;
TRACE_ENTRY();
- down(&scst_suspend_mutex);
+ mutex_lock(&scst_suspend_mutex);
TRACE_MGMT_DBG("suspend_count %d", suspend_count);
suspend_count--;
wake_up_all(&scst_mgmt_cmd_list_waitQ);
out_up:
- up(&scst_suspend_mutex);
+ mutex_unlock(&scst_suspend_mutex);
TRACE_EXIT();
return;
TRACE_ENTRY();
scst_suspend_activity();
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
res = scst_alloc_device(GFP_KERNEL, &dev);
if (res != 0)
}
out_up:
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
if (res == 0) {
TRACE_ENTRY();
scst_suspend_activity();
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_for_each_entry(d, &scst_dev_list, dev_list_entry) {
if (d->scsi_dev == scsidp) {
scsidp->channel, scsidp->id, scsidp->lun, scsidp->type);
out_unblock:
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
TRACE_EXIT();
goto out;
scst_suspend_activity();
- if (down_interruptible(&scst_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_mutex) != 0) {
res = -EINTR;
goto out_resume;
}
}
out_up:
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
out_resume:
scst_resume_activity();
TRACE_ENTRY();
scst_suspend_activity();
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_for_each_entry(d, &scst_dev_list, dev_list_entry) {
if (d->virt_id == id) {
scst_free_device(dev);
out_unblock:
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
TRACE_EXIT();
#endif
scst_suspend_activity();
- if (down_interruptible(&scst_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_mutex) != 0) {
res = -EINTR;
goto out_err;
}
scst_assign_dev_handler(dev, dev_type);
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
if (res == 0) {
return res;
out_up:
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
out_err:
scst_resume_activity();
TRACE_ENTRY();
scst_suspend_activity();
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_for_each_entry(dt, &scst_dev_type_list, dev_type_list_entry) {
if (strcmp(dt->name, dev_type->name) == 0) {
list_del(&dev_type->dev_type_list_entry);
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
scst_cleanup_proc_dev_handler_dir_entries(dev_type);
return;
out_up:
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
goto out;
}
if (res != 0)
goto out;
- down(&scst_suspend_mutex);
+ mutex_lock(&scst_suspend_mutex);
list_add_tail(&dev->cmd_lists.lists_list_entry,
&scst_cmd_lists_list);
- up(&scst_suspend_mutex);
+ mutex_unlock(&scst_suspend_mutex);
dev->p_cmd_lists = &dev->cmd_lists;
scst_del_dev_threads(dev, -1);
if (dev->p_cmd_lists == &dev->cmd_lists) {
- down(&scst_suspend_mutex);
+ mutex_lock(&scst_suspend_mutex);
list_del(&dev->cmd_lists.lists_list_entry);
- up(&scst_suspend_mutex);
+ mutex_unlock(&scst_suspend_mutex);
}
out:
int i;
/* Just to lower the race window, when user can get just changed value */
- down(&scst_threads_info.cmd_threads_mutex);
+ mutex_lock(&scst_threads_info.cmd_threads_mutex);
i = scst_threads_info.nr_cmd_threads;
- up(&scst_threads_info.cmd_threads_mutex);
+ mutex_unlock(&scst_threads_info.cmd_threads_mutex);
return i;
}
static void scst_threads_info_init(void)
{
memset(&scst_threads_info, 0, sizeof(scst_threads_info));
- init_MUTEX(&scst_threads_info.cmd_threads_mutex);
+ mutex_init(&scst_threads_info.cmd_threads_mutex);
INIT_LIST_HEAD(&scst_threads_info.cmd_threads_list);
}
TRACE_ENTRY();
- down(&scst_threads_info.cmd_threads_mutex);
+ mutex_lock(&scst_threads_info.cmd_threads_mutex);
res = __scst_add_cmd_threads(num);
- up(&scst_threads_info.cmd_threads_mutex);
+ mutex_unlock(&scst_threads_info.cmd_threads_mutex);
TRACE_EXIT_RES(res);
return res;
{
TRACE_ENTRY();
- down(&scst_threads_info.cmd_threads_mutex);
+ mutex_lock(&scst_threads_info.cmd_threads_mutex);
__scst_del_cmd_threads(num);
- up(&scst_threads_info.cmd_threads_mutex);
+ mutex_unlock(&scst_threads_info.cmd_threads_mutex);
TRACE_EXIT();
return;
{
TRACE_ENTRY();
- down(&scst_threads_info.cmd_threads_mutex);
+ mutex_lock(&scst_threads_info.cmd_threads_mutex);
__scst_del_cmd_threads(scst_threads_info.nr_cmd_threads);
if (scst_threads_info.mgmt_cmd_thread)
kthread_stop(scst_threads_info.mgmt_cmd_thread);
kthread_stop(scst_threads_info.mgmt_thread);
if (scst_threads_info.init_cmd_thread)
kthread_stop(scst_threads_info.init_cmd_thread);
- up(&scst_threads_info.cmd_threads_mutex);
+ mutex_unlock(&scst_threads_info.cmd_threads_mutex);
TRACE_EXIT();
return;
TRACE_ENTRY();
- down(&scst_threads_info.cmd_threads_mutex);
+ mutex_lock(&scst_threads_info.cmd_threads_mutex);
res = __scst_add_cmd_threads(num);
if (res < 0)
goto out;
}
out:
- up(&scst_threads_info.cmd_threads_mutex);
+ mutex_unlock(&scst_threads_info.cmd_threads_mutex);
TRACE_EXIT_RES(res);
return res;
}
TRACE_ENTRY();
scst_suspend_activity();
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
TRACE_DBG("Removing sess %p from the list", sess);
list_del(&sess->sess_list_entry);
wake_up_all(&sess->tgt->unreg_waitQ);
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
kfree(sess->initiator_name);
* suspending the activity isn't necessary.
*/
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_for_each_entry(tgt_dev, &dev->dev_tgt_dev_list,
dev_tgt_dev_list_entry) {
scst_del_all_thr_data(tgt_dev);
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
TRACE_EXIT();
return;
atomic_t sgv_other_total_alloc;
-DECLARE_MUTEX(scst_sgv_pool_mutex);
+DEFINE_MUTEX(scst_sgv_pool_mutex);
LIST_HEAD(scst_sgv_pool_list);
static int scst_check_clustering(struct scatterlist *sg, int cur, int hint)
}
}
- down(&scst_sgv_pool_mutex);
+ mutex_lock(&scst_sgv_pool_mutex);
list_add_tail(&pool->sgv_pool_list_entry, &scst_sgv_pool_list);
- up(&scst_sgv_pool_mutex);
+ mutex_unlock(&scst_sgv_pool_mutex);
res = 0;
pool->caches[i] = NULL;
}
- down(&scst_sgv_pool_mutex);
+ mutex_lock(&scst_sgv_pool_mutex);
list_del(&pool->sgv_pool_list_entry);
- up(&scst_sgv_pool_mutex);
+ mutex_unlock(&scst_sgv_pool_mutex);
TRACE_EXIT();
}
};
extern atomic_t sgv_other_total_alloc;
-extern struct semaphore scst_sgv_pool_mutex;
+extern struct mutex scst_sgv_pool_mutex;
extern struct list_head scst_sgv_pool_list;
int sgv_pool_init(struct sgv_pool *pool, const char *name,
extern struct scst_sgv_pools scst_sgv;
extern unsigned long scst_flags;
-extern struct semaphore scst_mutex;
+extern struct mutex scst_mutex;
extern atomic_t scst_cmd_count;
extern struct list_head scst_template_list; /* protected by scst_mutex */
extern struct list_head scst_dev_list; /* protected by scst_mutex */
extern struct list_head scst_dev_type_list; /* protected by scst_mutex */
extern wait_queue_head_t scst_dev_cmd_waitQ;
-extern struct semaphore scst_suspend_mutex;
+extern struct mutex scst_suspend_mutex;
extern struct list_head scst_cmd_lists_list; /* protected by scst_suspend_mutex */
extern struct list_head scst_acg_list;
};
struct scst_threads_info_t {
- struct semaphore cmd_threads_mutex;
+ struct mutex cmd_threads_mutex;
u32 nr_cmd_threads;
struct list_head cmd_threads_list;
struct task_struct *init_cmd_thread;
"Optical card reader/writer device"
};
-static DECLARE_MUTEX(scst_proc_mutex);
+static DEFINE_MUTEX(scst_proc_mutex);
#include <linux/ctype.h>
#if defined(DEBUG) || defined(TRACING)
-static DECLARE_MUTEX(scst_log_mutex);
+static DEFINE_MUTEX(scst_log_mutex);
int scst_proc_log_entry_write(struct file *file, const char *buf,
unsigned long length, unsigned long *log_level,
TRACE_ENTRY();
- if (down_interruptible(&scst_log_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_log_mutex) != 0) {
res = -EINTR;
goto out;
}
res = scst_proc_log_entry_write(file, buf, length,
&trace_flag, SCST_DEFAULT_LOG_FLAGS, scst_proc_local_trace_tbl);
- up(&scst_log_mutex);
+ mutex_unlock(&scst_log_mutex);
out:
TRACE_EXIT_RES(res);
goto out_free;
}
- if (down_interruptible(&scst_proc_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_proc_mutex) != 0) {
res = -EINTR;
goto out_free;
}
- down(&scst_threads_info.cmd_threads_mutex);
+ mutex_lock(&scst_threads_info.cmd_threads_mutex);
oldtn = scst_threads_info.nr_cmd_threads;
newtn = simple_strtoul(buffer, NULL, 0);
PRINT_INFO_PR("Changed cmd threads num: old %d, new %d", oldtn, newtn);
out_up_thr_free:
- up(&scst_threads_info.cmd_threads_mutex);
+ mutex_unlock(&scst_threads_info.cmd_threads_mutex);
- up(&scst_proc_mutex);
+ mutex_unlock(&scst_proc_mutex);
out_free:
free_page((unsigned long)buffer);
TRACE_BUFFER("Buffer", buffer, length);
- if (down_interruptible(&scst_proc_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_proc_mutex) != 0) {
res = -EINTR;
goto out_free;
}
res = vtt->tgtt->write_proc(buffer, &start, 0, length, &eof, vtt);
- up(&scst_proc_mutex);
+ mutex_unlock(&scst_proc_mutex);
out_free:
free_page((unsigned long)buffer);
TRACE_BUFFER("Buffer", buffer, length);
- if (down_interruptible(&scst_proc_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_proc_mutex) != 0) {
res = -EINTR;
goto out_free;
}
res = dev_type->write_proc(buffer, &start, 0, length, &eof, dev_type);
- up(&scst_proc_mutex);
+ mutex_unlock(&scst_proc_mutex);
out_free:
free_page((unsigned long)buffer);
scst_suspend_activity();
- if (down_interruptible(&scst_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_mutex) != 0) {
res = -EINTR;
goto out_free_resume;
}
res = rc;
out_up_free:
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
out_free_resume:
scst_resume_activity();
scst_suspend_activity();
- if (down_interruptible(&scst_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_mutex) != 0) {
res = -EINTR;
goto out_free_resume;
}
}
out_free_up:
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
out_free_resume:
scst_resume_activity();
break;
}
- if (down_interruptible(&scst_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_mutex) != 0) {
res = -EINTR;
goto out_free;
}
break;
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
out_free:
free_page((unsigned long)buffer);
TRACE_ENTRY();
- if (down_interruptible(&scst_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_mutex) != 0) {
res = -EINTR;
goto out;
}
}
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
out:
TRACE_EXIT_RES(res);
seq_printf(seq, "%-30s %-11s %-11s", "Name", "Hit", "Total");
- down(&scst_sgv_pool_mutex);
+ mutex_lock(&scst_sgv_pool_mutex);
list_for_each_entry(pool, &scst_sgv_pool_list, sgv_pool_list_entry) {
scst_do_sgv_read(seq, pool);
}
- up(&scst_sgv_pool_mutex);
+ mutex_unlock(&scst_sgv_pool_mutex);
seq_printf(seq, "\n%-42s %-11d\n", "other", atomic_read(&sgv_other_total_alloc));
TRACE_ENTRY();
- if (down_interruptible(&scst_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_mutex) != 0) {
res = -EINTR;
goto out;
}
seq_printf(seq, "%s\n", name->name);
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
out:
TRACE_EXIT_RES(res);
TRACE_ENTRY();
- if (down_interruptible(&scst_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_mutex) != 0) {
res = -EINTR;
goto out;
}
acg_dev->rd_only_flag ? "RO" : "");
}
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
out:
TRACE_EXIT_RES(res);
TRACE_ENTRY();
- if (down_interruptible(&scst_log_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_log_mutex) != 0) {
res = -EINTR;
goto out;
}
res = scst_proc_log_entry_read(seq, trace_flag, scst_proc_local_trace_tbl);
- up(&scst_log_mutex);
+ mutex_unlock(&scst_log_mutex);
out:
TRACE_EXIT_RES(res);
TRACE_ENTRY();
- if (down_interruptible(&scst_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_mutex) != 0) {
res = -EINTR;
goto out;
}
seq_printf(seq, "%-60s%s\n", dev->virt_name, dev->handler->name);
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
out:
TRACE_EXIT_RES(res);
TRACE_ENTRY();
- if (down_interruptible(&scst_proc_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_proc_mutex) != 0) {
res = -EINTR;
goto out;
}
if (vtt->tgtt->read_proc)
res = vtt->tgtt->read_proc(seq, vtt);
- up(&scst_proc_mutex);
+ mutex_unlock(&scst_proc_mutex);
out:
TRACE_EXIT_RES(res);
return res;
TRACE_ENTRY();
- if (down_interruptible(&scst_proc_mutex) != 0) {
+ if (mutex_lock_interruptible(&scst_proc_mutex) != 0) {
res = -EINTR;
goto out;
}
if (dev_type->read_proc)
res = dev_type->read_proc(seq, dev_type);
- up(&scst_proc_mutex);
+ mutex_unlock(&scst_proc_mutex);
out:
TRACE_EXIT_RES(res);
return;
}
+static int scst_tgt_pre_exec(struct scst_cmd *cmd, int *action)
+{
+ int res = 0, rc;
+
+ TRACE_ENTRY();
+
+ TRACE_DBG("Calling pre_exec(%p)", cmd);
+ rc = cmd->tgtt->pre_exec(cmd);
+ TRACE_DBG("pre_exec() returned %d", rc);
+
+ if (unlikely(rc != SCST_PREPROCESS_STATUS_SUCCESS)) {
+ switch(rc) {
+ case SCST_PREPROCESS_STATUS_ERROR_SENSE_SET:
+ cmd->state = SCST_CMD_STATE_DEV_DONE;
+ *action = SCST_CMD_STATE_RES_CONT_SAME;
+ res = -1;
+ break;
+ case SCST_PREPROCESS_STATUS_ERROR_FATAL:
+ set_bit(SCST_CMD_NO_RESP, &cmd->cmd_flags);
+ /* go through */
+ case SCST_PREPROCESS_STATUS_ERROR:
+ scst_set_cmd_error(cmd,
+ SCST_LOAD_SENSE(scst_sense_hardw_error));
+ cmd->state = SCST_CMD_STATE_DEV_DONE;
+ *action = SCST_CMD_STATE_RES_CONT_SAME;
+ res = -1;
+ break;
+ default:
+ sBUG();
+ break;
+ }
+ }
+
+ TRACE_EXIT_RES(res);
+ return res;
+}
+
static void scst_inc_check_expected_sn(struct scst_cmd *cmd)
{
struct scst_cmd *c;
res = SCST_CMD_STATE_RES_CONT_NEXT;
+ if (cmd->tgtt->pre_exec != NULL) {
+ rc = scst_tgt_pre_exec(cmd, &res);
+ if (unlikely(rc != 0))
+ goto out;
+ }
+
if (unlikely(scst_inc_on_dev_cmd(cmd) != 0))
goto out;
TRACE_ENTRY();
if (!scst_mutex_held)
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_for_each_entry(dev, &scst_dev_list, dev_list_entry) {
struct scst_cmd *cmd, *tcmd;
}
if (!scst_mutex_held)
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
TRACE_EXIT();
return;
TRACE(TRACE_MGMT, "Target reset (mcmd %p, cmd count %d)",
mcmd, atomic_read(&mcmd->sess->sess_cmd_count));
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_for_each_entry(dev, &scst_dev_list, dev_list_entry) {
int found = 0;
dev->scsi_dev->was_reset = 0;
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
tm_dbg_task_mgmt("TARGET RESET", 0);
res = scst_set_mcmd_next_state(mcmd);
mcmd);
}
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
for(i = 0; i < TGT_DEV_HASH_SIZE; i++) {
struct list_head *sess_tgt_dev_list_head =
&sess->sess_tgt_dev_list_hash[i];
mcmd->status = rc;
}
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
res = scst_set_mcmd_next_state(mcmd);
mcmd);
}
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_for_each_entry(dev, &scst_dev_list, dev_list_entry) {
spin_lock_bh(&dev->dev_lock);
}
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
res = scst_set_mcmd_next_state(mcmd);
case SCST_TARGET_RESET:
case SCST_ABORT_ALL_TASKS:
case SCST_NEXUS_LOSS:
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
list_for_each_entry(dev, &scst_dev_list, dev_list_entry) {
scst_unblock_dev(dev);
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
break;
case SCST_NEXUS_LOSS_SESS:
{
int i;
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
for(i = 0; i < TGT_DEV_HASH_SIZE; i++) {
struct list_head *sess_tgt_dev_list_head =
&mcmd->sess->sess_tgt_dev_list_hash[i];
scst_unblock_dev(tgt_dev->dev);
}
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
break;
}
TRACE_ENTRY();
scst_suspend_activity();
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
if (sess->initiator_name)
acg = scst_find_acg(sess->initiator_name);
res = scst_sess_alloc_tgt_devs(sess);
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_resume_activity();
if (sess->init_result_fn) {
TRACE_ENTRY();
- down(&scst_mutex);
+ mutex_lock(&scst_mutex);
for(i = 0; i < TGT_DEV_HASH_SIZE; i++) {
struct list_head *sess_tgt_dev_list_head =
&sess->sess_tgt_dev_list_hash[i];
}
}
}
- up(&scst_mutex);
+ mutex_unlock(&scst_mutex);
scst_sess_put(sess);