[openfabrics-ewg] [PATCH 1/4] IB/iSER: Integrate open-iscsi into the OFED build scripts

Erez Zilber erezz at voltaire.com
Mon Jan 1 06:18:20 PST 2007


Erez Zilber wrote:
> Add open-iscsi into configure & Makefile.
> 
> Signed-off-by: Erez Zilber <erezz at voltaire.com>
> 

Consider the following patch instead. It adds a wrapper to Makefile (install.sh). install.sh builds & installs open-iscsi (if iSER was selected). Then, it fixes the symbols's CRC for open-iscsi in Module.symvers (see my other e-mail with subject "Fixing Module.symvers while building OFED"). Then, it builds and installs IB modules and fixes the CRC for them.

diff -ruN ofa_1_2_kernel-20061228-0200/Makefile ofa_1_2_kernel-20061228-0200-open-iscsi/Makefile
--- ofa_1_2_kernel-20061228-0200/Makefile	2006-12-28 12:00:04.000000000 +0200
+++ ofa_1_2_kernel-20061228-0200-open-iscsi/Makefile	2007-01-01 11:59:18.000000000 +0200
@@ -1,7 +1,7 @@
 # $Id: Makefile 9120 2006-08-28 13:01:07Z vlad $
 
 all:
-.PHONY: all kernel install_kernel install_modules install clean clean_kernel uninstall
+.PHONY: all kernel_ib kernel_iscsi install_kernel_ib install_kernel_iscsi install_modules install clean clean_kernel uninstall
 	
 .DELETE_ON_ERROR:
 
@@ -15,13 +15,15 @@
         export KERNEL_MEMTRACK_CFLAGS =
 endif
 
+export OPEN_ISCSI_MODULES = iscsi_tcp.ko libiscsi.ko scsi_transport_iscsi.ko
+
 configure.mk:
 	@echo Please run ./configure.kernel
 	@exit 1
 
-all: kernel
+all: kernel_ib
 
-install: install_kernel
+install: install_kernel_ib
 
 #########################
 #	make kernel	#
@@ -29,7 +31,7 @@
 #NB: The LINUXINCLUDE value comes from main kernel Makefile
 #    with local directories prepended. This eventually affects
 #    CPPFLAGS in the kernel Makefile
-kernel:
+kernel_ib:
 	@echo "Building kernel modules"
 	@echo "Kernel version: $(KVERSION)"
 	@echo "Modules directory: $(DESTDIR)/$(MODULES_DIR)"
@@ -75,13 +77,30 @@
 		' \
 		modules
 
+kernel_iscsi:
+	if [ "$(CONFIG_INFINIBAND_ISER)" == "m" ]; then \
+		echo "Building open-iscsi"; \
+		$(MAKE) -C $(KSRC) SUBDIRS="$(CWD)/drivers/scsi" KERNELRELEASE=$(KVERSION) \
+			EXTRAVERSION=$(EXTRAVERSION) V=1 $(WITH_MAKE_PARAMS) \
+			CONFIG_SCSI_ISCSI_ATTRS=$(CONFIG_SCSI_ISCSI_ATTRS) \
+			CONFIG_ISCSI_TCP=$(CONFIG_ISCSI_TCP) \
+			LINUXINCLUDE=' \
+			$(BACKPORT_INCLUDES) \
+			-I$(CWD)/include \
+			-Iinclude \
+			$$(if $$(KBUILD_SRC),-Iinclude2 -I$$(srctree)/include) \
+			-include include/linux/autoconf.h \
+			-include $(CWD)/include/linux/autoconf.h \
+			' \
+			modules; \
+	fi		
 
 #########################
 #	Install kernel	#
 #########################
-install_kernel: install_modules
+install_kernel_ib: install_modules
 
-install_modules: kernel
+install_modules: kernel_ib
 	@echo "Installing kernel modules"
 	
 	$(MAKE) -C $(KSRC) SUBDIRS="$(CWD)/drivers/infiniband" \
@@ -100,8 +119,8 @@
 			mv $(DESTDIR)/$(prefix)/backup/infko_tmp.tgz $(DESTDIR)/$(prefix)/backup/infiniband_ko-$(KVERSION).tgz; \
 		fi; \
 		/bin/rm -rf $(DESTDIR)/$(MODULES_DIR)/kernel/drivers/infiniband; \
