From cef1b4cdffe5568b6956d7e8c73a5390db50dec3 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 8 Oct 2010 19:30:39 +0000 Subject: [PATCH] The changes included in the patch below are: - If someone tries to build SCST on an RHEL 5 system without having run 'make enable_proc' first, complain. - Do not define set_cpus_allowed_ptr() on RHEL 5 since RHEL 5 does have a declaration for this function. The function itself is not exported from the kernel however (this is probably a bug). Because of that, replace the call to set_cpus_allowed_ptr() in scst_main.c by a call to set_cpus_allowed(). - Do not define the variable 'err' on kernels where that variable is not used in order to avoid a compiler warning. - Also in scst_vdisk.c, pass a 16-bit value as the first argument of put_unaligned() when writing to a 16-bit variable in order to avoid a compiler warning. Signed-off-by: Bart Van Assche with fixes and additions: - In scst_vdisk.c we need 32-bit values, not 16, fixed - Optimal UNMAP granuality changed to 1. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2377 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 4 +++- scst/src/dev_handlers/scst_vdisk.c | 17 +++++++++++------ scst/src/scst_main.c | 5 +++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index dc2551bbf..6b01af6b6 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -33,6 +33,8 @@ #ifdef CONFIG_SCST_PROC #include #include +#elif defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 5 +#error The SCST sysfs interface is not supported on RHEL 5. Please run 'make enable_proc'. #endif #include @@ -122,7 +124,7 @@ static inline void cpumask_copy(cpumask_t *dstp, } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) && !defined(RHEL_MAJOR) static inline int set_cpus_allowed_ptr(struct task_struct *p, const cpumask_t *new_mask) { diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 5cc83de9c..12c795c39 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1353,7 +1353,9 @@ static void vdisk_exec_unmap(struct scst_cmd *cmd, struct scst_vdisk_thr *thr) } while ((offset - 8) < descriptor_len) { +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27) int err; +#endif uint64_t start; uint32_t len; start = be64_to_cpu(get_unaligned((__be64 *)&address[offset])); @@ -1566,7 +1568,7 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) put_unaligned(cpu_to_be32(max_transfer), (uint32_t *)&buf[8]); /* - * Let's have optimal transfer len 1MB. Better to not + * Let's have optimal transfer len 512KB. Better to not * set it at all, because we don't have such limit, * but some initiators may not understand that (?). * From other side, too big transfers are not optimal, @@ -1574,15 +1576,18 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) */ put_unaligned(cpu_to_be32(min_t(int, max_transfer, - 1*1024*1024 / virt_dev->block_size)), + 512*1024 / virt_dev->block_size)), (uint32_t *)&buf[12]); if (virt_dev->thin_provisioned) { /* MAXIMUM UNMAP LBA COUNT is UNLIMITED */ - put_unaligned(cpu_to_be32(0xFFFFFFFF), - (uint16_t *)&buf[20]); + put_unaligned(__constant_cpu_to_be32(0xFFFFFFFF), + (uint32_t *)&buf[20]); /* MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT is UNLIMITED */ - put_unaligned(cpu_to_be32(0xFFFFFFFF), - (uint16_t *)&buf[24]); + put_unaligned(__constant_cpu_to_be32(0xFFFFFFFF), + (uint32_t *)&buf[24]); + /* OPTIMAL UNMAP GRANULARITY is 1 */ + put_unaligned(__constant_cpu_to_be32(1), + (uint32_t *)&buf[28]); } resp_len = buf[3] + 4; } else if ((0xB2 == cmd->cdb[2]) && diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 6479639bc..f994ff42e 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -1575,8 +1575,13 @@ int scst_add_threads(struct scst_cmd_threads *cmd_threads, strlcpy(nm, tgt_dev->dev->virt_name, ARRAY_SIZE(nm)); thr->cmd_thread = kthread_create(scst_cmd_thread, cmd_threads, "%s%d_%d", nm, tgt_dev_num, n++); +#ifdef RHEL_MAJOR + rc = set_cpus_allowed(thr->cmd_thread, + tgt_dev->sess->acg->acg_cpu_mask); +#else rc = set_cpus_allowed_ptr(thr->cmd_thread, &tgt_dev->sess->acg->acg_cpu_mask); +#endif if (rc != 0) PRINT_ERROR("Setting CPU affinity failed: " "%d", rc);