From ef3019b48b2887906ea800b0ece78bb522bc3774 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Tue, 3 May 2011 21:13:08 +0000 Subject: [PATCH] Merge of the trunk's r3428-3435: - Don't allow to create targets with the same names - Remove "unused variable" warning on old kernels - Fix a compiler warning on pre-2.6.35 non-RHEL systems. - Bug fix: do not try to apply patch readahead-2.6.32.below11.patch on kernel 2.6.32.11 or any later 2.6.32 kernel. - Removed the constant REPORT_DEVICE_IDENTIFIER from scst/include/scst_const.h because it is not used anywhere in the SCST source tree. - Expand CONFIG_SCST_PROC too. - Added #include for kmem_cache_free(). - MultiP must be 1 and HiSup 0 git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.1.0.x@3437 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/generate-patched-kernel | 8 ++++++-- scripts/specialize-patch | 1 + scst/include/scst_const.h | 1 - scst/src/dev_handlers/scst_vdisk.c | 6 +++--- scst/src/scst_main.c | 10 +++++++++- scst/src/scst_mem.c | 2 +- scst/src/scst_priv.h | 2 +- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/scripts/generate-patched-kernel b/scripts/generate-patched-kernel index 8c1d662eb..11ab35864 100755 --- a/scripts/generate-patched-kernel +++ b/scripts/generate-patched-kernel @@ -116,6 +116,10 @@ svn status -v "$(dirname "$(dirname "$scriptname")")" \ | grep -v /in-tree/ \ | while read p do - echo "==== $p" - patch -p1 <$p + if [ "${p/readahead-2.6.32.below11.patch//}" = "$p" \ + -o "${patchlevel:-0}" -lt 11 ] + then + echo "==== $p" + patch -p1 <$p + fi done diff --git a/scripts/specialize-patch b/scripts/specialize-patch index f81599e7b..0737325cd 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -242,6 +242,7 @@ function handle_if(evaluated) # kernel version, and do not interpret other expressions. if ($0 ~ "LINUX_VERSION_CODE" \ || $0 ~ "INSIDE_KERNEL_TREE" \ + || $0 ~ "CONFIG_SCST_PROC" \ || $0 ~ "RHEL_MAJOR" \ || $0 ~ "RHEL_MINOR" \ || $0 ~ "RHEL_RELEASE_CODE" \ diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index ee5de2621..162af19fa 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -272,7 +272,6 @@ enum scst_cdb_flags { /************************************************************* * SCSI opcodes not listed anywhere else *************************************************************/ -#define REPORT_DEVICE_IDENTIFIER 0xA3 #define INIT_ELEMENT_STATUS 0x07 #define INIT_ELEMENT_STATUS_RANGE 0x37 #define PREVENT_ALLOW_MEDIUM 0x1E diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index f550b351a..8b57ecbb4 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1322,8 +1322,8 @@ static void vdisk_exec_unmap(struct scst_cmd *cmd, struct scst_vdisk_thr *thr) (unsigned long long)start, len); if (virt_dev->blockio) { - gfp_t gfp = cmd->noio_mem_alloc ? GFP_NOIO : GFP_KERNEL; #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27) + gfp_t gfp = cmd->noio_mem_alloc ? GFP_NOIO : GFP_KERNEL; #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31) err = blkdev_issue_discard(inode->i_bdev, start, len, gfp); @@ -1577,11 +1577,11 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) if (virt_dev->removable) buf[1] = 0x80; /* removable */ buf[2] = 5; /* Device complies to SPC-3 */ - buf[3] = 0x12; /* HiSup + data in format specified in SPC */ + buf[3] = 0x02; /* Data in format specified in SPC */ if (cmd->tgtt->fake_aca) buf[3] |= 0x20; buf[4] = 31;/* n - 4 = 35 - 4 = 31 for full 36 byte data */ - buf[6] = 1; /* MultiP 1 */ + buf[6] = 0x10; /* MultiP 1 */ buf[7] = 2; /* CMDQUE 1, BQue 0 => commands queuing supported */ /* diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index c0f9121a3..0fbcd32f6 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -473,7 +473,7 @@ EXPORT_SYMBOL(scst_unregister_target_template); struct scst_tgt *scst_register_target(struct scst_tgt_template *vtt, const char *target_name) { - struct scst_tgt *tgt; + struct scst_tgt *tgt, *t; int rc = 0; TRACE_ENTRY(); @@ -527,6 +527,14 @@ struct scst_tgt *scst_register_target(struct scst_tgt_template *vtt, if (rc != 0) goto out_free_tgt; + list_for_each_entry(t, &vtt->tgt_list, tgt_list_entry) { + if (strcmp(t->tgt_name, tgt->tgt_name) == 0) { + PRINT_ERROR("target %s already exists", tgt->tgt_name); + rc = -EEXIST; + goto out_unlock; + } + } + #ifdef CONFIG_SCST_PROC rc = scst_build_proc_target_entries(tgt); if (rc < 0) diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index a2740530c..2ae96d5c9 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -339,7 +339,7 @@ out_unlock_put: goto out; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) && (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 6) static int sgv_shrink(int nr, gfp_t gfpm) #else static int sgv_shrink(struct shrinker *shrinker, int nr, gfp_t gfpm) diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index ab31e5386..b83b18bc0 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -21,7 +21,7 @@ #define __SCST_PRIV_H #include - +#include #include #include #include