diff --git a/scripts/generate-kernel-patch b/scripts/generate-kernel-patch index cc95d7a67..d41d188e9 100755 --- a/scripts/generate-kernel-patch +++ b/scripts/generate-kernel-patch @@ -373,18 +373,33 @@ rm -rf "${tmpdir}" for s in ${separate_patches} do - fileset=$s - for f in $(set | grep "^$s=" | sed -e "s/^$s='\(.*\)'\$/\1/" -e "s/^$s=\(.*\)\$/\1/") - do - if [ "${f#scst/include}" != "${f}" ]; then - add_file "${f}" "include/scst/${f#scst/include/}" - elif [ "${f#doc}" != "${f}" ]; then - add_file "${f}" "Documentation/scst/${f#doc/}" - else - add_file "${f}" "drivers/scst/${f#scst/src/}" + { + fileset=$s + for f in $(set | grep "^$s=" | sed -e "s/^$s='\(.*\)'\$/\1/" -e "s/^$s=\(.*\)\$/\1/") + do + if [ "${f#scst/include}" != "${f}" ]; then + add_file "${f}" "include/scst/${f#scst/include/}" + elif [ "${f#doc}" != "${f}" ]; then + add_file "${f}" "Documentation/scst/${f#doc/}" + else + add_file "${f}" "drivers/scst/${f#scst/src/}" + fi + done + if grep -q /scst_itf_ver.h scst/src/Makefile && + [ "$s" = "scst_03_public_headers" ]; then + tmp_itf_ver="$(mktemp /tmp/scst-itf-ver.h.XXXXXXXXXX)" + cat <<"EOF" >$tmp_itf_ver +/* Autogenerated, don't edit */ + +#define SCST_INTF_VER "SCST_INTF_VER" +#define SCST_CONST_INTF_VER "SCST_CONST_INTF_VER" +#define DEV_USER_INTF_VER "DEV_USER_INTF_VER" +EOF + add_file "$tmp_itf_ver" "include/scst/scst_itf_ver.h" + rm -f "$tmp_itf_ver" fi - done \ - | process_patch "${s}.diff" + } | + process_patch "${s}.diff" done { diff --git a/scripts/rebuild-rhel-kernel-rpm b/scripts/rebuild-rhel-kernel-rpm index 88c93d16d..e4a96c1d7 100755 --- a/scripts/rebuild-rhel-kernel-rpm +++ b/scripts/rebuild-rhel-kernel-rpm @@ -36,63 +36,51 @@ # ############################################################################ -scst_dir="$(dirname "$(dirname "$0")")" -if [ ${scst_dir:0:1} != "/" ]; then - scst_dir="$PWD/${scst_dir}" +scriptdir="$(dirname "$0")" +if [ "${scriptdir:0:1}" != "/" ]; then + scriptdir="$PWD/${scriptdir}" fi +scriptdir="${scriptdir%/.}" +source "${scriptdir}/rhel-rpm-functions" +scst_dir="$(dirname "$scriptdir")" downloaddir=$HOME/software/downloads rpmbuild_dir=$HOME/rpmbuild -if [ "$1" = "" ]; then - if echo "$(uname -r)" | grep -q uek; then + +if echo "$(uname -r)" | grep -q uek; then kernel="kernel-uek-$(uname -r)" - else - kernel="kernel-$(uname -r)" - fi else - kernel="$1" + kernel="kernel-$(uname -r)" fi + +releasever="$(sed -n -e 's/^.* release \([0-9.]*\).*$/\1/p' /etc/redhat-release)" +distro="$(sed -n -e 's/^\(.*\) release .*$/\1/p' /etc/redhat-release)" + +install_prerequisites=true + +usage() { + echo "$(basename "$0") [-d ] [-h] [-i] [-k ] [-r ]" +} + +type /usr/bin/getopt >/dev/null || exit 1 +options="$(/usr/bin/getopt d:hik:r: "$@")" || { usage; exit 1; } +set -- $options +while [ "$1" != "${1#-}" ]; do + case "$1" in + '-d') distro="$2"; shift; shift;; + '-i') install_prerequisites="false"; shift;; + '-k') kernel="$2"; shift; shift;; + '-r') releasever="$2"; shift; shift;; + '--') shift; break;; + *) usage; exit 1;; + esac +done + arch="$(uname -m)" kernel="${kernel%.${arch}}" kernel_src_rpm="${kernel}.src.rpm" kver="${kernel#kernel-}" -distro="$(sed -n -e 's/^\(.*\) release .*$/\1/p' /etc/issue)" -if [ -n "$2" ]; then - releasever="$2" -else - releasever="$(sed -n -e 's/^.* release \([0-9.]*\).*$/\1/p' /etc/issue)" -fi -releasevermajor="$(echo $releasever | cut -f1 -d.)" -releaseverminor="$(echo $releasever | cut -f2 -d.)" -case "$distro" in - "CentOS"*) - case $releasever in - 5.*|6.[01]) - srpm_url=("http://vault.centos.org/${releasever}/os/SRPMS" "http://vault.centos.org/${releasever}/updates/SRPMS");; - *) - srpm_url=("http://vault.centos.org/${releasever}/os/Source/SPackages" "http://vault.centos.org/${releasever}/updates/Source/SPackages");; - esac - ;; - "Red Hat Enterprise Linux"*) - srpm_url=("http://ftp.redhat.com/pub/redhat/linux/enterprise/${releasevermajor}Server/en/os/SRPMS") - ;; - "Oracle Linux Server") - srpm_url=("http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/${releaseverminor}/base/x86_64/getPackageSource" "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/latest/x86_64/getPackageSource" "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/UEK/latest/x86_64/getPackageSource") - ;; - "Scientific Linux") - if [ "$releasevermajor" = 6 ]; then - srpm_url=("http://ftp.scientificlinux.org/linux/scientific/$releasever/SRPMS/vendor") - else - srpm_url=("http://ftp.scientificlinux.org/linux/scientific/$releasevermajor$releaseverminor/SRPMS/vendor") - fi - ;; - "Fedora") - srpm_url="http://ftp.redhat.com/redhat/rhel/rc/7/Server/source/tree/Packages" - ;; - *) - echo "Unknown type of distribution: $distro" - exit 1 - ;; -esac + +srpm_urls="$(get_srpm_urls "$distro" "$releasever" "$arch")" || exit $? function log { echo @@ -100,6 +88,25 @@ function log { echo } +copy_best_matching_patch() { + local f v + + v="${kver}" + while [ "${v%[0-9a-z]}" != "$v" ]; do + f="${1}-${v}.patch" + if [ -e "$f" ]; then + copy_patch "$f" "$2" + return 0 + fi + while [ "${v%[0-9a-z]}" != "$v" ]; do + v="${v%[0-9a-z]}" + done + v="${v%.}" + v="${v%-}" + done + return 1 +} + function copy_patch { local p="$1" while [ ! -e "$p" ] @@ -137,7 +144,33 @@ fi log "Installing prerequisites" -sudo yum install -y -q asciidoc binutils-devel elfutils-libelf-devel hmaccalc ncurses-devel newt-devel patchutils 'perl(ExtUtils::Embed)' python-devel redhat-rpm-config rpmdevtools rng-tools rpm-build unifdef xmlto yum-utils zlib-devel +if $install_prerequisites; then + for p in \ +asciidoc \ +audit-libs-devel \ +binutils-devel \ +elfutils-devel \ +elfutils-libelf-devel \ +hmaccalc \ +ncurses-devel \ +newt-devel \ +patchutils \ +numactl-devel \ +pciutils-devel \ +'perl(ExtUtils::Embed)' \ +pesign \ +python-devel \ +redhat-rpm-config \ +rng-tools \ +rpm-build \ +rpmdevtools \ +unifdef \ +wget \ +xmlto \ +yum-utils \ +zlib-devel \ +; do sudo yum install -y -q "$p"; done +fi rc=$?; if [ $rc != 0 ]; then exit $rc; fi @@ -150,7 +183,7 @@ log "Installing, unpacking and preparing kernel source files" mkdir -p ${downloaddir} if [ ! -e ${downloaddir}/${kernel_src_rpm} ]; then cd ${downloaddir} - for dir in ${srpm_url[@]} + for dir in ${srpm_urls} do url="$dir/${kernel_src_rpm}" echo "Trying $url ..." @@ -166,7 +199,9 @@ fi log "Installing kernel build prerequisites" -sudo yum-builddep -q -y ${downloaddir}/${kernel_src_rpm} +if $install_prerequisites; then + sudo yum-builddep -q -y ${downloaddir}/${kernel_src_rpm} +fi log "Installing kernel sources in ${rpmbuild_dir}" @@ -185,11 +220,16 @@ cd SPECS log "Copying SCST patches to the SOURCES directory" cd ${rpmbuild_dir}/SOURCES -copy_patch $scst_dir/scst/kernel/rhel/scst_exec_req_fifo-${kver}.patch scst_exec_req_fifo.patch -f="$scst_dir/iscsi-scst/kernel/patches/rhel/put_page_callback-${kver}.patch" -if [ -e "$f" ]; then - copy_patch "$f" put_page_callback.patch -fi +copy_best_matching_patch $scst_dir/scst/kernel/rhel/scst_exec_req_fifo scst_exec_req_fifo.patch || +{ + echo "No matching scst_exec_req_fifo patch found for kernel version $kver"; + exit 1; +} +copy_best_matching_patch $scst_dir/iscsi-scst/kernel/patches/rhel/put_page_callback put_page_callback.patch || +{ + echo "No matching scst_exec_req_fifo patch found for kernel version $kver"; + exit 1; +} log "Adding SCST patches in kernel.spec" @@ -325,7 +365,7 @@ diff -u SPECS/kernel.spec{.orig,} make ARCH=$Arch %{oldconfig_target} > /dev/null echo "# $Arch" > configs/$i EOF -elif [ ${kver#3.10.0-121} != $kver ]; then +elif [ ${kver#3.10.0-12[13]} != $kver ]; then # RHEL/CentOS/SL 7.0 patch -p1 ${rpmbuild_dir}/SPECS/kernel.spec <<'EOF' || exit $? --- kernel.spec.orig 2014-05-23 10:09:17.707202148 +0200 @@ -343,7 +383,7 @@ patch -p1 ${rpmbuild_dir}/SPECS/kernel.spec <<'EOF' || exit $? Source2001: cpupower.config +Patch200: scst_exec_req_fifo.patch -+#Patch201: put_page_callback.patch ++Patch201: put_page_callback.patch + # empty final patch to facilitate testing of kernel patches Patch999999: linux-kernel-test.patch @@ -353,7 +393,7 @@ patch -p1 ${rpmbuild_dir}/SPECS/kernel.spec <<'EOF' || exit $? cp $RPM_SOURCE_DIR/kernel-%{version}-*.config . +ApplyPatch scst_exec_req_fifo.patch -+#ApplyPatch put_page_callback.patch ++ApplyPatch put_page_callback.patch + ApplyOptionalPatch linux-kernel-test.patch diff --git a/scripts/rhel-rpm-functions b/scripts/rhel-rpm-functions new file mode 100644 index 000000000..a6765ae3f --- /dev/null +++ b/scripts/rhel-rpm-functions @@ -0,0 +1,98 @@ +# -*- mode: shell-script -*- +# Shell functions for downloading and extracting a RHEL or RHEL clone RPM + +# Arguments: +# $1: Linux distribution name +# $2: Linux distribution version (major.minor) +# $3: architecture +function get_srpm_urls() { + local arch distro releasever releasevermajor releaseverminor + + distro="$1" + releasever="$2" + arch="$3" + IFS=. + set -- "$2" + unset IFS + releasevermajor="$1" + releaseverminor="$2" + + case "$distro" in + "CentOS"*) + case $releasever in + 5.*|6.[01]) + echo "http://vault.centos.org/${releasever}/os/SRPMS http://vault.centos.org/${releasever}/updates/SRPMS";; + [67].*) + echo "http://vault.centos.org/${releasever}/os/Source/SPackages http://vault.centos.org/${releasever}/updates/Source/SPackages";; + esac + ;; + "Red Hat Enterprise Linux"*) + case $releasever in + [56].*) + echo "http://ftp.redhat.com/pub/redhat/linux/enterprise/${releasevermajor}Server/en/os/SRPMS http://ftp.redhat.com/redhat/rhel/rc/7/Server/source/tree/Packages";; + esac + ;; + "Oracle Linux Server") + echo "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/${releaseverminor}/base/${arch}/getPackageSource http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/latest/${arch}/getPackageSource http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/UEK/latest/${arch}/getPackageSource" + ;; + "Scientific Linux") + case $releasever in + 5.*) + echo "http://ftp.scientificlinux.org/linux/scientific/$releasevermajor$releaseverminor/SRPMS/vendor";; + 6.*) + echo "http://ftp.scientificlinux.org/linux/scientific/$releasever/SRPMS/vendor";; + esac + ;; + *) + echo "Unknown type of distribution: $distro" >&2 + return 1 + ;; + esac +} + +# Arguments: +# $1: Linux distribution name +# $2: Linux distribution version (major.minor) +# $3: architecture +function get_rpm_urls() { + local arch distro releasever releasevermajor releaseverminor + + distro="$1" + releasever="$2" + arch="$3" + IFS=. + set -- "$2" + unset IFS + releasevermajor="$1" + releaseverminor="$2" + + case "$distro" in + "CentOS"*) + case $releasever in + 5.*) + echo "http://vault.centos.org/${releasever}/os/${arch}/CentOS http://vault.centos.org/${releasever}/updates/${arch}/RPMS";; + 6.[01]) + echo "http://vault.centos.org/${releasever}/os/${arch}/Packages http://vault.centos.org/${releasever}/updates/${arch}/Packages";; + [67].*) + echo "http://vault.centos.org/${releasever}/os/${arch}/Packages http://vault.centos.org/${releasever}/updates/${arch}/Packages";; + esac + ;; + "Red Hat Enterprise Linux"*) + echo "";; + "Oracle Linux Server") + echo "http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/${releaseverminor}/base/${arch}/getPackageSource http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/latest/${arch}/getPackageSource http://public-yum.oracle.com/repo/OracleLinux/OL${releasevermajor}/UEK/latest/${arch}/getPackageSource" + ;; + "Scientific Linux") + case $releasever in + 5.*) + echo "http://ftp.scientificlinux.org/linux/scientific/$releasevermajor$releaseverminor/SRPMS/vendor";; + 6.*) + echo "http://ftp.scientificlinux.org/linux/scientific/$releasever/SRPMS/vendor";; + esac + ;; + *) + echo "Unknown distribution type: $distro" >&2 + return 1 + ;; + esac +} diff --git a/scripts/run-regression-tests b/scripts/run-regression-tests index 65105cf9d..f792254c4 100755 --- a/scripts/run-regression-tests +++ b/scripts/run-regression-tests @@ -263,30 +263,32 @@ CONFIG_TRACING CONFIG_X86_32 \ " echo "Patching and configuring kernel ..." + if [ "$ipv6" = "false" ]; then + disable="$disable CONFIG_IPV6" + fi ( local srcdir="$PWD" - cd "${outputdir}/linux-$1" \ - && if [ "${multiple_patches}" = "false" ]; then - patch -p1 -f -s <"${patchfile}" >"${patchoutput}" - else - rm -f "${patchoutput}" - for p in "${outputdir}/${patchdir}"/* - do - echo "==== $p" >>"${patchoutput}" - patch -p1 -f -s <"${p}" >>"${patchoutput}" 2>&1 - done - fi \ - && if [ -e $srcdir/srpt/patches/kernel-${kver}-pre-cflags.patch ]; then - echo "$srcdir/srpt/patches/kernel-${kver}-pre-cflags.patch ..." \ + cd "${outputdir}/linux-$1" && + if [ "${multiple_patches}" = "false" ]; then + patch -p1 -f -s <"${patchfile}" >"${patchoutput}" + else + rm -f "${patchoutput}" + for p in "${outputdir}/${patchdir}"/*; do + echo "==== $p" >>"${patchoutput}" + patch -p1 -f -s <"${p}" >>"${patchoutput}" 2>&1 + done + fi && + if [ -e $srcdir/srpt/patches/kernel-${kver}-pre-cflags.patch ]; then + echo "$srcdir/srpt/patches/kernel-${kver}-pre-cflags.patch ..." \ >>"${patchoutput}" - patch -p1 -f -s <$srcdir/srpt/patches/kernel-${kver}-pre-cflags.patch \ - >>"${patchoutput}"; - else - echo "srpt/patches/kernel-${kver}-pre-cflags.patch not found."; \ - fi \ - && make -s allmodconfig &>"${outputdir}/make-config-output.txt" \ - && for c in $disable; do sed -i.tmp "s/^$c=y\$/$c=n/" .config; done \ - && make -s oldconfig &>/dev/null + patch -p1 -f -s <$srcdir/srpt/patches/kernel-${kver}-pre-cflags.patch \ + >>"${patchoutput}" + else + echo "srpt/patches/kernel-${kver}-pre-cflags.patch not found." + fi && + make -s allmodconfig &>"${outputdir}/make-config-output.txt" && + for c in $disable; do sed -i.tmp "s/^$c=[ym]\$/$c=n/" .config; done && + make -s oldconfig &>/dev/null ) } @@ -585,6 +587,7 @@ do run_checkpatch="true" run_sparse="true" run_smatch="true" + ipv6="true" global_multiple_patches="${multiple_patches}" while [ "${kv%-?}" != "${kv}" -o "${kv%-??}" != "${kv}" ]; do kv_without_opt="${kv%-?}" @@ -593,6 +596,7 @@ do fi kopt="${kv#${kv_without_opt}}" case "${kopt}" in + '-4') ipv6="false";; '-f') full_check="true";; '-i') ibmvio="true";; '-nc') run_checkpatch="false";; diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index ea099a727..7bc6b4418 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -1021,7 +1021,13 @@ struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size, goto out_fail_free; } - TRACE_MEM("Brand new obj %p", obj); + if (likely(!obj->recycling_list_entry.next)) { + TRACE_MEM("Brand new obj %p", obj); + } else if (unlikely(obj->sg_entries != obj->sg_entries_data)) { + TRACE_MEM("Cached obj %p with sg_count == 0", obj); + kfree(obj->sg_entries); + obj->sg_entries = NULL; + } if (pages_to_alloc <= sgv_max_local_pages) { obj->sg_entries = obj->sg_entries_data;