-	fi
-	
+	fi;
+
 	# Copy new infiniband kernel modules to $(DESTDIR)/$(MODULES_DIR)/kernel/drivers/infiniband
 	if [ -d $(CWD)/lib/modules/$(KVERSION)/infiniband ]; then \
 		mkdir -p $(DESTDIR)/$(MODULES_DIR)/kernel/drivers; \
@@ -114,6 +133,50 @@
 
 	$(DEPMOD) -r -ae $(KVERSION)
 
+ifeq ($(CONFIG_INFINIBAND_ISER),m)
+install_kernel_iscsi:
+	$(MAKE) -C $(KSRC) SUBDIRS="$(CWD)/drivers/scsi" \
+		KERNELRELEASE=$(KVERSION) EXTRAVERSION=$(EXTRAVERSION) \
+		INSTALL_MOD_DIR="scsi" INSTALL_MOD_PATH=$(CWD) \
+		$(WITH_MAKE_PARAMS) modules_install; \
+
+	# Backup original open-iscsi modules
+	# under 'prefix'/backup directory
+	if [ -d $(DESTDIR)/$(MODULES_DIR)/kernel/drivers/scsi ]; then \
+		mkdir -p $(DESTDIR)/$(prefix)/backup; \
+		if [ ! -f $(DESTDIR)/$(prefix)/backup/open_iscsi_ko-$(KVERSION).tgz ]; then \
+			open_iscsi_mods_full_path=""; \
+			for open_iscsi_module in $(OPEN_ISCSI_MODULES); \
+			do \
+				open_iscsi_mods_full_path="$(DESTDIR)/$(MODULES_DIR)/kernel/drivers/scsi/$$open_iscsi_module $$open_iscsi_mods_full_path"; \
+			done; \
+			tar czfP $(DESTDIR)/$(prefix)/backup/open_iscsi_ko-$(KVERSION).tgz $$open_iscsi_mods_full_path; \
+		fi; \
+		for open_iscsi_module in $(OPEN_ISCSI_MODULES); \
+		do \
+			(/bin/rm -f $(DESTDIR)/$(MODULES_DIR)/kernel/drivers/scsi/$$open_iscsi_module ); \
+		done; \
+	fi;
+
+	# Copy new open-iscsi kernel modules to $(DESTDIR)/$(MODULES_DIR)/kernel/drivers/scsi	
+	if [ -d $(CWD)/lib/modules/$(KVERSION)/scsi ]; then \
+		mkdir -p $(DESTDIR)/$(MODULES_DIR)/kernel/drivers; \
+		for open_iscsi_module in $(OPEN_ISCSI_MODULES); \
+		do \
+			(mv $(CWD)/lib/modules/$(KVERSION)/scsi/$$open_iscsi_module $(DESTDIR)/$(MODULES_DIR)/kernel/drivers/scsi ); \
+		done; \
+	fi; \
+	if [ -d $(CWD)/lib/modules/$(KVERSION)/extra ]; then \
+		mkdir -p $(DESTDIR)/$(MODULES_DIR)/kernel/drivers; \
+		for open_iscsi_module in $(OPEN_ISCSI_MODULES); \
+		do \
+			(mv $(CWD)/lib/modules/$(KVERSION)/extra/$$open_iscsi_module $(DESTDIR)/$(MODULES_DIR)/kernel/drivers/scsi ); \
+		done; \
+	fi;
+
+	$(DEPMOD) -r -ae $(KVERSION)
+endif
+
 clean: clean_kernel
 
 clean_kernel:
@@ -126,18 +189,31 @@
 		/bin/rm -f $(DESTDIR)/$(prefix)/backup/infiniband_ko-$(KVERSION).tgz; \
 	fi
 
+ifeq ($(CONFIG_INFINIBAND_ISER),m)	
+	if [ -f $(DESTDIR)/$(prefix)/backup/open_iscsi_ko-$(KVERSION).tgz ]; then \
+		for open_iscsi_module in $(OPEN_ISCSI_MODULES); \
+		do \
+		       (/bin/rm $(DESTDIR)/$(MODULES_DIR)/kernel/drivers/scsi/$$open_iscsi_module ); \
+		done; \
+		tar xzfP $(DESTDIR)/$(prefix)/backup/open_iscsi_ko-$(KVERSION).tgz; \
+		/bin/rm -f $(DESTDIR)/$(prefix)/backup/open_iscsi_ko-$(KVERSION).tgz; \
+	fi;
+endif	
+
 	$(DEPMOD) -r -ae $(KVERSION)
 
 help:
 	@echo
