Merge the recent changes to the 2.0.0.x branch now that Chris Worley has tested

them and seems happy. Vlad approved having these changes merged.


git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.0.0.x@2183 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Richard Sharpe
2010-09-23 04:50:15 +00:00
parent f0e023fb4d
commit efabfe526b

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008 Richard Sharpe
* Copyright (C) 2008 - 2010 Richard Sharpe
* Copyright (C) 1992 Eric Youngdale
* Copyright (C) 2008 - 2010 Vladislav Bolkhovitin <vst@vlnb.net>
*
@@ -43,6 +43,10 @@
#include <scst_debug.h>
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25))
#define SG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist))
#endif
#ifndef INSIDE_KERNEL_TREE
#if defined(CONFIG_HIGHMEM4G) || defined(CONFIG_HIGHMEM64G)
#warning "HIGHMEM kernel configurations are not supported by this module,\
@@ -934,7 +938,7 @@ static int scst_local_queuecommand(struct scsi_cmnd *SCpnt,
*/
tgt_specific = kmem_cache_alloc(tgt_specific_pool, GFP_ATOMIC);
if (!tgt_specific) {
PRINT_ERROR("Unable to create tgt_specific (size %d)",
PRINT_ERROR("Unable to create tgt_specific (size %zu)",
sizeof(*tgt_specific));
return -ENOMEM;
}
@@ -998,7 +1002,7 @@ static int scst_local_queuecommand(struct scsi_cmnd *SCpnt,
*/
if (scsi_sglist(SCpnt)) {
sg_init_one(&(tgt_specific->sgl),
(const void *)scsi_sglist(SCpnt),
(void *)scsi_sglist(SCpnt),
scsi_bufflen(SCpnt));
sgl = &(tgt_specific->sgl);
sgl_count = 1;
@@ -1120,14 +1124,22 @@ done:
return;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void scst_aen_work_fn(void *ctx)
#else
static void scst_aen_work_fn(struct work_struct *work)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct scst_local_sess *sess = (struct scst_local_sess *)ctx;
#else
struct scst_local_sess *sess =
container_of(work, struct scst_local_sess, aen_work);
#endif
TRACE_ENTRY();
TRACE_MGMT_DBG("Target work %p)", work);
TRACE_MGMT_DBG("Target work %p)", sess);
spin_lock(&sess->aen_lock);
scst_process_aens(sess, false);
@@ -1317,7 +1329,11 @@ static uint16_t scst_local_get_phys_transport_version(struct scst_tgt *scst_tgt)
static struct scst_tgt_template scst_local_targ_tmpl = {
.name = "scst_local",
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
.sg_tablesize = SG_MAX_SINGLE_ALLOC,
#else
.sg_tablesize = 0xffff,
#endif
.xmit_response_atomic = 1,
#ifndef CONFIG_SCST_PROC
.enabled_attr_not_needed = 1,
@@ -1508,7 +1524,15 @@ static void scst_local_release_adapter(struct device *dev)
scst_process_aens(sess, true);
spin_unlock(&sess->aen_lock);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
/*
* cancel_work_sync() was introduced in 2.6.22. We can only wait until
* all scheduled work is done.
*/
flush_scheduled_work();
#else
cancel_work_sync(&sess->aen_work);
#endif
scst_unregister_session(sess->scst_sess, TRUE, NULL);
@@ -1530,7 +1554,7 @@ static int __scst_local_add_adapter(struct scst_local_tgt *tgt,
sess = kzalloc(sizeof(*sess), GFP_KERNEL);
if (NULL == sess) {
PRINT_ERROR("Unable to alloc scst_lcl_host (size %zd)",
PRINT_ERROR("Unable to alloc scst_lcl_host (size %zu)",
sizeof(*sess));
res = -ENOMEM;
goto out;
@@ -1543,7 +1567,11 @@ static int __scst_local_add_adapter(struct scst_local_tgt *tgt,
/*
* Init this stuff we need for scheduling AEN work
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20))
INIT_WORK(&sess->aen_work, scst_aen_work_fn, sess);
#else
INIT_WORK(&sess->aen_work, scst_aen_work_fn);
#endif
spin_lock_init(&sess->aen_lock);
INIT_LIST_HEAD(&sess->aen_work_list);
@@ -1643,7 +1671,7 @@ static int scst_local_add_target(const char *target_name,
tgt = kzalloc(sizeof(*tgt), GFP_KERNEL);
if (NULL == tgt) {
PRINT_ERROR("Unable to alloc tgt (size %zd)", sizeof(*tgt));
PRINT_ERROR("Unable to alloc tgt (size %zu)", sizeof(*tgt));
res = -ENOMEM;
goto out;
}