From 9e700c6c03956dc7a1186faaa6a846c10be4622f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 15 Jun 2015 14:41:35 +0000 Subject: [PATCH 1/3] iscsi-scst/Makefile: Only build the iSER target driver if InfiniBand has been enabled in the kernel config git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6313 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/Makefile | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/iscsi-scst/Makefile b/iscsi-scst/Makefile index b9f16e358..2291e6269 100644 --- a/iscsi-scst/Makefile +++ b/iscsi-scst/Makefile @@ -48,6 +48,7 @@ ifeq ($(INSTALL_MOD_PATH),) endif INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra +INFINIBAND_ENABLED := $(shell if grep -q '^CONFIG_INFINIBAND=[my]$$' $(KDIR)/.config; then echo true; else echo false; fi) all: include/iscsi_scst_itf_ver.h progs mods @@ -102,7 +103,11 @@ endif mods: Modules.symvers Module.symvers echo " Building against $(OFED_FLAVOR) InfiniBand kernel headers." $(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(KMOD) modules - $(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(ISERTMOD) PRE_CFLAGS="$(OFED_CFLAGS) -DOFED_FLAVOR=$(OFED_FLAVOR)" KBUILD_EXTRA_SYMBOLS=$(ISER_SYMVERS) modules + if $(INFINIBAND_ENABLED); then \ + $(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(ISERTMOD) \ + PRE_CFLAGS="$(OFED_CFLAGS) -DOFED_FLAVOR=$(OFED_FLAVOR)" \ + KBUILD_EXTRA_SYMBOLS=$(ISER_SYMVERS) modules; \ + fi progs: $(MAKE) -C usr SCST_INC_DIR=$(SCST_INC_DIR) @@ -123,9 +128,11 @@ install: all $(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(KMOD) \ $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ modules_install - $(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(ISERTMOD) \ - $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ - modules_install + if $(INFINIBAND_ENABLED); then \ + $(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(ISERTMOD) \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ + modules_install + fi uninstall: rm -f $(DESTDIR)$(SBINDIR)/iscsi-scstd \ @@ -142,7 +149,9 @@ ifneq ($(SCST_MOD_VERS),) Modules.symvers: $(SCST_DIR)/Modules.symvers echo $(SCST_MOD_VERS) cp $(SCST_DIR)/Modules.symvers kernel/ - cp $(SCST_DIR)/Modules.symvers kernel/isert-scst + if $(INFINIBAND_ENABLED); then \ + cp $(SCST_DIR)/Modules.symvers kernel/isert-scst; \ + fi else .PHONY: Modules.symvers endif @@ -152,7 +161,9 @@ SCST_MOD_VERS := $(shell ls $(SCST_DIR)/Module.symvers 2>/dev/null) ifneq ($(SCST_MOD_VERS),) Module.symvers: $(SCST_DIR)/Module.symvers cp $(SCST_DIR)/Module.symvers kernel/ - cp $(SCST_DIR)/Module.symvers kernel/isert-scst + if $(INFINIBAND_ENABLED); then \ + cp $(SCST_DIR)/Module.symvers kernel/isert-scst; \ + fi else .PHONY: Module.symvers endif From 15535bf6489c48bc850e28245e149fcf3810251c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 15 Jun 2015 22:06:29 +0000 Subject: [PATCH 2/3] iscsi-scst: Suppress a compiler warning Avoid that the compiler complains that the variable 'pad_bytes' is not used with CONFIG_LIBCRC32C=n. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6314 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/digest.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/iscsi-scst/kernel/digest.c b/iscsi-scst/kernel/digest.c index 1da1a04d0..29f9e645d 100644 --- a/iscsi-scst/kernel/digest.c +++ b/iscsi-scst/kernel/digest.c @@ -61,7 +61,6 @@ static __be32 evaluate_crc32_from_sg(struct scatterlist *sg, int nbytes, uint32_t padding) { u32 crc = ~0; - int pad_bytes = ((nbytes + 3) & -4) - nbytes; #ifdef CONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES if (((scst_random() % 100000) == 752)) { @@ -71,15 +70,19 @@ static __be32 evaluate_crc32_from_sg(struct scatterlist *sg, int nbytes, #endif #if defined(CONFIG_LIBCRC32C_MODULE) || defined(CONFIG_LIBCRC32C) - while (nbytes > 0) { - int d = min(nbytes, (int)(sg->length)); - crc = crc32c(crc, sg_virt(sg), d); - nbytes -= d; - sg++; - } + { + int pad_bytes = ((nbytes + 3) & -4) - nbytes; - if (pad_bytes) - crc = crc32c(crc, (u8 *)&padding, pad_bytes); + while (nbytes > 0) { + int d = min(nbytes, (int)(sg->length)); + crc = crc32c(crc, sg_virt(sg), d); + nbytes -= d; + sg++; + } + + if (pad_bytes) + crc = crc32c(crc, (u8 *)&padding, pad_bytes); + } #endif return (__force __be32)~cpu_to_le32(crc); From 7566e2ed71b1ef79b82eac05e77e901e650b8f2d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 15 Jun 2015 22:15:07 +0000 Subject: [PATCH 3/3] Avoid that compiler warnings depend on the build mode It is annoying that some warnings are only reported in release mode. Modify scst_debug.h such that the compiler does not report variables that are only used in debug builds as unused. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6315 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/iscsi.h | 2 -- iscsi-scst/kernel/iscsi_dbg.h | 2 +- scst/include/scst.h | 10 ++++++++++ scst/include/scst_debug.h | 32 ++++++++++++++++++------------ scst/src/dev_handlers/scst_vdisk.c | 3 +-- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/iscsi-scst/kernel/iscsi.h b/iscsi-scst/kernel/iscsi.h index 908068bd0..5875fbd2a 100644 --- a/iscsi-scst/kernel/iscsi.h +++ b/iscsi-scst/kernel/iscsi.h @@ -280,9 +280,7 @@ struct iscsi_conn { struct list_head rd_list_entry; -#ifdef CONFIG_SCST_EXTRACHECKS struct task_struct *rd_task; -#endif unsigned long last_rcv_time; diff --git a/iscsi-scst/kernel/iscsi_dbg.h b/iscsi-scst/kernel/iscsi_dbg.h index 6f6e247b8..408cdc4c8 100644 --- a/iscsi-scst/kernel/iscsi_dbg.h +++ b/iscsi-scst/kernel/iscsi_dbg.h @@ -52,7 +52,7 @@ extern unsigned long iscsi_get_flow_ctrl_or_mgmt_dbg_log_flag( struct iscsi_cmnd *cmnd); #else #define iscsi_dump_pdu(x) do {} while (0) -#define iscsi_get_flow_ctrl_or_mgmt_dbg_log_flag(x) do {} while (0) +#define iscsi_get_flow_ctrl_or_mgmt_dbg_log_flag(x) 0 #endif #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) diff --git a/scst/include/scst.h b/scst/include/scst.h index 975463def..c393205fa 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -247,6 +247,16 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q) #endif #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) && \ + (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 6) +/* + * See also patch "Add a dummy printk function for the maintenance of unused + * printks" (commit 12fdff3fc2483f906ae6404a6e8dcf2550310b6f). + */ +static inline __attribute__ ((format (printf, 1, 2))) +int no_printk(const char *s, ...) { return 0; } +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) /* * See also patch "sched: Fix softirq time accounting" (commit ID diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index 878d188b6..28c396466 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -224,9 +224,12 @@ do { \ #define TRACING_MINOR() (false) -#define TRACE(trace, format, args...) do {} while (0) -#define PRINT_BUFFER(message, buff, len) do {} while (0) -#define PRINT_BUFF_FLAG(flag, message, buff, len) do {} while (0) +#define TRACE(trace, format, args...) \ + ((void)(trace), no_printk(format, ##args)) +#define PRINT_BUFFER(message, buff, len) \ + ((void)(message), (void)(buff), (void)(len)) +#define PRINT_BUFF_FLAG(flag, message, buff, len) \ + ((void)(flag), (void)(message), (void)(buff), (void)(len)) #endif /* CONFIG_SCST_DEBUG || CONFIG_SCST_TRACING */ @@ -353,17 +356,20 @@ do { \ #else /* CONFIG_SCST_DEBUG */ -#define TRACE_MEM(format, args...) do {} while (0) -#define TRACE_SG(format, args...) do {} while (0) -#define TRACE_DBG(format, args...) do {} while (0) -#define TRACE_DBG_FLAG(format, args...) do {} while (0) -#define TRACE_DBG_SPECIAL(format, args...) do {} while (0) -#define TRACE_MGMT_DBG(format, args...) do {} while (0) -#define TRACE_MGMT_DBG_SPECIAL(format, args...) do {} while (0) +#define TRACE_MEM(format, args...) no_printk(format, ##args) +#define TRACE_SG(format, args...) no_printk(format, ##args) +#define TRACE_DBG(format, args...) no_printk(format, ##args) +#define TRACE_DBG_FLAG(flag, format, args...) \ + ((void)(flag), no_printk(format, ##args)) +#define TRACE_DBG_SPECIAL(format, args...) no_printk(format, ##args) +#define TRACE_MGMT_DBG(format, args...) no_printk(format, ##args) +#define TRACE_MGMT_DBG_SPECIAL(format, args...) no_printk(format, ##args) #define TRACE_PR(format, args...) do {} while (0) -#define TRACE_BLOCK(format, args...) do {} while (0) -#define TRACE_BUFFER(message, buff, len) do {} while (0) -#define TRACE_BUFF_FLAG(flag, message, buff, len) do {} while (0) +#define TRACE_BLOCK(format, args...) no_printk(format, ##args) +#define TRACE_BUFFER(message, buff, len) \ + ((void)(message), (void)(buff), (void)(len)) +#define TRACE_BUFF_FLAG(flag, message, buff, len) \ + ((void)(flag), (void)(message), (void)(buff), (void)(len)) #ifndef GENERATING_UPSTREAM_PATCH #define TRACE_ENTRY() do {} while (0) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index e25753ec1..2ac5a37c4 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -60,10 +60,9 @@ #include "scst.h" #endif -#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) - #define TRACE_ORDER 0x80000000 +#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) static struct scst_trace_log vdisk_local_trace_tbl[] = { { TRACE_ORDER, "order" }, { 0, NULL }