-	@echo kernel: 		build kernel modules
-	@echo all: 		build kernel modules
+	@echo kernel_ib: 		build InfiniBand kernel modules
+	@echo kernel_iscsi: 		build iSCSI kernel modules	
+	@echo all: 			build kernel_ib modules
 	@echo
-	@echo install_kernel:	install kernel modules under $(DESTDIR)/$(MODULES_DIR)
-	@echo install_modules:	install kernel modules under $(DESTDIR)/$(MODULES_DIR)
-	@echo install:		run install_kernel
+	@echo install_kernel_ib:	install InfiniBand kernel modules under $(DESTDIR)/$(MODULES_DIR)
+	@echo install_kernel_iscsi:	install iSCSI kernel modules under $(DESTDIR)/$(MODULES_DIR)	
+	@echo install_modules:		install kernel modules under $(DESTDIR)/$(MODULES_DIR)
+	@echo install:			run install_kernel_ib
 	@echo
-	@echo clean:		delete kernel modules binaries
-	@echo clean_kernel:	delete kernel modules binaries
-	@echo uninstall:	delete installed environment
+	@echo clean:			delete kernel modules binaries
+	@echo clean_kernel:		delete kernel modules binaries
+	@echo uninstall:		delete installed environment
 	@echo
diff -ruN ofa_1_2_kernel-20061228-0200/configure ofa_1_2_kernel-20061228-0200-open-iscsi/configure
--- ofa_1_2_kernel-20061228-0200/configure	2006-12-28 12:00:04.000000000 +0200
+++ ofa_1_2_kernel-20061228-0200-open-iscsi/configure	2006-12-31 14:53:45.000000000 +0200
@@ -555,9 +555,13 @@
                         ;;
                         --with-iser-mod)
                             CONFIG_INFINIBAND_ISER="m"
+                            CONFIG_SCSI_ISCSI_ATTRS="m"
+                            CONFIG_ISCSI_TCP="m"
                         ;;
                         --without-iser-mod)
                             CONFIG_INFINIBAND_ISER=
+                            CONFIG_SCSI_ISCSI_ATTRS=
+                            CONFIG_ISCSI_TCP=
                         ;;
                         --with-ehca-mod)
                             CONFIG_INFINIBAND_EHCA="m"
@@ -667,6 +671,8 @@
 
 CONFIG_INFINIBAND_IPOIB_DEBUG=${CONFIG_INFINIBAND_IPOIB_DEBUG:-''}
 CONFIG_INFINIBAND_ISER=${CONFIG_INFINIBAND_ISER:-''}
+CONFIG_SCSI_ISCSI_ATTRS=${CONFIG_SCSI_ISCSI_ATTRS:-''}
+CONFIG_ISCSI_TCP=${CONFIG_ISCSI_TCP:-''}
 CONFIG_INFINIBAND_EHCA=${CONFIG_INFINIBAND_EHCA:-''}
 CONFIG_INFINIBAND_EHCA_SCALING=${CONFIG_INFINIBAND_EHCA_SCALING:-''}
 CONFIG_INFINIBAND_RDS=${CONFIG_INFINIBAND_RDS:-''}
@@ -728,6 +734,8 @@
 
 CONFIG_INFINIBAND_IPOIB_DEBUG=${CONFIG_INFINIBAND_IPOIB_DEBUG}
 CONFIG_INFINIBAND_ISER=${CONFIG_INFINIBAND_ISER}
+CONFIG_SCSI_ISCSI_ATTRS=${CONFIG_SCSI_ISCSI_ATTRS}
+CONFIG_ISCSI_TCP=${CONFIG_ISCSI_TCP}
 CONFIG_INFINIBAND_EHCA=${CONFIG_INFINIBAND_EHCA}
 CONFIG_INFINIBAND_EHCA_SCALING=${CONFIG_INFINIBAND_EHCA_SCALING}
 CONFIG_INFINIBAND_RDS=${CONFIG_INFINIBAND_RDS}
