diff --git a/fcst/Makefile b/fcst/Makefile index 5939c958a..1200bcb77 100644 --- a/fcst/Makefile +++ b/fcst/Makefile @@ -86,6 +86,7 @@ tgt: Modules.symvers Module.symvers install: all $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ SCST_INC_DIR=$(SCST_INC_DIR) modules_install ins: diff --git a/ibmvstgt/Makefile b/ibmvstgt/Makefile index daaf57f4e..2bc8ce127 100644 --- a/ibmvstgt/Makefile +++ b/ibmvstgt/Makefile @@ -38,7 +38,9 @@ all: src/$(MODULE_SYMVERS) $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src modules install: all src/ibmvstgt.ko - $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src modules_install + $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ + modules_install uninstall: rm -f $(INSTALL_DIR)/libsrp.ko $(INSTALL_DIR)/ibmvstgt.ko diff --git a/iscsi-scst/Makefile b/iscsi-scst/Makefile index cb4f0a4f9..50c10a0a4 100644 --- a/iscsi-scst/Makefile +++ b/iscsi-scst/Makefile @@ -120,8 +120,10 @@ install: all @install -vD -m 755 usr/iscsi-scst-adm $(DESTDIR)$(SBINDIR)/iscsi-scst-adm @install -vD -m 644 doc/manpages/iscsi-scst-adm.8 $(DESTDIR)$(MANDIR)/man8/iscsi-scst-adm.8 $(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 uninstall: diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index cceb7b698..463ce522a 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -453,7 +453,11 @@ static void iscsi_state_change(struct sock *sk) return; } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) +static void iscsi_data_ready(struct sock *sk) +#else static void iscsi_data_ready(struct sock *sk, int len) +#endif { struct iscsi_conn *conn = sk->sk_user_data; @@ -461,7 +465,11 @@ static void iscsi_data_ready(struct sock *sk, int len) iscsi_make_conn_rd_active(conn); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) + conn->old_data_ready(sk); +#else conn->old_data_ready(sk, len); +#endif TRACE_EXIT(); return; diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index fc72e23dd..459668831 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -3271,7 +3271,8 @@ static ssize_t iscsi_tcp_get_initiator_ip(struct iscsi_conn *conn, "[%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]", NIP6(inet6_sk(sk)->daddr)); #else -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0) && \ + (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 7) pos = scnprintf(buf, size, "[%p6]", &inet6_sk(sk)->daddr); #else pos = scnprintf(buf, size, "[%p6]", &sk->sk_v6_daddr); @@ -4149,8 +4150,7 @@ int iscsi_threads_pool_get(const cpumask_t *cpu_mask, list_for_each_entry(p, &iscsi_thread_pools_list, thread_pools_list_entry) { - if ((cpu_mask == NULL) || - __cpus_equal(cpu_mask, &p->cpu_mask, nr_cpumask_bits)) { + if (!cpu_mask || cpumask_equal(cpu_mask, &p->cpu_mask)) { p->thread_pool_ref++; TRACE_DBG("iSCSI thread pool %p found (new ref %d)", p, p->thread_pool_ref); @@ -4184,12 +4184,9 @@ int iscsi_threads_pool_get(const cpumask_t *cpu_mask, INIT_LIST_HEAD(&p->wr_list); init_waitqueue_head(&p->wr_waitQ); if (cpu_mask == NULL) - cpus_setall(p->cpu_mask); - else { - cpus_clear(p->cpu_mask); - for_each_cpu(i, cpu_mask) - cpu_set(i, p->cpu_mask); - } + cpumask_setall(&p->cpu_mask); + else + cpumask_copy(&p->cpu_mask, cpu_mask); p->thread_pool_ref = 1; INIT_LIST_HEAD(&p->threads_list); diff --git a/iscsi-scst/kernel/iscsi.h b/iscsi-scst/kernel/iscsi.h index d93c78d4f..6410a9cd0 100644 --- a/iscsi-scst/kernel/iscsi.h +++ b/iscsi-scst/kernel/iscsi.h @@ -253,7 +253,11 @@ struct iscsi_conn { struct socket *sock; void (*old_state_change)(struct sock *); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) + void (*old_data_ready)(struct sock *); +#else void (*old_data_ready)(struct sock *, int); +#endif void (*old_write_space)(struct sock *); /* Both read only. Stay here for better CPU cache locality. */ diff --git a/iscsi-scst/kernel/patches/put_page_callback-3.15.patch b/iscsi-scst/kernel/patches/put_page_callback-3.15.patch new file mode 100644 index 000000000..0bf0ce5e4 --- /dev/null +++ b/iscsi-scst/kernel/patches/put_page_callback-3.15.patch @@ -0,0 +1,364 @@ +=== modified file 'drivers/block/drbd/drbd_receiver.c' +--- old/drivers/block/drbd/drbd_receiver.c 2014-06-18 01:32:48 +0000 ++++ new/drivers/block/drbd/drbd_receiver.c 2014-06-18 01:44:08 +0000 +@@ -131,7 +131,7 @@ static int page_chain_free(struct page * + struct page *tmp; + int i = 0; + page_chain_for_each_safe(page, tmp) { +- put_page(page); ++ net_put_page(page); + ++i; + } + return i; + +=== modified file 'include/linux/mm_types.h' +--- old/include/linux/mm_types.h 2014-06-18 01:32:48 +0000 ++++ new/include/linux/mm_types.h 2014-06-18 01:44:08 +0000 +@@ -196,6 +196,17 @@ struct page { + #ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS + int _last_cpupid; + #endif ++ ++#if defined(CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION) ++ /* ++ * Used to implement support for notification on zero-copy TCP transfer ++ * completion. It might look as not good to have this field here and ++ * it's better to have it in struct sk_buff, but it would make the code ++ * much more complicated and fragile, since all skb then would have to ++ * contain only pages with the same value in this field. ++ */ ++ void *net_priv; ++#endif + } + /* + * The struct page can be forced to be double word aligned so that atomic ops + +=== modified file 'include/linux/net.h' +--- old/include/linux/net.h 2014-06-18 01:32:48 +0000 ++++ new/include/linux/net.h 2014-06-18 01:44:08 +0000 +@@ -19,6 +19,7 @@ + #define _LINUX_NET_H + + #include ++#include + #include + #include + #include /* For O_CLOEXEC and O_NONBLOCK */ +@@ -285,6 +286,45 @@ int kernel_sendpage(struct socket *sock, + int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg); + int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how); + ++#if defined(CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION) ++/* Support for notification on zero-copy TCP transfer completion */ ++typedef void (*net_get_page_callback_t)(struct page *page); ++typedef void (*net_put_page_callback_t)(struct page *page); ++ ++extern net_get_page_callback_t net_get_page_callback; ++extern net_put_page_callback_t net_put_page_callback; ++ ++extern int net_set_get_put_page_callbacks( ++ net_get_page_callback_t get_callback, ++ net_put_page_callback_t put_callback); ++ ++/* ++ * See comment for net_set_get_put_page_callbacks() why those functions ++ * don't need any protection. ++ */ ++static inline void net_get_page(struct page *page) ++{ ++ if (page->net_priv != 0) ++ net_get_page_callback(page); ++ get_page(page); ++} ++static inline void net_put_page(struct page *page) ++{ ++ if (page->net_priv != 0) ++ net_put_page_callback(page); ++ put_page(page); ++} ++#else ++static inline void net_get_page(struct page *page) ++{ ++ get_page(page); ++} ++static inline void net_put_page(struct page *page) ++{ ++ put_page(page); ++} ++#endif /* CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION */ ++ + #define MODULE_ALIAS_NETPROTO(proto) \ + MODULE_ALIAS("net-pf-" __stringify(proto)) + + +=== modified file 'include/linux/skbuff.h' +--- old/include/linux/skbuff.h 2014-06-18 01:32:48 +0000 ++++ new/include/linux/skbuff.h 2014-06-18 01:44:08 +0000 +@@ -2113,7 +2113,7 @@ static inline struct page *skb_frag_page + */ + static inline void __skb_frag_ref(skb_frag_t *frag) + { +- get_page(skb_frag_page(frag)); ++ net_get_page(skb_frag_page(frag)); + } + + /** +@@ -2136,7 +2136,7 @@ static inline void skb_frag_ref(struct s + */ + static inline void __skb_frag_unref(skb_frag_t *frag) + { +- put_page(skb_frag_page(frag)); ++ net_put_page(skb_frag_page(frag)); + } + + /** + +=== modified file 'net/Kconfig' +--- old/net/Kconfig 2014-06-18 01:32:48 +0000 ++++ new/net/Kconfig 2014-06-18 01:44:08 +0000 +@@ -75,6 +75,18 @@ config INET + + Short answer: say Y. + ++config TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION ++ bool "TCP/IP zero-copy transfer completion notification" ++ depends on INET ++ default SCST_ISCSI ++ ---help--- ++ Adds support for sending a notification upon completion of a ++ zero-copy TCP/IP transfer. This can speed up certain TCP/IP ++ software. Currently this is only used by the iSCSI target driver ++ iSCSI-SCST. ++ ++ If unsure, say N. ++ + if INET + source "net/ipv4/Kconfig" + source "net/ipv6/Kconfig" + +=== modified file 'net/ceph/pagevec.c' +--- old/net/ceph/pagevec.c 2014-06-18 01:32:48 +0000 ++++ new/net/ceph/pagevec.c 2014-06-18 01:44:08 +0000 +@@ -51,7 +51,7 @@ void ceph_put_page_vector(struct page ** + for (i = 0; i < num_pages; i++) { + if (dirty) + set_page_dirty_lock(pages[i]); +- put_page(pages[i]); ++ net_put_page(pages[i]); + } + kfree(pages); + } + +=== modified file 'net/core/skbuff.c' +--- old/net/core/skbuff.c 2014-06-18 01:32:48 +0000 ++++ new/net/core/skbuff.c 2014-06-18 01:44:08 +0000 +@@ -425,7 +425,7 @@ struct sk_buff *__netdev_alloc_skb(struc + if (likely(data)) { + skb = build_skb(data, fragsz); + if (unlikely(!skb)) +- put_page(virt_to_head_page(data)); ++ net_put_page(virt_to_head_page(data)); + } + } else { + skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, +@@ -483,7 +483,7 @@ static void skb_clone_fraglist(struct sk + static void skb_free_head(struct sk_buff *skb) + { + if (skb->head_frag) +- put_page(virt_to_head_page(skb->head)); ++ net_put_page(virt_to_head_page(skb->head)); + else + kfree(skb->head); + } +@@ -804,7 +804,7 @@ int skb_copy_ubufs(struct sk_buff *skb, + if (!page) { + while (head) { + struct page *next = (struct page *)page_private(head); +- put_page(head); ++ net_put_page(head); + head = next; + } + return -ENOMEM; +@@ -1647,7 +1647,7 @@ EXPORT_SYMBOL(skb_copy_bits); + */ + static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i) + { +- put_page(spd->pages[i]); ++ net_put_page(spd->pages[i]); + } + + static struct page *linear_to_page(struct page *page, unsigned int *len, +@@ -1700,7 +1700,7 @@ static bool spd_fill_page(struct splice_ + spd->partial[spd->nr_pages - 1].len += *len; + return false; + } +- get_page(page); ++ net_get_page(page); + spd->pages[spd->nr_pages] = page; + spd->partial[spd->nr_pages].len = *len; + spd->partial[spd->nr_pages].offset = offset; +@@ -2159,7 +2159,7 @@ skb_zerocopy(struct sk_buff *to, struct + page = virt_to_head_page(from->head); + offset = from->data - (unsigned char *)page_address(page); + __skb_fill_page_desc(to, 0, page, offset, plen); +- get_page(page); ++ net_get_page(page); + j = 1; + len -= plen; + } +@@ -2813,7 +2813,7 @@ int skb_append_datato_frags(struct sock + copy); + frg_cnt++; + pfrag->offset += copy; +- get_page(pfrag->page); ++ net_get_page(pfrag->page); + + skb->truesize += copy; + atomic_add(copy, &sk->sk_wmem_alloc); + +=== modified file 'net/core/sock.c' +--- old/net/core/sock.c 2014-06-18 01:32:48 +0000 ++++ new/net/core/sock.c 2014-06-18 01:44:08 +0000 +@@ -1888,7 +1888,7 @@ bool skb_page_frag_refill(unsigned int s + } + if (pfrag->offset + sz <= pfrag->size) + return true; +- put_page(pfrag->page); ++ net_put_page(pfrag->page); + } + + order = SKB_FRAG_PAGE_ORDER; +@@ -2651,7 +2651,7 @@ void sk_common_release(struct sock *sk) + sk_refcnt_debug_release(sk); + + if (sk->sk_frag.page) { +- put_page(sk->sk_frag.page); ++ net_put_page(sk->sk_frag.page); + sk->sk_frag.page = NULL; + } + + +=== modified file 'net/ipv4/Makefile' +--- old/net/ipv4/Makefile 2014-06-18 01:32:48 +0000 ++++ new/net/ipv4/Makefile 2014-06-18 01:44:08 +0000 +@@ -53,6 +53,7 @@ obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah. + obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o + obj-$(CONFIG_MEMCG_KMEM) += tcp_memcontrol.o + obj-$(CONFIG_NETLABEL) += cipso_ipv4.o ++obj-$(CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION) += tcp_zero_copy.o + + obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ + xfrm4_output.o xfrm4_protocol.o + +=== modified file 'net/ipv4/ip_output.c' +--- old/net/ipv4/ip_output.c 2014-06-18 01:32:48 +0000 ++++ new/net/ipv4/ip_output.c 2014-06-18 01:44:08 +0000 +@@ -1047,7 +1047,7 @@ alloc_new_skb: + __skb_fill_page_desc(skb, i, pfrag->page, + pfrag->offset, 0); + skb_shinfo(skb)->nr_frags = ++i; +- get_page(pfrag->page); ++ net_get_page(pfrag->page); + } + copy = min_t(int, copy, pfrag->size - pfrag->offset); + if (getfrag(from, +@@ -1272,7 +1272,7 @@ ssize_t ip_append_page(struct sock *sk, + if (skb_can_coalesce(skb, i, page, offset)) { + skb_frag_size_add(&skb_shinfo(skb)->frags[i-1], len); + } else if (i < MAX_SKB_FRAGS) { +- get_page(page); ++ net_get_page(page); + skb_fill_page_desc(skb, i, page, offset, len); + } else { + err = -EMSGSIZE; + +=== modified file 'net/ipv4/tcp.c' +--- old/net/ipv4/tcp.c 2014-06-18 01:32:48 +0000 ++++ new/net/ipv4/tcp.c 2014-06-18 01:44:08 +0000 +@@ -939,7 +939,7 @@ new_segment: + if (can_coalesce) { + skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); + } else { +- get_page(page); ++ net_get_page(page); + skb_fill_page_desc(skb, i, page, offset, copy); + } + skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; +@@ -1238,7 +1238,7 @@ new_segment: + } else { + skb_fill_page_desc(skb, i, pfrag->page, + pfrag->offset, copy); +- get_page(pfrag->page); ++ net_get_page(pfrag->page); + } + pfrag->offset += copy; + } + +=== added file 'net/ipv4/tcp_zero_copy.c' +--- old/net/ipv4/tcp_zero_copy.c 1970-01-01 00:00:00 +0000 ++++ new/net/ipv4/tcp_zero_copy.c 2014-06-18 01:44:08 +0000 +@@ -0,0 +1,50 @@ ++/* ++ * Support routines for TCP zero copy transmit ++ * ++ * Created by Vladislav Bolkhovitin ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * version 2 as published by the Free Software Foundation. ++ */ ++ ++#include ++#include ++ ++net_get_page_callback_t net_get_page_callback __read_mostly; ++EXPORT_SYMBOL_GPL(net_get_page_callback); ++ ++net_put_page_callback_t net_put_page_callback __read_mostly; ++EXPORT_SYMBOL_GPL(net_put_page_callback); ++ ++/* ++ * Caller of this function must ensure that at the moment when it's called ++ * there are no pages in the system with net_priv field set to non-zero ++ * value. Hence, this function, as well as net_get_page() and net_put_page(), ++ * don't need any protection. ++ */ ++int net_set_get_put_page_callbacks( ++ net_get_page_callback_t get_callback, ++ net_put_page_callback_t put_callback) ++{ ++ int res = 0; ++ ++ if ((net_get_page_callback != NULL) && (get_callback != NULL) && ++ (net_get_page_callback != get_callback)) { ++ res = -EBUSY; ++ goto out; ++ } ++ ++ if ((net_put_page_callback != NULL) && (put_callback != NULL) && ++ (net_put_page_callback != put_callback)) { ++ res = -EBUSY; ++ goto out; ++ } ++ ++ net_get_page_callback = get_callback; ++ net_put_page_callback = put_callback; ++ ++out: ++ return res; ++} ++EXPORT_SYMBOL_GPL(net_set_get_put_page_callbacks); + +=== modified file 'net/ipv6/ip6_output.c' +--- old/net/ipv6/ip6_output.c 2014-06-18 01:32:48 +0000 ++++ new/net/ipv6/ip6_output.c 2014-06-18 01:44:08 +0000 +@@ -1461,7 +1461,7 @@ alloc_new_skb: + __skb_fill_page_desc(skb, i, pfrag->page, + pfrag->offset, 0); + skb_shinfo(skb)->nr_frags = ++i; +- get_page(pfrag->page); ++ net_get_page(pfrag->page); + } + copy = min_t(int, copy, pfrag->size - pfrag->offset); + if (getfrag(from, + diff --git a/mpt/Makefile b/mpt/Makefile index 957c39a1e..f75c73761 100644 --- a/mpt/Makefile +++ b/mpt/Makefile @@ -74,6 +74,7 @@ tgt: Modules.symvers Module.symvers install: all $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ modules_install SCST_MOD_VERS := $(shell ls $(SCST_DIR)/Modules.symvers 2>/dev/null) diff --git a/mvsas_tgt/Makefile b/mvsas_tgt/Makefile index 5b4db8d9c..30af54767 100644 --- a/mvsas_tgt/Makefile +++ b/mvsas_tgt/Makefile @@ -89,6 +89,7 @@ tgt: Modules.symvers Module.symvers install: all $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ modules_install ins: diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index 268ce0bb2..5565c0da6 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -3,17 +3,18 @@ ABT_DETAILS="x86_64" ABT_JOBS=5 ABT_KERNELS=" \ -3.14.4 \ -3.13.11 \ -3.12.20-nc \ +3.15.2 \ +3.14.9-nc \ +3.13.11-nc \ +3.12.21-nc \ 3.11.10-nc \ -3.10.40-nc \ +3.10.45-nc \ 3.9.11-nc \ -3.8.13.14-nc \ +3.8.13-nc \ 3.7.10-nc \ -3.6.11.9-nc \ +3.6.11-nc \ 3.5.7-nc \ -3.4.91-nc \ +3.4.95-nc \ 3.3.8-nc \ 3.2.59-nc \ 3.1.10-nc \ @@ -26,7 +27,7 @@ ABT_KERNELS=" \ 2.6.35.14-u-nc \ 2.6.34.14-nc \ 2.6.33.20-nc \ -2.6.32.61-nc \ +2.6.32.62-nc \ 2.6.31.14-nc \ 2.6.30.10-nc \ 2.6.29.6-nc \ diff --git a/qla2x00t/Makefile b/qla2x00t/Makefile index ac628ce9b..b1651b067 100644 --- a/qla2x00t/Makefile +++ b/qla2x00t/Makefile @@ -61,6 +61,7 @@ all: install: all $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ modules_install uninstall: diff --git a/qla2x00t/qla2x00-target/Makefile b/qla2x00t/qla2x00-target/Makefile index 7dbbf0117..67aacf8a1 100644 --- a/qla2x00t/qla2x00-target/Makefile +++ b/qla2x00t/qla2x00-target/Makefile @@ -105,6 +105,7 @@ ifneq ($(BUILD_2X_MODULE),) SCST_INC_DIR=$(SCST_INC_DIR) endif $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ SCST_INC_DIR=$(SCST_INC_DIR) modules_install uninstall: diff --git a/qla2x00t/qla2x00-target/Makefile_in-tree-3.15 b/qla2x00t/qla2x00-target/Makefile_in-tree-3.15 new file mode 100644 index 000000000..9657aee84 --- /dev/null +++ b/qla2x00t/qla2x00-target/Makefile_in-tree-3.15 @@ -0,0 +1,5 @@ +ccflags-y += -Idrivers/scsi/qla2xxx + +qla2x00tgt-y := qla2x00t.o + +obj-$(CONFIG_SCST_QLA_TGT_ADDON) += qla2x00tgt.o diff --git a/qla_isp/linux-2.6/Makefile b/qla_isp/linux-2.6/Makefile index 5c669c9e1..326fa8d86 100644 --- a/qla_isp/linux-2.6/Makefile +++ b/qla_isp/linux-2.6/Makefile @@ -53,7 +53,9 @@ extraclean: clean rm -f *.orig *.rej install: - @$(MAKE) -C ${LINUX} M=${CURDIR}/build modules_install + @$(MAKE) -C ${LINUX} M=${CURDIR}/build \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ + modules_install install_host_progs: @$(MAKE) -C build $@ diff --git a/scripts/kernel-functions b/scripts/kernel-functions index 58751563f..a72230dc7 100644 --- a/scripts/kernel-functions +++ b/scripts/kernel-functions @@ -2,7 +2,7 @@ # Shell functions for parsing the Linux kernel version and for downloading # from kernel.org. -kernel_mirror="ftp://ftp.kernel.org/pub/linux/kernel" +kernel_mirror="http://ftp.kernel.org/pub/linux/kernel" kernel_longterm="http://www.kernel.org/pub/linux/kernel" kernel_sources="$HOME/software/downloads" diff --git a/scripts/rebuild-rhel-kernel-rpm b/scripts/rebuild-rhel-kernel-rpm index b881fe4db..88c93d16d 100755 --- a/scripts/rebuild-rhel-kernel-rpm +++ b/scripts/rebuild-rhel-kernel-rpm @@ -85,6 +85,9 @@ case "$distro" in 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 @@ -183,7 +186,10 @@ 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 -copy_patch $scst_dir/iscsi-scst/kernel/patches/rhel/put_page_callback-${kver}.patch put_page_callback.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 log "Adding SCST patches in kernel.spec" @@ -319,6 +325,49 @@ 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 +# 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 ++++ kernel.spec 2014-05-23 10:15:50.883937952 +0200 +@@ -4,6 +4,7 @@ + Summary: The Linux kernel + + # % define buildid .local ++%define buildid .scst + + # For a stable, released kernel, released_kernel should be 1. For rawhide + # and/or a kernel built from an rc or git snapshot, released_kernel should +@@ -367,6 +368,9 @@ + Source2000: cpupower.service + Source2001: cpupower.config + ++Patch200: scst_exec_req_fifo.patch ++#Patch201: put_page_callback.patch ++ + # empty final patch to facilitate testing of kernel patches + Patch999999: linux-kernel-test.patch + +@@ -668,6 +672,9 @@ + # Drop some necessary files from the source dir into the buildroot + cp $RPM_SOURCE_DIR/kernel-%{version}-*.config . + ++ApplyPatch scst_exec_req_fifo.patch ++#ApplyPatch put_page_callback.patch ++ + ApplyOptionalPatch linux-kernel-test.patch + + # Any further pre-build tree manipulations happen here. +@@ -700,6 +707,8 @@ + for i in *.config + do + mv $i .config ++ echo "CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION=y" >> .config ++ sed -i.tmp -e 's/^CONFIG_SCSI_QLA_FC=.*/CONFIG_SCSI_QLA_FC=n/' .config + Arch=`head -1 .config | cut -b 3-` + make %{?cross_opts} ARCH=$Arch listnewconfig | grep -E '^CONFIG_' >.newoptions || true + %if %{listnewconfig_fail} +EOF else log "Unrecognized kernel version ${kver}" fi @@ -327,7 +376,7 @@ log "Rebuilding kernel" cd ${rpmbuild_dir}/SPECS { - rpmbuild -bb --target=${arch} --with baseonly --with firmware --without kabichk kernel*.spec + rpmbuild -bb --target=${arch} --nodeps --with baseonly --with firmware --without kabichk kernel*.spec rc=$? if [ $rc != 0 ]; then exit $rc diff --git a/scripts/run-regression-tests b/scripts/run-regression-tests index bae2ad0a5..65105cf9d 100755 --- a/scripts/run-regression-tests +++ b/scripts/run-regression-tests @@ -492,7 +492,7 @@ fi # Where to store persistenly downloaded kernel tarballs and kernel patches. kernel_sources="$HOME/software/downloads" # URL for downloading kernel tarballs and kernel patches. -kernel_mirror="ftp://ftp.kernel.org/pub/linux/kernel" +kernel_mirror="http://ftp.kernel.org/pub/linux/kernel" kernel_longterm="http://www.kernel.org/pub/linux/kernel" kernel_versions="" # Directory in which the regression test output files will be stored. Must be diff --git a/scst.spec.in b/scst.spec.in index 579888487..535875b0d 100644 --- a/scst.spec.in +++ b/scst.spec.in @@ -90,6 +90,8 @@ rm -f /usr/local/man/man8/iscsi-scstd.8 rm -f /usr/local/sbin/iscsi-scst-adm rm -f /usr/local/sbin/iscsi-scstd rm -rf /usr/local/include/scst +# Remove existing ib_srpt.ko kernel modules +find /lib/modules/%{kver} -name ib_srpt.ko -exec rm {} \; %post /sbin/depmod -a %{kver} diff --git a/scst/include/scst.h b/scst/include/scst.h index 66cb6d685..3ee400055 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -79,6 +79,14 @@ typedef _Bool bool; #define __aligned __attribute__((aligned)) #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) +char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap); +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) +#define lockdep_assert_held(l) do { (void)(l); } while (0) +#endif + #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32) #ifndef O_DSYNC #define O_DSYNC O_SYNC @@ -172,6 +180,27 @@ static inline void cpumask_copy(cpumask_t *dstp, { bitmap_copy(cpumask_bits(dstp), cpumask_bits(srcp), nr_cpumask_bits); } + +/** + * cpumask_setall - set all cpus (< nr_cpu_ids) in a cpumask + * @dstp: the cpumask pointer + */ +static inline void cpumask_setall(cpumask_t *dstp) +{ + bitmap_fill(cpumask_bits(dstp), nr_cpumask_bits); +} + +/** + * cpumask_equal - *src1p == *src2p + * @src1p: the first input + * @src2p: the second input + */ +static inline bool cpumask_equal(const cpumask_t *src1p, + const cpumask_t *src2p) +{ + return bitmap_equal(cpumask_bits(src1p), cpumask_bits(src2p), + nr_cpumask_bits); +} #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) && \ @@ -186,6 +215,16 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q) } #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) +/* + * See also patch "kernel.h: add pr_warn for symmetry to dev_warn, + * netdev_warn" (commit fc62f2f19edf46c9bdbd1a54725b56b18c43e94f). + */ +#ifndef pr_warn +#define pr_warn pr_warning +#endif +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) /* * See also patch "sched: Fix softirq time accounting" (commit ID @@ -4277,11 +4316,16 @@ static inline int cancel_delayed_work_sync(struct delayed_work *work) #endif #endif -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) && \ + defined(CONFIG_DEBUG_LOCK_ALLOC) extern struct lockdep_map scst_suspend_dep_map; #define scst_assert_activity_suspended() \ WARN_ON(debug_locks && !lock_is_held(&scst_suspend_dep_map)); #else +/* + * See also patch "lockdep: Introduce lockdep_assert_held()" (commit ID + * f607c6685774811b8112e124f10a053d77015485) + */ #define scst_assert_activity_suspended() do { } while (0) #endif diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index f8a7f28ac..5af2c6f5c 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -53,7 +53,6 @@ printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) #define pr_warning(fmt, ...) \ printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) -#define pr_warn pr_warning #define pr_notice(fmt, ...) \ printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) #endif diff --git a/scst/kernel/in-tree/Kconfig.drivers.Linux-3.15.patch b/scst/kernel/in-tree/Kconfig.drivers.Linux-3.15.patch new file mode 100644 index 000000000..0d5a19f0f --- /dev/null +++ b/scst/kernel/in-tree/Kconfig.drivers.Linux-3.15.patch @@ -0,0 +1,13 @@ +diff --git a/drivers/Kconfig b/drivers/Kconfig +index aa43b91..c96860e 100644 +--- a/drivers/Kconfig ++++ b/drivers/Kconfig +@@ -24,6 +24,8 @@ source "drivers/ide/Kconfig" + + source "drivers/scsi/Kconfig" + ++source "drivers/scst/Kconfig" ++ + source "drivers/ata/Kconfig" + + source "drivers/md/Kconfig" diff --git a/scst/kernel/in-tree/Makefile.dev_handlers-3.15 b/scst/kernel/in-tree/Makefile.dev_handlers-3.15 new file mode 100644 index 000000000..f933b36f7 --- /dev/null +++ b/scst/kernel/in-tree/Makefile.dev_handlers-3.15 @@ -0,0 +1,14 @@ +ccflags-y += -Wno-unused-parameter + +obj-m := scst_cdrom.o scst_changer.o scst_disk.o scst_modisk.o scst_tape.o \ + scst_vdisk.o scst_raid.o scst_processor.o scst_user.o + +obj-$(CONFIG_SCST_DISK) += scst_disk.o +obj-$(CONFIG_SCST_TAPE) += scst_tape.o +obj-$(CONFIG_SCST_CDROM) += scst_cdrom.o +obj-$(CONFIG_SCST_MODISK) += scst_modisk.o +obj-$(CONFIG_SCST_CHANGER) += scst_changer.o +obj-$(CONFIG_SCST_RAID) += scst_raid.o +obj-$(CONFIG_SCST_PROCESSOR) += scst_processor.o +obj-$(CONFIG_SCST_VDISK) += scst_vdisk.o +obj-$(CONFIG_SCST_USER) += scst_user.o diff --git a/scst/kernel/in-tree/Makefile.drivers.Linux-3.15.patch b/scst/kernel/in-tree/Makefile.drivers.Linux-3.15.patch new file mode 100644 index 000000000..f7213ed4c --- /dev/null +++ b/scst/kernel/in-tree/Makefile.drivers.Linux-3.15.patch @@ -0,0 +1,12 @@ +diff --git a/drivers/Makefile b/drivers/Makefile +index ab93de8..45077ec 100644 +--- a/drivers/Makefile ++++ b/drivers/Makefile +@@ -128,6 +128,7 @@ obj-$(CONFIG_SSB) += ssb/ + obj-$(CONFIG_BCMA) += bcma/ + obj-$(CONFIG_VHOST_RING) += vhost/ + obj-$(CONFIG_VLYNQ) += vlynq/ ++obj-$(CONFIG_SCST) += scst/ + obj-$(CONFIG_STAGING) += staging/ + obj-y += platform/ + #common clk code diff --git a/scst/kernel/in-tree/Makefile.scst-3.15 b/scst/kernel/in-tree/Makefile.scst-3.15 new file mode 100644 index 000000000..53af5f388 --- /dev/null +++ b/scst/kernel/in-tree/Makefile.scst-3.15 @@ -0,0 +1,13 @@ +ccflags-y += -Wno-unused-parameter + +scst-y += scst_main.o +scst-y += scst_pres.o +scst-y += scst_targ.o +scst-y += scst_lib.o +scst-y += scst_sysfs.o +scst-y += scst_mem.o +scst-y += scst_tg.o +scst-y += scst_debug.o + +obj-$(CONFIG_SCST) += scst.o dev_handlers/ fcst/ iscsi-scst/ qla2xxx-target/ \ + srpt/ scst_local/ diff --git a/scst/kernel/rhel/scst_exec_req_fifo-3.10.0-121.el7.patch b/scst/kernel/rhel/scst_exec_req_fifo-3.10.0-121.el7.patch new file mode 120000 index 000000000..6a3acd053 --- /dev/null +++ b/scst/kernel/rhel/scst_exec_req_fifo-3.10.0-121.el7.patch @@ -0,0 +1 @@ +../scst_exec_req_fifo-3.10.patch \ No newline at end of file diff --git a/scst/kernel/scst_exec_req_fifo-3.15.patch b/scst/kernel/scst_exec_req_fifo-3.15.patch new file mode 100644 index 000000000..665cc2606 --- /dev/null +++ b/scst/kernel/scst_exec_req_fifo-3.15.patch @@ -0,0 +1,528 @@ +=== modified file 'block/blk-map.c' +--- old/block/blk-map.c 2014-06-18 01:32:48 +0000 ++++ new/block/blk-map.c 2014-06-18 01:40:34 +0000 +@@ -5,6 +5,8 @@ + #include + #include + #include ++#include ++#include + #include /* for struct sg_iovec */ + + #include "blk.h" +@@ -275,6 +277,337 @@ int blk_rq_unmap_user(struct bio *bio) + } + EXPORT_SYMBOL(blk_rq_unmap_user); + ++struct blk_kern_sg_work { ++ atomic_t bios_inflight; ++ struct sg_table sg_table; ++ struct scatterlist *src_sgl; ++}; ++ ++static void blk_free_kern_sg_work(struct blk_kern_sg_work *bw) ++{ ++ struct sg_table *sgt = &bw->sg_table; ++ struct scatterlist *sg; ++ int i; ++ ++ for_each_sg(sgt->sgl, sg, sgt->orig_nents, i) { ++ struct page *pg = sg_page(sg); ++ if (pg == NULL) ++ break; ++ __free_page(pg); ++ } ++ ++ sg_free_table(sgt); ++ kfree(bw); ++ return; ++} ++ ++static void blk_bio_map_kern_endio(struct bio *bio, int err) ++{ ++ struct blk_kern_sg_work *bw = bio->bi_private; ++ ++ if (bw != NULL) { ++ /* Decrement the bios in processing and, if zero, free */ ++ BUG_ON(atomic_read(&bw->bios_inflight) <= 0); ++ if (atomic_dec_and_test(&bw->bios_inflight)) { ++ if ((bio_data_dir(bio) == READ) && (err == 0)) { ++ unsigned long flags; ++ ++ local_irq_save(flags); /* to protect KMs */ ++ sg_copy(bw->src_sgl, bw->sg_table.sgl, 0, 0); ++ local_irq_restore(flags); ++ } ++ blk_free_kern_sg_work(bw); ++ } ++ } ++ ++ bio_put(bio); ++ return; ++} ++ ++static int blk_rq_copy_kern_sg(struct request *rq, struct scatterlist *sgl, ++ int nents, struct blk_kern_sg_work **pbw, ++ gfp_t gfp, gfp_t page_gfp) ++{ ++ int res = 0, i; ++ struct scatterlist *sg; ++ struct scatterlist *new_sgl; ++ int new_sgl_nents; ++ size_t len = 0, to_copy; ++ struct blk_kern_sg_work *bw; ++ ++ bw = kzalloc(sizeof(*bw), gfp); ++ if (bw == NULL) ++ goto out; ++ ++ bw->src_sgl = sgl; ++ ++ for_each_sg(sgl, sg, nents, i) ++ len += sg->length; ++ to_copy = len; ++ ++ new_sgl_nents = PFN_UP(len); ++ ++ res = sg_alloc_table(&bw->sg_table, new_sgl_nents, gfp); ++ if (res != 0) ++ goto err_free; ++ ++ new_sgl = bw->sg_table.sgl; ++ ++ for_each_sg(new_sgl, sg, new_sgl_nents, i) { ++ struct page *pg; ++ ++ pg = alloc_page(page_gfp); ++ if (pg == NULL) ++ goto err_free; ++ ++ sg_assign_page(sg, pg); ++ sg->length = min_t(size_t, PAGE_SIZE, len); ++ ++ len -= PAGE_SIZE; ++ } ++ ++ if (rq_data_dir(rq) == WRITE) { ++ /* ++ * We need to limit amount of copied data to to_copy, because ++ * sgl might have the last element in sgl not marked as last in ++ * SG chaining. ++ */ ++ sg_copy(new_sgl, sgl, 0, to_copy); ++ } ++ ++ *pbw = bw; ++ /* ++ * REQ_COPY_USER name is misleading. It should be something like ++ * REQ_HAS_TAIL_SPACE_FOR_PADDING. ++ */ ++ rq->cmd_flags |= REQ_COPY_USER; ++ ++out: ++ return res; ++ ++err_free: ++ blk_free_kern_sg_work(bw); ++ res = -ENOMEM; ++ goto out; ++} ++ ++static int __blk_rq_map_kern_sg(struct request *rq, struct scatterlist *sgl, ++ int nents, struct blk_kern_sg_work *bw, gfp_t gfp) ++{ ++ int res; ++ struct request_queue *q = rq->q; ++ int rw = rq_data_dir(rq); ++ int max_nr_vecs, i; ++ size_t tot_len; ++ bool need_new_bio; ++ struct scatterlist *sg, *prev_sg = NULL; ++ struct bio *bio = NULL, *hbio = NULL, *tbio = NULL; ++ int bios; ++ ++ if (unlikely((sgl == NULL) || (sgl->length == 0) || (nents <= 0))) { ++ WARN_ON(1); ++ res = -EINVAL; ++ goto out; ++ } ++ ++ /* ++ * Let's keep each bio allocation inside a single page to decrease ++ * probability of failure. ++ */ ++ max_nr_vecs = min_t(size_t, ++ ((PAGE_SIZE - sizeof(struct bio)) / sizeof(struct bio_vec)), ++ BIO_MAX_PAGES); ++ ++ need_new_bio = true; ++ tot_len = 0; ++ bios = 0; ++ for_each_sg(sgl, sg, nents, i) { ++ struct page *page = sg_page(sg); ++ void *page_addr = page_address(page); ++ size_t len = sg->length, l; ++ size_t offset = sg->offset; ++ ++ tot_len += len; ++ prev_sg = sg; ++ ++ /* ++ * Each segment must be aligned on DMA boundary and ++ * not on stack. The last one may have unaligned ++ * length as long as the total length is aligned to ++ * DMA padding alignment. ++ */ ++ if (i == nents - 1) ++ l = 0; ++ else ++ l = len; ++ if (((sg->offset | l) & queue_dma_alignment(q)) || ++ (page_addr && object_is_on_stack(page_addr + sg->offset))) { ++ res = -EINVAL; ++ goto out_free_bios; ++ } ++ ++ while (len > 0) { ++ size_t bytes; ++ int rc; ++ ++ if (need_new_bio) { ++ bio = bio_kmalloc(gfp, max_nr_vecs); ++ if (bio == NULL) { ++ res = -ENOMEM; ++ goto out_free_bios; ++ } ++ ++ if (rw == WRITE) ++ bio->bi_rw |= REQ_WRITE; ++ ++ bios++; ++ bio->bi_private = bw; ++ bio->bi_end_io = blk_bio_map_kern_endio; ++ ++ if (hbio == NULL) ++ hbio = tbio = bio; ++ else ++ tbio = tbio->bi_next = bio; ++ } ++ ++ bytes = min_t(size_t, len, PAGE_SIZE - offset); ++ ++ rc = bio_add_pc_page(q, bio, page, bytes, offset); ++ if (rc < bytes) { ++ if (unlikely(need_new_bio || (rc < 0))) { ++ if (rc < 0) ++ res = rc; ++ else ++ res = -EIO; ++ goto out_free_bios; ++ } else { ++ need_new_bio = true; ++ len -= rc; ++ offset += rc; ++ continue; ++ } ++ } ++ ++ need_new_bio = false; ++ offset = 0; ++ len -= bytes; ++ page = nth_page(page, 1); ++ } ++ } ++ ++ if (hbio == NULL) { ++ res = -EINVAL; ++ goto out_free_bios; ++ } ++ ++ /* Total length must be aligned on DMA padding alignment */ ++ if ((tot_len & q->dma_pad_mask) && ++ !(rq->cmd_flags & REQ_COPY_USER)) { ++ res = -EINVAL; ++ goto out_free_bios; ++ } ++ ++ if (bw != NULL) ++ atomic_set(&bw->bios_inflight, bios); ++ ++ while (hbio != NULL) { ++ bio = hbio; ++ hbio = hbio->bi_next; ++ bio->bi_next = NULL; ++ ++ blk_queue_bounce(q, &bio); ++ ++ res = blk_rq_append_bio(q, rq, bio); ++ if (unlikely(res != 0)) { ++ bio->bi_next = hbio; ++ hbio = bio; ++ /* We can have one or more bios bounced */ ++ goto out_unmap_bios; ++ } ++ } ++ ++ res = 0; ++ ++ rq->buffer = NULL; ++out: ++ return res; ++ ++out_unmap_bios: ++ blk_rq_unmap_kern_sg(rq, res); ++ ++out_free_bios: ++ while (hbio != NULL) { ++ bio = hbio; ++ hbio = hbio->bi_next; ++ bio_put(bio); ++ } ++ goto out; ++} ++ ++/** ++ * blk_rq_map_kern_sg - map kernel data to a request, for REQ_TYPE_BLOCK_PC ++ * @rq: request to fill ++ * @sgl: area to map ++ * @nents: number of elements in @sgl ++ * @gfp: memory allocation flags ++ * ++ * Description: ++ * Data will be mapped directly if possible. Otherwise a bounce ++ * buffer will be used. ++ */ ++int blk_rq_map_kern_sg(struct request *rq, struct scatterlist *sgl, ++ int nents, gfp_t gfp) ++{ ++ int res; ++ ++ res = __blk_rq_map_kern_sg(rq, sgl, nents, NULL, gfp); ++ if (unlikely(res != 0)) { ++ struct blk_kern_sg_work *bw = NULL; ++ ++ res = blk_rq_copy_kern_sg(rq, sgl, nents, &bw, ++ gfp, rq->q->bounce_gfp | gfp); ++ if (unlikely(res != 0)) ++ goto out; ++ ++ res = __blk_rq_map_kern_sg(rq, bw->sg_table.sgl, ++ bw->sg_table.nents, bw, gfp); ++ if (res != 0) { ++ blk_free_kern_sg_work(bw); ++ goto out; ++ } ++ } ++ ++ rq->buffer = NULL; ++ ++out: ++ return res; ++} ++EXPORT_SYMBOL(blk_rq_map_kern_sg); ++ ++/** ++ * blk_rq_unmap_kern_sg - unmap a request with kernel sg ++ * @rq: request to unmap ++ * @err: non-zero error code ++ * ++ * Description: ++ * Unmap a rq previously mapped by blk_rq_map_kern_sg(). Must be called ++ * only in case of an error! ++ */ ++void blk_rq_unmap_kern_sg(struct request *rq, int err) ++{ ++ struct bio *bio = rq->bio; ++ ++ while (bio) { ++ struct bio *b = bio; ++ bio = bio->bi_next; ++ b->bi_end_io(b, err); ++ } ++ rq->bio = NULL; ++ ++ return; ++} ++EXPORT_SYMBOL(blk_rq_unmap_kern_sg); ++ + /** + * blk_rq_map_kern - map kernel data to a request, for REQ_TYPE_BLOCK_PC usage + * @q: request queue where request should be inserted + +=== modified file 'include/linux/blkdev.h' +--- old/include/linux/blkdev.h 2014-06-18 01:32:48 +0000 ++++ new/include/linux/blkdev.h 2014-06-18 01:40:34 +0000 +@@ -717,6 +717,8 @@ extern unsigned long blk_max_low_pfn, bl + #define BLK_DEFAULT_SG_TIMEOUT (60 * HZ) + #define BLK_MIN_SG_TIMEOUT (7 * HZ) + ++#define SCSI_EXEC_REQ_FIFO_DEFINED ++ + #ifdef CONFIG_BOUNCE + extern int init_emergency_isa_pool(void); + extern void blk_queue_bounce(struct request_queue *q, struct bio **bio); +@@ -837,6 +839,9 @@ extern int blk_rq_map_kern(struct reques + extern int blk_rq_map_user_iov(struct request_queue *, struct request *, + struct rq_map_data *, const struct sg_iovec *, + int, unsigned int, gfp_t); ++extern int blk_rq_map_kern_sg(struct request *rq, struct scatterlist *sgl, ++ int nents, gfp_t gfp); ++extern void blk_rq_unmap_kern_sg(struct request *rq, int err); + extern int blk_execute_rq(struct request_queue *, struct gendisk *, + struct request *, int); + extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, + +=== modified file 'include/linux/scatterlist.h' +--- old/include/linux/scatterlist.h 2014-06-18 01:32:48 +0000 ++++ new/include/linux/scatterlist.h 2014-06-18 01:40:34 +0000 +@@ -8,6 +8,7 @@ + #include + #include + #include ++#include + + struct sg_table { + struct scatterlist *sgl; /* the list */ +@@ -249,6 +250,9 @@ size_t sg_pcopy_from_buffer(struct scatt + size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents, + void *buf, size_t buflen, off_t skip); + ++int sg_copy(struct scatterlist *dst_sg, struct scatterlist *src_sg, ++ int nents_to_copy, size_t copy_len); ++ + /* + * Maximum number of entries that will be allocated in one piece, if + * a list larger than this is required then chaining will be utilized. + +=== modified file 'lib/scatterlist.c' +--- old/lib/scatterlist.c 2014-06-18 01:32:48 +0000 ++++ new/lib/scatterlist.c 2014-06-18 01:40:34 +0000 +@@ -718,3 +718,127 @@ size_t sg_pcopy_to_buffer(struct scatter + return sg_copy_buffer(sgl, nents, buf, buflen, skip, true); + } + EXPORT_SYMBOL(sg_pcopy_to_buffer); ++ ++ ++/* ++ * Can switch to the next dst_sg element, so, to copy to strictly only ++ * one dst_sg element, it must be either last in the chain, or ++ * copy_len == dst_sg->length. ++ */ ++static int sg_copy_elem(struct scatterlist **pdst_sg, size_t *pdst_len, ++ size_t *pdst_offs, struct scatterlist *src_sg, ++ size_t copy_len) ++{ ++ int res = 0; ++ struct scatterlist *dst_sg; ++ size_t src_len, dst_len, src_offs, dst_offs; ++ struct page *src_page, *dst_page; ++ ++ dst_sg = *pdst_sg; ++ dst_len = *pdst_len; ++ dst_offs = *pdst_offs; ++ dst_page = sg_page(dst_sg); ++ ++ src_page = sg_page(src_sg); ++ src_len = src_sg->length; ++ src_offs = src_sg->offset; ++ ++ do { ++ void *saddr, *daddr; ++ size_t n; ++ ++ saddr = kmap_atomic(src_page + (src_offs >> PAGE_SHIFT)) + ++ (src_offs & ~PAGE_MASK); ++ daddr = kmap_atomic(dst_page + (dst_offs >> PAGE_SHIFT)) + ++ (dst_offs & ~PAGE_MASK); ++ ++ if (((src_offs & ~PAGE_MASK) == 0) && ++ ((dst_offs & ~PAGE_MASK) == 0) && ++ (src_len >= PAGE_SIZE) && (dst_len >= PAGE_SIZE) && ++ (copy_len >= PAGE_SIZE)) { ++ copy_page(daddr, saddr); ++ n = PAGE_SIZE; ++ } else { ++ n = min_t(size_t, PAGE_SIZE - (dst_offs & ~PAGE_MASK), ++ PAGE_SIZE - (src_offs & ~PAGE_MASK)); ++ n = min(n, src_len); ++ n = min(n, dst_len); ++ n = min_t(size_t, n, copy_len); ++ memcpy(daddr, saddr, n); ++ } ++ dst_offs += n; ++ src_offs += n; ++ ++ kunmap_atomic(saddr); ++ kunmap_atomic(daddr); ++ ++ res += n; ++ copy_len -= n; ++ if (copy_len == 0) ++ goto out; ++ ++ src_len -= n; ++ dst_len -= n; ++ if (dst_len == 0) { ++ dst_sg = sg_next(dst_sg); ++ if (dst_sg == NULL) ++ goto out; ++ dst_page = sg_page(dst_sg); ++ dst_len = dst_sg->length; ++ dst_offs = dst_sg->offset; ++ } ++ } while (src_len > 0); ++ ++out: ++ *pdst_sg = dst_sg; ++ *pdst_len = dst_len; ++ *pdst_offs = dst_offs; ++ return res; ++} ++ ++/** ++ * sg_copy - copy one SG vector to another ++ * @dst_sg: destination SG ++ * @src_sg: source SG ++ * @nents_to_copy: maximum number of entries to copy ++ * @copy_len: maximum amount of data to copy. If 0, then copy all. ++ * ++ * Description: ++ * Data from the source SG vector will be copied to the destination SG ++ * vector. End of the vectors will be determined by sg_next() returning ++ * NULL. Returns number of bytes copied. ++ */ ++int sg_copy(struct scatterlist *dst_sg, struct scatterlist *src_sg, ++ int nents_to_copy, size_t copy_len) ++{ ++ int res = 0; ++ size_t dst_len, dst_offs; ++ ++ if (copy_len == 0) ++ copy_len = 0x7FFFFFFF; /* copy all */ ++ ++ if (nents_to_copy == 0) ++ nents_to_copy = 0x7FFFFFFF; /* copy all */ ++ ++ dst_len = dst_sg->length; ++ dst_offs = dst_sg->offset; ++ ++ do { ++ int copied = sg_copy_elem(&dst_sg, &dst_len, &dst_offs, ++ src_sg, copy_len); ++ copy_len -= copied; ++ res += copied; ++ if ((copy_len == 0) || (dst_sg == NULL)) ++ goto out; ++ ++ nents_to_copy--; ++ if (nents_to_copy == 0) ++ goto out; ++ ++ src_sg = sg_next(src_sg); ++ } while (src_sg != NULL); ++ ++out: ++ return res; ++} ++EXPORT_SYMBOL(sg_copy); + diff --git a/scst/src/dev_handlers/Makefile b/scst/src/dev_handlers/Makefile index 464ff06db..f3f8b960d 100644 --- a/scst/src/dev_handlers/Makefile +++ b/scst/src/dev_handlers/Makefile @@ -73,6 +73,7 @@ all: install: all mkdir -p $(DESTDIR)/var/lib/scst/vdev_mode_pages $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ modules_install uninstall: diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index e06591426..84906969d 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -2407,7 +2407,9 @@ static int prepare_read_page(struct file *filp, int len, unsigned long index, last_index; long end_index, nr; loff_t isize; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0) read_descriptor_t desc = { .count = len }; +#endif int error; TRACE_ENTRY(); @@ -2460,8 +2462,13 @@ find_page: /* Did it get truncated before we got the lock? */ if (!page->mapping) goto page_not_up_to_date_locked; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0) + if (!mapping->a_ops->is_partially_uptodate(page, + offset & ~PAGE_CACHE_MASK, len)) +#else if (!mapping->a_ops->is_partially_uptodate(page, &desc, offset & ~PAGE_CACHE_MASK)) +#endif goto page_not_up_to_date_locked; unlock_page(page); } @@ -6015,7 +6022,7 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev, char *params, const char *const allowed_params[]) { int res = 0; - unsigned long val; + unsigned long long val; char *param, *p, *pp; TRACE_ENTRY(); @@ -6093,9 +6100,9 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev, } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) - res = kstrtoul(pp, 0, &val); + res = kstrtoull(pp, 0, &val); #else - res = strict_strtoul(pp, 0, &val); + res = strict_strtoull(pp, 0, &val); #endif if (res != 0) { PRINT_ERROR("strtoul() for %s failed: %d (device %s)", @@ -6137,7 +6144,7 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev, } else if (!strcasecmp("tst", p)) { if ((val != SCST_TST_0_SINGLE_TASK_SET) && (val != SCST_TST_1_SEP_TASK_SETS)) { - PRINT_ERROR("Invalid TST value %d", (int)val); + PRINT_ERROR("Invalid TST value %lld", val); res = -EINVAL; goto out; } @@ -6160,7 +6167,7 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev, res = -EINVAL; goto out; } - TRACE_DBG("block size %ld, block shift %d", + TRACE_DBG("block size %lld, block shift %d", val, virt_dev->blk_shift); } else { PRINT_ERROR("Unknown parameter %s (device %s)", p, @@ -6170,7 +6177,7 @@ static int vdev_parse_add_dev_params(struct scst_vdisk_dev *virt_dev, } } - if (virt_dev->file_size % (1 << virt_dev->blk_shift) != 0) { + if ((virt_dev->file_size & ((1 << virt_dev->blk_shift) - 1)) != 0) { PRINT_ERROR("Device size %lld is not a multiple of the block" " size %d", virt_dev->file_size, 1 << virt_dev->blk_shift); @@ -6765,7 +6772,7 @@ static int vdev_size_process_store(struct scst_sysfs_work_item *work) int size_shift, res = -EINVAL; if (sscanf(work->buf, "%d %lld", &size_shift, &new_size) != 2 || - new_size > (ULONG_MAX >> size_shift)) + new_size > (ULLONG_MAX >> size_shift)) goto put; new_size <<= size_shift; @@ -6783,7 +6790,7 @@ static int vdev_size_process_store(struct scst_sysfs_work_item *work) if (!virt_dev->nullio) { res = -EPERM; sBUG(); - } else if (new_size % (1 << virt_dev->blk_shift) == 0) { + } else if ((new_size & ((1 << virt_dev->blk_shift) - 1)) == 0) { virt_dev->file_size = new_size; virt_dev->nblocks = virt_dev->file_size >> dev->block_shift; } else { diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index afc92707a..369686ae1 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -76,6 +76,27 @@ static int strncasecmp(const char *s1, const char *s2, size_t n) } #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) +char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap) +{ + unsigned int len; + char *p; + va_list aq; + + va_copy(aq, ap); + len = vsnprintf(NULL, 0, fmt, aq); + va_end(aq); + + p = kmalloc_track_caller(len + 1, gfp); + if (!p) + return NULL; + + vsnprintf(p, len + 1, fmt, ap); + + return p; +} +#endif + #if !((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)) && defined(SCSI_EXEC_REQ_FIFO_DEFINED)) && !defined(HAVE_SG_COPY) static int sg_copy(struct scatterlist *dst_sg, struct scatterlist *src_sg, #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) @@ -9749,7 +9770,8 @@ void scst_vfs_unlink_and_put(struct nameidata *nd) #else void scst_vfs_unlink_and_put(struct path *path) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0) && \ + (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 7) vfs_unlink(path->dentry->d_parent->d_inode, path->dentry); #else vfs_unlink(path->dentry->d_parent->d_inode, path->dentry, NULL); diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 867e7f6b5..e85a9d0ed 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -2455,7 +2455,7 @@ static int __init init_scst(void) mutex_init(&scst_suspend_mutex); mutex_init(&scst_cmd_threads_mutex); INIT_LIST_HEAD(&scst_cmd_threads_list); - cpus_setall(default_cpu_mask); + cpumask_setall(&default_cpu_mask); scst_init_threads(&scst_main_cmd_threads); diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index c20edd010..9e7dbb1d9 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -2566,7 +2566,7 @@ void scst_pr_read_reservation(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) { struct scst_device *dev = cmd->dev; - uint8_t b[24]; + uint8_t b[24] = { }; int size = 0; TRACE_ENTRY(); @@ -2579,8 +2579,6 @@ void scst_pr_read_reservation(struct scst_cmd *cmd, uint8_t *buffer, goto out; } - memset(b, 0, sizeof(b)); - put_unaligned_be32(dev->pr_generation, &b[0]); if (!dev->pr_is_set) { diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index d9768fa5a..6ee2b2ef1 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1885,7 +1885,7 @@ static ssize_t __scst_acg_cpu_mask_show(struct scst_acg *acg, char *buf) res = cpumask_scnprintf(buf, SCST_SYSFS_BLOCK_SIZE, &acg->acg_cpu_mask); #endif - if (!cpus_equal(acg->acg_cpu_mask, default_cpu_mask)) + if (!cpumask_equal(&acg->acg_cpu_mask, &default_cpu_mask)) res += sprintf(&buf[res], "\n%s\n", SCST_SYSFS_KEY_MARK); return res; @@ -1991,7 +1991,7 @@ static ssize_t __scst_acg_cpu_mask_store(struct scst_acg *acg, goto out_release; } - if (cpus_equal(acg->acg_cpu_mask, work->cpu_mask)) + if (cpumask_equal(&acg->acg_cpu_mask, &work->cpu_mask)) goto out; work->tgt = acg->tgt; diff --git a/scst_local/Makefile b/scst_local/Makefile index 2dee7552a..7eba6e431 100644 --- a/scst_local/Makefile +++ b/scst_local/Makefile @@ -61,6 +61,7 @@ all: Modules.symvers Module.symvers install: all $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ SCST_INC_DIR=$(SCST_INC_DIR) modules_install SCST_MOD_VERS := $(shell ls $(SCST_DIR)/Modules.symvers 2>/dev/null) diff --git a/scst_local/in-tree/Makefile-3.15 b/scst_local/in-tree/Makefile-3.15 new file mode 100644 index 000000000..8cbbbff63 --- /dev/null +++ b/scst_local/in-tree/Makefile-3.15 @@ -0,0 +1,2 @@ +obj-$(CONFIG_SCST_LOCAL) += scst_local.o + diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t index 10f88b048..f1b6bcac7 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t @@ -8,6 +8,7 @@ BEGIN { } use Data::Dumper; +$Data::Dumper::Sortkeys = 1; use SCST::SCST; sub addTargets { diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t index c2b39a7d1..72db337a2 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t @@ -8,6 +8,7 @@ BEGIN { } use Data::Dumper; +$Data::Dumper::Sortkeys = 1; use SCST::SCST; sub setup { diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t index 02ff569ca..d31c739bf 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t @@ -8,6 +8,7 @@ BEGIN { } use Data::Dumper; +$Data::Dumper::Sortkeys = 1; use SCST::SCST; sub setup { diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf index 5e248d128..77c6f5389 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf @@ -45,7 +45,6 @@ DEVICE_GROUP dg01 { TARGET_GROUP tg01b { group_id 2 - preferred 0 state active TARGET tgt_b { diff --git a/srpt/LICENSE b/srpt/LICENSE index 7dd67d52b..bfaa85cb7 100644 --- a/srpt/LICENSE +++ b/srpt/LICENSE @@ -40,6 +40,5 @@ is the GNU Public License: 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., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. diff --git a/srpt/Makefile b/srpt/Makefile index a97d930df..95bb21216 100644 --- a/srpt/Makefile +++ b/srpt/Makefile @@ -48,44 +48,50 @@ MODULE_SYMVERS:=$(shell if [ -e $(KDIR)/Module.symvers ]; then \ echo Module.symvers; else echo Modules.symvers; fi) # Name of the OFED kernel RPM. -OFED_KERNEL_IB_RPM:=$(shell for r in kernel-ib mlnx-ofa_kernel compat-rdma; do rpm -q $$r 2>/dev/null | grep -q "^$$r" && echo $$r && break; done) +OFED_KERNEL_IB_RPM:=$(shell for r in mlnx-ofa_kernel compat-rdma kernel-ib; do rpm -q $$r 2>/dev/null | grep -q "^$$r" && echo $$r && break; done) # Name of the OFED kernel development RPM. -OFED_KERNEL_IB_DEVEL_RPM:=$(shell for r in kernel-ib-devel mlnx-ofa_kernel-devel compat-rdma-devel; do rpm -q $$r 2>/dev/null | grep -q "^$$r" && echo $$r && break; done) +OFED_KERNEL_IB_DEVEL_RPM:=$(shell for r in mlnx-ofa_kernel-devel compat-rdma-devel kernel-ib-devel; do rpm -q $$r 2>/dev/null | grep -q "^$$r" && echo $$r && break; done) -ifeq ($(OFED_KERNEL_IB_RPM),kernel-ib) +OFED_FLAVOR=$(shell /usr/bin/ofed_info 2>/dev/null | head -n1 | sed -n 's/^MLNX_OFED.*/MOFED/p;s/^OFED-.*/OFED/p') + +ifneq ($(OFED_KERNEL_IB_RPM),) +ifeq ($(OFED_KERNEL_IB_RPM),compat-rdma) +# OFED 3.x +OFED_KERNEL_DIR:=/usr/src/compat-rdma +OFED_CFLAGS:=-I$(OFED_KERNEL_DIR)/include +else OFED_KERNEL_DIR:=/usr/src/ofa_kernel -# Read OFED 1.x's config.mk, which contains the definition of the variable -# BACKPORT_INCLUDES. +ifeq ($(OFED_FLAVOR),MOFED) +# Mellanox OFED with or without kernel-ib RPM +OFED_CFLAGS:=-I$(OFED_KERNEL_DIR)/include +else +# OFED 1.5 include $(OFED_KERNEL_DIR)/config.mk OFED_CFLAGS:=$(BACKPORT_INCLUDES) -I$(OFED_KERNEL_DIR)/include endif -ifeq ($(OFED_KERNEL_IB_RPM),mlnx-ofa_kernel) -OFED_KERNEL_DIR:=/usr/src/ofa_kernel/default -OFED_CFLAGS:=-I$(OFED_KERNEL_DIR)/default/include endif -ifeq ($(OFED_KERNEL_IB_RPM),compat-rdma) -OFED_KERNEL_DIR:=/usr/src/compat-rdma -OFED_CFLAGS:=-I$(OFED_KERNEL_DIR)/include -endif -ifneq ($(OFED_KERNEL_IB_RPM),) +# Any OFED version OFED_MODULE_SYMVERS:=$(OFED_KERNEL_DIR)/Module.symvers endif -# Path of the OFED ib_srpt.ko kernel module. -OFED_SRPT_PATH:=/lib/modules/$(KVER)/updates/kernel/drivers/infiniband/ulp/srpt/ib_srpt.ko - -# Whether or not the OFED ib_srpt.ko kernel module has been installed. -OFED_SRPT_INSTALLED:=$(shell if [ -e $(OFED_SRPT_PATH) ]; then echo true; else echo false; fi) +HAVE_KCFLAGS = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/kcflags KCFLAGS=-DKCFLAGS_MACRO=1 >/dev/null 2>&1 && echo true || echo false) +HAVE_PRE_CFLAGS = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/pre_cflags PRE_CFLAGS=-DPRE_CFLAGS_MACRO=1 >/dev/null 2>&1 && echo true || echo false) +AUTOCONF_FLAGS = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/gid_change PRE_CFLAGS="$(OFED_CFLAGS)" >/dev/null 2>&1 && echo -DHAVE_IB_EVENT_GID_CHANGE) all: src/$(MODULE_SYMVERS) $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src \ - PRE_CFLAGS="$(OFED_CFLAGS)" SCST_INC_DIR=$(SCST_INC_DIR) modules + PRE_CFLAGS="$(OFED_CFLAGS) $(AUTOCONF_FLAGS)" \ + KCFLAGS="$(AUTOCONF_FLAGS)" SCST_INC_DIR=$(SCST_INC_DIR) modules install: all src/ib_srpt.ko + @[ -z "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && \ + find /lib/modules/$(KVER) -name ib_srpt.ko -exec rm {} \; ; \ + true $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/src \ PRE_CFLAGS="$(OFED_CFLAGS)" SCST_INC_DIR=$(SCST_INC_DIR) \ + $$([ -n "$(DESTDIR)$(INSTALL_MOD_PATH)" ] && echo DEPMOD=true) \ modules_install uninstall: @@ -93,6 +99,11 @@ uninstall: -/sbin/depmod -b $(INSTALL_MOD_PATH)/ -a $(KVER) src/Module.symvers src/Modules.symvers: $(SCST_SYMVERS_DIR)/$(MODULE_SYMVERS) + @if [ "$(HAVE_KCFLAGS)" = false -a "$(HAVE_PRE_CFLAGS)" = false -a \ + -n "$(AUTOCONF_FLAGS)" ]; then \ + echo "Error: the kernel build system has not yet been patched.";\ + false; \ + fi @if [ -n "$(OFED_KERNEL_IB_RPM)" ]; then \ if [ -z "$(OFED_KERNEL_IB_DEVEL_RPM)" ]; then \ echo "Error: the OFED package $(OFED_KERNEL_IB_RPM)-devel has" \ @@ -103,20 +114,12 @@ src/Module.symvers src/Modules.symvers: $(SCST_SYMVERS_DIR)/$(MODULE_SYMVERS) "must be removed first" \ " (/lib/modules/$(KVER)/kernel/drivers/infiniband)."; \ false; \ - elif $(OFED_SRPT_INSTALLED); then \ - echo "Error: OFED has been built with srpt=y in ofed.conf."; \ - echo "Rebuild OFED with srpt=n."; \ - false; \ - elif [ -e $(KDIR)/scripts/Makefile.lib ] \ - && ! grep -wq '^c_flags .*PRE_CFLAGS' \ - $(KDIR)/scripts/Makefile.lib \ - && ! grep -wq '^LINUXINCLUDE .*PRE_CFLAGS' \ - $(KDIR)/Makefile; then \ + elif [ "$(HAVE_PRE_CFLAGS)" = false ]; then \ echo "Error: the kernel build system has not yet been patched.";\ false; \ else \ - echo " Building against $(OFED_KERNEL_IB_RPM) InfiniBand" \ - "kernel headers."; \ + echo " Building against $(OFED_FLAVOR) $(OFED_KERNEL_IB_RPM)" \ + "InfiniBand kernel headers."; \ ( \ grep -v drivers/infiniband/ $<; \ cat $(OFED_MODULE_SYMVERS) \ diff --git a/srpt/README b/srpt/README index f5940962c..ae06ffd62 100644 --- a/srpt/README +++ b/srpt/README @@ -50,7 +50,8 @@ The ib_srpt kernel module supports the following parameters: Mode (1) is choosen if both one_target_per_port and use_node_guid_in_target_name are false. Mode (2) is choosen if one_target_per_port is false and use_node_guid_in_target_name is true. Mode - (3) is choosen if one_target_per_port is true. + (3) is choosen if one_target_per_port is true. This last mode is the + default mode. * rdma_cm_port (number) A 16-bit number that specifies the port number to be registered via the RDMA/CM. Must be specified to make communication over RoCE or iWARP diff --git a/srpt/conftest/gid_change/Makefile b/srpt/conftest/gid_change/Makefile new file mode 100644 index 000000000..e81c05753 --- /dev/null +++ b/srpt/conftest/gid_change/Makefile @@ -0,0 +1 @@ +obj-m += gid_change.o diff --git a/srpt/conftest/gid_change/gid_change.c b/srpt/conftest/gid_change/gid_change.c new file mode 100644 index 000000000..bb60773fb --- /dev/null +++ b/srpt/conftest/gid_change/gid_change.c @@ -0,0 +1,9 @@ +#include +#include + +static int modinit(void) +{ + return IB_EVENT_GID_CHANGE; +} + +module_init(modinit); diff --git a/srpt/conftest/kcflags/Makefile b/srpt/conftest/kcflags/Makefile new file mode 100644 index 000000000..59e12dda0 --- /dev/null +++ b/srpt/conftest/kcflags/Makefile @@ -0,0 +1 @@ +obj-m += kcflags.o diff --git a/srpt/conftest/kcflags/kcflags.c b/srpt/conftest/kcflags/kcflags.c new file mode 100644 index 000000000..fff6e202f --- /dev/null +++ b/srpt/conftest/kcflags/kcflags.c @@ -0,0 +1,8 @@ +#include + +static int modinit(void) +{ + return KCFLAGS_MACRO; +} + +module_init(modinit); diff --git a/srpt/conftest/pre_cflags/Makefile b/srpt/conftest/pre_cflags/Makefile new file mode 100644 index 000000000..3c8c550f2 --- /dev/null +++ b/srpt/conftest/pre_cflags/Makefile @@ -0,0 +1 @@ +obj-m += pre_cflags.o diff --git a/srpt/conftest/pre_cflags/pre_cflags.c b/srpt/conftest/pre_cflags/pre_cflags.c new file mode 100644 index 000000000..1602d7115 --- /dev/null +++ b/srpt/conftest/pre_cflags/pre_cflags.c @@ -0,0 +1,8 @@ +#include + +static int modinit(void) +{ + return PRE_CFLAGS_MACRO; +} + +module_init(modinit); diff --git a/srpt/patches/kernel-3.15-pre-cflags.patch b/srpt/patches/kernel-3.15-pre-cflags.patch new file mode 100644 index 000000000..3964ee179 --- /dev/null +++ b/srpt/patches/kernel-3.15-pre-cflags.patch @@ -0,0 +1,12 @@ +diff --git a/Makefile b/Makefile +index 540f7b2..078307f 100644 +--- a/Makefile ++++ b/Makefile +@@ -361,6 +361,7 @@ USERINCLUDE := \ + # Use LINUXINCLUDE when you must reference the include/ directory. + # Needed to be compatible with the O= option + LINUXINCLUDE := \ ++ $(PRE_CFLAGS) \ + -I$(srctree)/arch/$(hdr-arch)/include \ + -Iarch/$(hdr-arch)/include/generated \ + $(if $(KBUILD_SRC), -I$(srctree)/include) \ diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 62acead56..8b5998914 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -151,9 +151,9 @@ MODULE_PARM_DESC(use_node_guid_in_target_name, #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) \ || defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 5 -static int one_target_per_port; +static int one_target_per_port = true; #else -static bool one_target_per_port; +static bool one_target_per_port = true; #endif module_param(one_target_per_port, bool, 0444); MODULE_PARM_DESC(one_target_per_port, @@ -1542,8 +1542,9 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch, int status, const u8 *sense_data, int sense_data_len) { + struct scst_cmd *cmd = &ioctx->scmnd; struct srp_rsp *srp_rsp; - int max_sense_len; + int resid, max_sense_len; /* * The lowest bit of all SAM-3 status codes is zero (see also @@ -1560,6 +1561,23 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch, srp_rsp->tag = tag; srp_rsp->status = status; + if (unlikely(scst_get_resid(cmd, &resid, NULL) && resid != 0)) { + if (scst_cmd_get_data_direction(cmd) & SCST_DATA_READ) { + if (resid > 0) + srp_rsp->flags |= SRP_RSP_FLAG_DIUNDER; + else if (resid < 0) + srp_rsp->flags |= SRP_RSP_FLAG_DIOVER; + srp_rsp->data_in_res_cnt = cpu_to_be32(abs(resid)); + } + if (scst_cmd_get_data_direction(cmd) & SCST_DATA_WRITE) { + if (resid > 0) + srp_rsp->flags |= SRP_RSP_FLAG_DOUNDER; + else if (resid < 0) + srp_rsp->flags |= SRP_RSP_FLAG_DOOVER; + srp_rsp->data_out_res_cnt = cpu_to_be32(abs(resid)); + } + } + if (!scst_sense_valid(sense_data)) sense_data_len = 0; else { @@ -1938,9 +1956,11 @@ static void srpt_process_send_completion(struct ib_cq *cq, } else if (opcode == SRPT_RDMA_READ_LAST || opcode == SRPT_RDMA_WRITE_LAST) { PRINT_INFO("RDMA t %d for idx %u failed with status %d." + "%s", opcode, index, wc->status, + wc->status == IB_WC_WR_FLUSH_ERR ? " If this has not been triggered by a cable" " pull, please check the involved IB HCA's" - " and cables.", opcode, index, wc->status); + " and cables." : ""); srpt_handle_rdma_err_comp(ch, ch->ioctx_ring[index], opcode, srpt_xmt_rsp_context); } else if (opcode == SRPT_RDMA_ZEROLENGTH_WRITE) { @@ -2057,6 +2077,16 @@ static int srpt_compl_thread(void *arg) ch = arg; BUG_ON(!ch); + while (ch->state < CH_LIVE) { + set_current_state(TASK_INTERRUPTIBLE); + if (srpt_process_completion(ch, poll_budget) >= poll_budget) + cond_resched(); + else + schedule(); + } + + srpt_process_wait_list(ch); + while (ch->state < CH_DISCONNECTED) { set_current_state(TASK_INTERRUPTIBLE); if (srpt_process_completion(ch, poll_budget) >= poll_budget) @@ -2247,9 +2277,7 @@ static void __srpt_close_all_ch(struct srpt_tgt *srpt_tgt) struct srpt_nexus *nexus; struct srpt_rdma_ch *ch; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) lockdep_assert_held(&srpt_tgt->mutex); -#endif list_for_each_entry(nexus, &srpt_tgt->nexus_list, entry) { list_for_each_entry(ch, &nexus->ch_list, list) { diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 135091311..0e30e16ea 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -51,7 +51,7 @@ #if defined(RHEL_MAJOR) && RHEL_MAJOR -0 == 5 #define vlan_dev_vlan_id(dev) (panic("RHEL 5 misses vlan_dev_vlan_id()"),0) #endif -#if defined(RHEL_MAJOR) +#if defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 6 #define __ethtool_get_settings(dev, cmd) (panic("RHEL misses __ethtool_get_settings()"),0) #endif #include @@ -142,12 +142,7 @@ enum { }; #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0) && \ - !(defined(CONFIG_SUSE_KERNEL) && \ - LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 76)) && \ - !(defined(RHEL_MAJOR) && \ - (RHEL_MAJOR -0 > 6 || \ - RHEL_MAJOR -0 == 6 && RHEL_MINOR -0 >= 5 || \ - RHEL_MAJOR -0 == 5 && RHEL_MINOR -0 >= 9)) + !defined(HAVE_IB_EVENT_GID_CHANGE) /* See also patch "IB/core: Add GID change event" (commit 761d90ed4). */ enum { IB_EVENT_GID_CHANGE = 18 }; #endif