diff --git a/Makefile b/Makefile index b7f8fe971..e17b06726 100644 --- a/Makefile +++ b/Makefile @@ -54,11 +54,11 @@ EMULEX_DIR=emulex ISCSI_DIR=iscsi-scst -VERSION = $(shell echo -n "$$(sed -n 's/^\#define[[:blank:]]SCST_VERSION_NAME[[:blank:]]*\"\([^-]*\).*\"/\1/p' scst/include/scst_const.h)."; \ - if svn info >/dev/null 2>&1; \ +REVISION ?= $(shell if svn info >/dev/null 2>&1; \ then svn info | sed -n 's/^Revision:[[:blank:]]*/r/p';\ - else git show | sed -n 's/^commit[[:blank:]]*\(.......\).*/\1/p'; \ + else echo -n r; git log | grep -c ^commit; \ fi) +VERSION = $(shell echo -n "$$(sed -n 's/^\#define[[:blank:]]SCST_VERSION_NAME[[:blank:]]*\"\([^-]*\).*\"/\1/p' scst/include/scst_const.h).$(REVISION)") help: @echo " all : make all" @@ -453,6 +453,7 @@ scst-dkms-rpm: <$${name}.spec.in >$${name}.spec && \ MAKE="$(MAKE)" rpmbuild --define="%_topdir $${rpmtopdir}" \ $(if $(KVER),--define="%kversion $(KVER)") \ + $(if $(KDIR),--define="%kdir $(KDIR)") \ -ba $${name}.spec && \ rm -f $${name}-$(VERSION).tar.bz2 diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index 2bfc53cd4..d5fc4a7d3 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -1345,6 +1345,8 @@ static int isert_cm_conn_req_handler(struct rdma_cm_id *cm_id, tgt_conn_param.private_data = &cm_hdr; cm_hdr.flags = ISER_ZBVA_NOT_SUPPORTED | ISER_SEND_W_INV_NOT_SUPPORTED; + kref_get(&isert_conn->kref); + err = rdma_accept(cm_id, &tgt_conn_param); if (unlikely(err)) { pr_err("Failed to accept conn request, err:%d\n", err); @@ -1422,7 +1424,6 @@ static int isert_cm_connect_handler(struct rdma_cm_id *cm_id, if (unlikely(ret)) goto out; - kref_get(&isert_conn->kref); kref_get(&isert_conn->kref); /* notify upper layer */ ret = isert_conn_established(&isert_conn->iscsi, @@ -1592,6 +1593,12 @@ static int isert_cm_evt_handler(struct rdma_cm_id *cm_id, isert_conn = cm_id->qp->qp_context; set_bit(ISERT_CONNECTION_ABORTED, &isert_conn->flags); + /* + * reaching here must be with the isert_conn refcount of 2, + * one from the init and one from the connect request, + * thus it is safe to deref directly before the sched_conn_closed + */ + isert_conn_free(isert_conn); isert_sched_conn_closed(isert_conn); err = 0; } diff --git a/scst.spec.in b/scst.spec.in index 99a18b157..e983f58cb 100644 --- a/scst.spec.in +++ b/scst.spec.in @@ -9,7 +9,7 @@ %{!?kversion:%define kversion %{expand:%%( if rpm --quiet -q kernel-headers; then rpm -q --qf '%%%%{version}-%%%%{release}.%%%%{arch}\\n' \\ - kernel-headers | head -n1; + kernel-headers | tail -n1; else uname -r; fi @@ -64,6 +64,8 @@ BuildRequires: %{?kernel_rpm:%{kernel_rpm} = %{krpmver} %{kernel_devel_rpm} = %{ Source: %{kmod_name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-build AutoReqProv: no +Requires: %{expand:%%(for c in depmod find rm; do echo -n "$(which $c) "; done)} +Provides: scst %description A generic SCSI target subsystem for Linux that allows to convert any Linux @@ -104,13 +106,16 @@ Authors: %build make 2release export KVER=%{kversion} PREFIX=%{_prefix} +%{?kdir:%{expand:%%(export KDIR=%{kdir})}} export BUILD_2X_MODULE=y CONFIG_SCSI_QLA_FC=y CONFIG_SCSI_QLA2XXX_TARGET=y +make 2release for d in scst fcst iscsi-scst qla2x00t/qla2x00-target scst_local srpt; do %{make} -C $d done %install export KVER=%{kversion} PREFIX=%{_prefix} MANDIR=%{_mandir} +%{?kdir:%{expand:%%(export KDIR=%{kdir})}} export BUILD_2X_MODULE=y CONFIG_SCSI_QLA_FC=y CONFIG_SCSI_QLA2XXX_TARGET=y for d in scst; do DESTDIR=%{buildroot} %{make} -C $d install diff --git a/scst/include/scst.h b/scst/include/scst.h index 441d931f7..e8668608e 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -2275,6 +2275,7 @@ struct scst_cmd_threads { int io_context_refcnt; bool io_context_ready; + wait_queue_head_t ioctx_wq; /* io_context_mutex protects io_context and io_context_refcnt. */ struct mutex io_context_mutex; diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 84b04d115..dd1eaf3e7 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4645,6 +4645,7 @@ struct scst_acg *scst_tgt_find_acg(struct scst_tgt *tgt, const char *name) static struct scst_tgt_dev *scst_find_shared_io_tgt_dev( struct scst_tgt_dev *tgt_dev) { + struct scst_cmd_threads *a; struct scst_tgt_dev *res = NULL; struct scst_session *sess = tgt_dev->sess; struct scst_acg *acg = tgt_dev->acg_dev->acg; @@ -4716,21 +4717,16 @@ out: return res; found: - if (t->active_cmd_threads == &scst_main_cmd_threads) { - res = t; + res = t; + a = t->active_cmd_threads; + if (a == &scst_main_cmd_threads) { TRACE_DBG("Going to share async IO context %p (res %p, " "ini %s, dev %s, grouping type %d)", t->aic_keeper->aic, res, t->sess->initiator_name, t->dev->virt_name, t->acg_dev->acg->acg_io_grouping_type); } else { - res = t; - if (!*(volatile bool *)&res->active_cmd_threads->io_context_ready) { - TRACE_DBG("IO context for t %p not yet " - "initialized, waiting...", t); - msleep(100); - goto found; - } + wait_event(a->ioctx_wq, a->io_context_ready); smp_rmb(); TRACE_DBG("Going to share IO context %p (res %p, ini %s, " "dev %s, cmd_threads %p, grouping type %d)", diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 090b215eb..7b50d6fe9 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -1925,11 +1925,8 @@ out_wait: * Wait for io_context gets initialized to avoid possible races * for it from the sharing it tgt_devs. */ - while (!*(volatile bool *)&cmd_threads->io_context_ready) { - TRACE_DBG("Waiting for io_context for cmd_threads %p " - "initialized", cmd_threads); - msleep(50); - } + wait_event(cmd_threads->ioctx_wq, + cmd_threads->io_context_ready); smp_rmb(); } @@ -2178,6 +2175,7 @@ void scst_init_threads(struct scst_cmd_threads *cmd_threads) spin_lock_init(&cmd_threads->cmd_list_lock); INIT_LIST_HEAD(&cmd_threads->active_cmd_list); init_waitqueue_head(&cmd_threads->cmd_list_waitQ); + init_waitqueue_head(&cmd_threads->ioctx_wq); INIT_LIST_HEAD(&cmd_threads->threads_list); mutex_init(&cmd_threads->io_context_mutex); spin_lock_init(&cmd_threads->thr_lock); diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 6ccb8cf40..1706acb78 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -1168,7 +1168,7 @@ out_return: out_return1: *sgv = obj; - TRACE_MEM("Returning failed obj %p (count %d)", obj, *count); + TRACE_MEM("Returning failed obj %p", obj); out_return2: *count = pages_to_alloc; diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index bfde1f209..e06be51f2 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -5023,6 +5023,8 @@ int scst_cmd_thread(void *arg) scst_ioctx_get(p_cmd_threads); + wake_up_all(&p_cmd_threads->ioctx_wq); + spin_lock_irq(&p_cmd_threads->cmd_list_lock); while (!kthread_should_stop()) { wait_event_locked(p_cmd_threads->cmd_list_waitQ, diff --git a/scstadmin/Makefile b/scstadmin/Makefile index 72bb5b831..0cb1cf85c 100644 --- a/scstadmin/Makefile +++ b/scstadmin/Makefile @@ -2,11 +2,11 @@ ifndef PREFIX PREFIX=/usr/local endif -VERSION = $(shell echo -n "$$(sed -n 's/^[[:blank:]]*\$$VERSION[[:blank:]]*=[[:blank:]]*[\"'"'"']\([0-9.]*\)[\"'"'"'];$$/\1/p' scstadmin/scst-*/lib/SCST/SCST.pm)."; \ - if svn info >/dev/null 2>&1; \ +REVISION ?= $(shell if svn info >/dev/null 2>&1; \ then svn info | sed -n 's/^Revision:[[:blank:]]*/r/p';\ - else git show | sed -n 's/^commit[[:blank:]]*\(.......\).*/\1/p'; \ + else echo -n r; git log | grep -c ^commit; \ fi) +VERSION = $(shell echo -n "$$(sed -n 's/^[[:blank:]]*\$$VERSION[[:blank:]]*=[[:blank:]]*[\"'"'"']\([0-9.]*\)[\"'"'"'];$$/\1/p' scstadmin/scst-*/lib/SCST/SCST.pm).$(REVISION)") SCSTADMIN_DIR = $(shell if [ ! -h scstadmin ]; then \ rm -f scstadmin; \ diff --git a/scstadmin/scstadmin.spec.in b/scstadmin/scstadmin.spec.in index 3105c71f3..0b40c1181 100644 --- a/scstadmin/scstadmin.spec.in +++ b/scstadmin/scstadmin.spec.in @@ -13,6 +13,7 @@ URL: http://scst.sourceforge.net/ Source: %{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-build AutoReqProv: yes +Requires: %{expand:%%(for c in rm; do echo -n "$(which $c) "; done)} %description A tool for configuring SCST via the SCST sysfs interface. Allows to save,