@@ -797,8 +805,12 @@
 fi
 if [ "X${CONFIG_INFINIBAND_ISER}" == "Xm" ]; then
         DEFINE_INFINIBAND_ISER="#define CONFIG_INFINIBAND_ISER 1"
+        DEFINE_SCSI_ISCSI_ATTRS="#define CONFIG_SCSI_ISCSI_ATTRS 1"
+        DEFINE_ISCSI_TCP="#define CONFIG_ISCSI_TCP 1"
 else
         DEFINE_INFINIBAND_ISER="#undef CONFIG_INFINIBAND_ISER"
+        DEFINE_SCSI_ISCSI_ATTRS="#undef CONFIG_SCSI_ISCSI_ATTRS"
+        DEFINE_ISCSI_TCP="#undef CONFIG_ISCSI_TCP"
 fi
 if [ "X${CONFIG_INFINIBAND_EHCA}" == "Xm" ]; then
         DEFINE_INFINIBAND_EHCA="#define CONFIG_INFINIBAND_EHCA 1"
@@ -918,6 +930,8 @@
 
 ${DEFINE_INFINIBAND_IPOIB_DEBUG}
 ${DEFINE_INFINIBAND_ISER}
+${DEFINE_SCSI_ISCSI_ATTRS}
+${DEFINE_ISCSI_TCP}
 ${DEFINE_INFINIBAND_EHCA}
 ${DEFINE_INFINIBAND_RDS}
 ${DEFINE_INFINIBAND_RDS_DEBUG}
