diff --git a/iscsi-scst/Makefile b/iscsi-scst/Makefile index aa1c03584..52d9410c0 100644 --- a/iscsi-scst/Makefile +++ b/iscsi-scst/Makefile @@ -81,7 +81,9 @@ ifeq ($(OFED_FLAVOR),MOFED) OFED_DIR:=/usr/src/ofa_kernel/default OFED_CFLAGS:= -I$(OFED_DIR)/include \ -I$(OFED_DIR)/include/uapi \ - -include $(OFED_DIR)/include/linux/compat-2.6.h + -include $(OFED_DIR)/include/linux/compat-2.6.h \ + -DMOFED_MAJOR=$(shell echo $(OFED_VERS) | cut -f1 -d.)\ + -DMOFED_MINOR=$(shell echo $(OFED_VERS) | cut -f2 -d.) ISER_SYMVERS:="$(ISER_SYMVERS) $(OFED_DIR)/$(MODULE_SYMVERS)" OFED_CONFIG:= CONFIG_DTRACE= else diff --git a/scripts/specialize-patch b/scripts/specialize-patch index 19fb9d933..9c59e1bf3 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -197,6 +197,22 @@ function evaluate(stmnt, pattern, arg, op, result) { "(\\1) * 256 + (\\2)", "g", stmnt) } + if (MOFED_MAJOR == "") { + gsub("defined\\(MOFED_MAJOR\\)", "0", stmnt) + gsub("MOFED_MAJOR", "", stmnt) + } else { + gsub("defined\\(MOFED_MAJOR\\)", "1", stmnt) + gsub("MOFED_MAJOR", MOFED_MAJOR, stmnt) + } + + if (MOFED_MINOR == "") { + gsub("defined\\(MOFED_MINOR\\)", "0", stmnt) + gsub("MOFED_MINOR", "", stmnt) + } else { + gsub("defined\\(MOFED_MINOR\\)", "1", stmnt) + gsub("MOFED_MINOR", MOFED_MINOR, stmnt) + } + gsub("defined\\(UEK_KABI_RENAME\\)", "0", stmnt) if (SCSI_EXEC_REQ_FIFO_DEFINED != "") @@ -384,6 +400,8 @@ function handle_if(evaluated) || $0 ~ "IB_QUERY_GID_HAS_ATTR_ARG" \ || $0 ~ "INSIDE_KERNEL_TREE" \ || $0 ~ "MAD_HANDLER_TAKES_SEND_BUF" \ + || $0 ~ "MOFED_MAJOR" \ + || $0 ~ "MOFED_MINOR" \ || $0 ~ "RDMA_CREATE_ID_TAKES_NET_ARG" \ || $0 ~ "REGISTER_MAD_AGENT_HAS_FLAGS_ARG" \ || $0 ~ "RHEL_MAJOR" \ diff --git a/scst/include/backport.h b/scst/include/backport.h index 3ebdf5770..853faf8ea 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -905,7 +905,9 @@ static inline void *kvzalloc(size_t size, gfp_t flags) } #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) && \ + (!defined(MOFED_MAJOR) || !defined(MOFED_MINOR) || \ + MOFED_MAJOR < 4 || (MOFED_MAJOR == 4 && MOFED_MINOR < 5)) /* See also commit 1c542f38ab8d ("mm: Introduce kvcalloc()") # v4.18. */ static inline void *kvcalloc(size_t n, size_t size, gfp_t flags) { diff --git a/srpt/Makefile b/srpt/Makefile index 159a15577..d262a64dc 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -67,6 +67,8 @@ OFED_VERS=$(OFED_RPM_VERS)$(OFED_DEB_VERS) OFED_CFLAGS:=-I$(OFED_KERNEL_DIR)/include \ -I$(OFED_KERNEL_DIR)/include/uapi \ -include "linux/compat-2.6.h" +OFED_CFLAGS+=-DMOFED_MAJOR=$(shell echo "$(OFED_VERS)" | sed 's/\([0-9]\+\)[^0-9]\+\([0-9]\+\).*/\1/g') +OFED_CFLAGS+=-DMOFED_MINOR=$(shell echo "$(OFED_VERS)" | sed 's/\([0-9]\+\)[^0-9]\+\([0-9]\+\).*/\2/g') else # OFED 1.5 OFED_KERNEL_DIR:=/usr/src/ofa_kernel