diff -ruN ofa_1_2_kernel-20061228-0200/install.sh ofa_1_2_kernel-20061228-0200-open-iscsi/install.sh
--- ofa_1_2_kernel-20061228-0200/install.sh	1970-01-01 02:00:00.000000000 +0200
+++ ofa_1_2_kernel-20061228-0200-open-iscsi/install.sh	2007-01-01 12:33:50.000000000 +0200
@@ -0,0 +1,188 @@
+#!/bin/bash
+#
+# Copyright (C) Voltaire Ltd. 2007.  ALL RIGHTS RESERVED.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Author: Erez Zilber <erezz at voltaire.com>
+
+OPEN_ISCSI_MODULES="iscsi_tcp.ko libiscsi.ko scsi_transport_iscsi.ko"
+BCKP_DIR=/backup
+TMP_DIR=/tmp/ofed
+
+usage="Usage: $0 -i|-u"
+
+fix_symbol_crc()
+{
+	patch_ext=$1
+	shift
+	
+	echo "Fixing CRC for $patch_ext modules"
+
+	mkdir -p $TMP_DIR
+	rm -f $TMP_DIR/syms
+
+	n_mods=0
+
+	until [ -z "$1" ]
+	do
+		pkg_kernel_modules=$pkg_kernel_modules" "$1
+		shift
+	done
+	
+	for mod in $pkg_kernel_modules ; do
+		mod_name=$(basename $mod | cut -d"." -f1)
+		mod_name=$(modinfo $mod_name | grep filename | awk '{print $2}')
+		echo "fixing CRC for $mod_name"
+		nm -o $mod_name | grep __crc >> $TMP_DIR/syms
+		n_mods=$((n_mods+1))
+	done
+
+	n_syms=$(wc -l $TMP_DIR/syms |cut -f1 -d" ")
+	echo found $n_syms symbols in $n_mods modules
+	n=1
+   
+	MOD_SYMVERS_PKG=$TMP_DIR/Module.symvers.pkg
+	MOD_SYMVERS_PATCH=$TMP_DIR/Module.symvers.patch_$patch_ext
+
+	# make sure that we use a new patch file
+	rm -f $MOD_SYMVERS_PATCH
+
+	# find Module.symvers file
+	if [ -f /lib/modules/`uname -r`/source/Module.symvers ] ; then
+		MOD_SYMVERS_KERNEL=/lib/modules/`uname -r`/source/Module.symvers
+	elif [ -f /lib/modules/`uname -r`/build/Module.symvers ] ; then
+		MOD_SYMVERS_KERNEL=/lib/modules/`uname -r`/build/Module.symvers
+	else
+		echo file Module.symvers not found
+	fi
+   
+	if [ ! -z $MOD_SYMVERS_KERNEL ] ; then
+   
+		rm -f $MOD_SYMVERS_PKG
+   
+		# Build the new symbols
+		while [ $n -le $n_syms ] ; do
+			line=$(head -$n $TMP_DIR/syms|tail -1)
+			mod_path=$(echo $line|cut -f1 -d:)
+			symbol_crc=$(echo $line|cut -f2 -d:)
+			file=$(echo $mod_path|cut -f5- -d/)
+			file=$(echo $file|cut -f1 -d.)
+
+			crc=$(echo $symbol_crc|cut -f1 -d" ")
+			crc=${crc:8}
+			sym=$(echo $symbol_crc|cut -f3 -d" ")
+			sym=${sym:6}
+			echo -e  "0x$crc\t$sym\t$file" >> $MOD_SYMVERS_PKG
+			if [ -z $allsyms ] ; then
+				allsyms=$sym
+			else
+				allsyms="$allsyms|$sym"
+			fi
+			n=$((n+1))
+		done
+
+		# Add all other kernel symbols
+		egrep -v "$allsyms" $MOD_SYMVERS_KERNEL >> $MOD_SYMVERS_PKG
+		
+		diff -u $MOD_SYMVERS_KERNEL $MOD_SYMVERS_PKG > $MOD_SYMVERS_PATCH
+		patch -d $(dirname $MOD_SYMVERS_KERNEL) < $MOD_SYMVERS_PATCH
+		mkdir -p $BCKP_DIR
+		mv $MOD_SYMVERS_PATCH $BCKP_DIR
+	fi
+}
+
+restore_symbol_crc()
+{
+	patch_ext=$1
+
+	echo "Restoring CRC for $patch_ext modules"
+		
+	MOD_SYMVERS_PATCH=$BCKP_DIR/Module.symvers.patch_$patch_ext
+	
+	if [ -f /lib/modules/`uname -r`/source/Module.symvers ] ; then
+		MOD_SYMVERS_KERNEL=/lib/modules/`uname -r`/source/Module.symvers
+	elif [ -f /lib/modules/`uname -r`/build/Module.symvers ] ; then
+		MOD_SYMVERS_KERNEL=/lib/modules/`uname -r`/build/Module.symvers
+	else
+		echo file Module.symvers not found
+	fi
+
+	# apply the backward patch and delete it
+	patch -d $(dirname $MOD_SYMVERS_KERNEL) -R  < $MOD_SYMVERS_PATCH
+        rm $MOD_SYMVERS_PATCH
+
+	# if the backup dir is empty, delete it
+	if [ `ls -A $BCKP_DIR | wc -l` -eq 0 ] ; then
+		echo "removing $BCKP_DIR"
+		rm -rf $BCKP_DIR
+	fi
+}
+
+install()
+{
+	# Build and install open-iscsi (if iSER was selected)
+	if [ $(grep -c "CONFIG_INFINIBAND_ISER 1" $(pwd)/include/linux/autoconf.h) -eq 1 ]; then
+		make kernel_iscsi
+		make install_kernel_iscsi
+    
+		# Fix CRC for open-iscsi modules
+		fix_symbol_crc open-iscsi $OPEN_ISCSI_MODULES
+	fi
+    
+	# Build and install InfiniBand
+	make kernel_ib
+	make install_kernel_ib
+
+	# Fix CRC for InfiniBand modules
+	ib_mods=""
+	for mod in $(find $(pwd)/drivers/infiniband -name *.ko) ; do
+		ib_mods=$(basename $mod)" $ib_mods"
+	done
+	echo "ib_mods = $ib_mods"
+	fix_symbol_crc ib $ib_mods
+}
+
+uninstall()
+{
+	# Restore symbols for InfiniBand
+	restore_symbol_crc ib
+
+	# Restore symbolds for open-iscsi if iSER was selected
+	if [ $(grep -c "CONFIG_INFINIBAND_ISER 1" $(pwd)/include/linux/autoconf.h) -eq 1 ]; then
+		restore_symbol_crc open-iscsi
+	fi
+	
+	make uninstall
+}
+
+while getopts "iu" opt
+do
+	case ${opt} in
+	i) install
+		exit 0
+		;;
+	u) uninstall
+		exit 0
+		;;
+	*)
+		echo $usage
+		exit 1
+	esac
+done
+
+echo ${usage}
+
+





More information about the ewg mailing list