diff --git a/SOURCES/0001-Add-error-message-for-new-ISCSI_ERR_NOP_TIMEDOUT.patch b/SOURCES/0001-Add-error-message-for-new-ISCSI_ERR_NOP_TIMEDOUT.patch new file mode 100644 index 0000000..a5364ec --- /dev/null +++ b/SOURCES/0001-Add-error-message-for-new-ISCSI_ERR_NOP_TIMEDOUT.patch @@ -0,0 +1,27 @@ +From 6b5eb1008e593d7cadbc4165ee6978d8d2ff4f76 Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Thu, 12 Apr 2018 18:17:00 -0700 +Subject: [PATCH 1/1] Add error message for new ISCSI_ERR_NOP_TIMEDOUT + +This new error enum was added with commit 5c654fcc617a, +but it needs to be added to kern_err_table as well. +--- + usr/kern_err_table.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/usr/kern_err_table.c b/usr/kern_err_table.c +index a6ea8fb..8af6f05 100644 +--- a/usr/kern_err_table.c ++++ b/usr/kern_err_table.c +@@ -77,6 +77,8 @@ const char *kern_err_code_to_string(int err) + case ISCSI_ERR_SCSI_EH_SESSION_RST: + return "ISCSI_ERR_SCSI_EH_SESSION_RST: Session was dropped as " + "a result of SCSI error recovery"; ++ case ISCSI_ERR_NOP_TIMEDOUT: ++ return "ISCSI_ERR_NOP_TIMEDOUT: A NOP has timed out"; + default: + return "Invalid or unknown error code"; + } +-- +2.21.0 + diff --git a/SOURCES/0001-Keep-iscsi_if-in-sync-with-kernel-version.patch b/SOURCES/0001-Keep-iscsi_if-in-sync-with-kernel-version.patch new file mode 100644 index 0000000..d9a6d07 --- /dev/null +++ b/SOURCES/0001-Keep-iscsi_if-in-sync-with-kernel-version.patch @@ -0,0 +1,59 @@ +From 5c654fcc617a7b42d93a53660ea578b2ab3efa3e Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Thu, 12 Apr 2018 16:49:00 -0700 +Subject: [PATCH 1/1] Keep iscsi_if in sync with kernel version. + +Add in a new enum for iscsi_param and iscsi_err, +and add a couple of new (higher) port speeds. + +Also added a note about having to keep this +file in sync with the kernel version. +--- + include/iscsi_if.h | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/include/iscsi_if.h b/include/iscsi_if.h +index 5be1981..2d46214 100644 +--- a/include/iscsi_if.h ++++ b/include/iscsi_if.h +@@ -30,6 +30,12 @@ + + #include "iscsi_proto.h" + ++/* ++ * NOTE: This file should be kept in sync with the kernel include file ++ * of the same name. In particular, iscsi_param and iscsi_err need ++ * to be in sync. ++ */ ++ + #define ISCSI_NL_GRP_ISCSID 1 + #define ISCSI_NL_GRP_UIP 2 + +@@ -536,6 +542,7 @@ enum iscsi_err { + ISCSI_ERR_XMIT_FAILED = ISCSI_ERR_BASE + 19, + ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20, + ISCSI_ERR_SCSI_EH_SESSION_RST = ISCSI_ERR_BASE + 21, ++ ISCSI_ERR_NOP_TIMEDOUT = ISCSI_ERR_BASE + 22, + }; + + /* +@@ -627,6 +634,7 @@ enum iscsi_param { + + ISCSI_PARAM_DISCOVERY_PARENT_IDX, + ISCSI_PARAM_DISCOVERY_PARENT_TYPE, ++ ISCSI_PARAM_LOCAL_IPADDR, + /* must always be last */ + ISCSI_PARAM_MAX, + }; +@@ -731,6 +739,8 @@ enum iscsi_port_speed { + ISCSI_PORT_SPEED_100MBPS = 0x4, + ISCSI_PORT_SPEED_1GBPS = 0x8, + ISCSI_PORT_SPEED_10GBPS = 0x10, ++ ISCSI_PORT_SPEED_25GBPS = 0x20, ++ ISCSI_PORT_SPEED_40GBPS = 0x40, + }; + + /* iSCSI port state */ +-- +2.21.0 + diff --git a/SOURCES/0001-Update-service-files-and-add-sd_notify-support-to-is.patch b/SOURCES/0001-Update-service-files-and-add-sd_notify-support-to-is.patch new file mode 100644 index 0000000..29d575e --- /dev/null +++ b/SOURCES/0001-Update-service-files-and-add-sd_notify-support-to-is.patch @@ -0,0 +1,571 @@ +From 6896af7a1a076302470db07ac9e6e91eee8988df Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Tue, 16 Oct 2018 13:53:09 -0700 +Subject: [PATCH 1/1] Update service files and add sd_notify support to iscsid + and iscsiuio + +Cherry Picks the following changes from upstream: + + * Added service file for iscsi logins + * Use sd_notify() to tell systemd when iscsid is ready. + * Update systemd unit files for iscsid + * Use pkg-config in Makefiles for newer libraries. + * Improve daemon synchronization, fix err msgs + * Fix pipe notification code + * Add systemd support for iscsiuio + * Make iscsid systemd usage optional + * Handle systemd disablement correctly in iscsiuio +--- + Makefile | 10 +++++- + etc/systemd/iscsi.service | 21 +++++------- + etc/systemd/iscsid.service | 12 +++---- + etc/systemd/iscsiuio.service | 8 +++-- + iscsiuio/configure.ac | 8 +++++ + iscsiuio/src/unix/logger.c | 2 +- + iscsiuio/src/unix/main.c | 49 +++++++++++++++++++++----- + usr/Makefile | 14 ++++++-- + usr/event_poll.c | 21 ++++++++++-- + usr/event_poll.h | 1 + + usr/iscsi_sysfs.c | 44 ++++++++++++++++++++++++ + usr/iscsi_sysfs.h | 1 + + usr/iscsid.c | 66 +++++++++++++++++++++++++++++------- + 13 files changed, 208 insertions(+), 49 deletions(-) + +diff --git a/Makefile b/Makefile +index 03175a3..340c457 100644 +--- a/Makefile ++++ b/Makefile +@@ -31,6 +31,14 @@ ifneq (,$(CFLAGS)) + export CFLAGS + endif + ++# export systemd disablement if set ++ifneq ($(NO_SYSTEMD),) ++export NO_SYSTEMD ++WITHOUT_ARG = --without-systemd ++else ++WITHOUT_ARG = ++endif ++ + # Random comments: + # using '$(MAKE)' instead of just 'make' allows make to run in parallel + # over multiple makefile. +@@ -59,7 +67,7 @@ utils/open-isns/Makefile: utils/open-isns/configure utils/open-isns/Makefile.in + cd utils/open-isns; ./configure --with-security=no + + iscsiuio/Makefile: iscsiuio/configure iscsiuio/Makefile.in +- cd iscsiuio; ./configure ++ cd iscsiuio; ./configure $(WITHOUT_ARG) + + iscsiuio/configure iscsiuio/Makefile.in: iscsiuio/configure.ac iscsiuio/Makefile.am + cd iscsiuio; autoreconf --install +diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service +index 2736956..0edcf51 100644 +--- a/etc/systemd/iscsi.service ++++ b/etc/systemd/iscsi.service +@@ -1,20 +1,17 @@ + [Unit] + Description=Login and scanning of iSCSI devices +-Documentation=man:iscsid(8) man:iscsiadm(8) +-DefaultDependencies=no +-Conflicts=shutdown.target +-After=systemd-remount-fs.service network.target iscsid.service iscsiuio.service +-Before=remote-fs-pre.target +-Wants=remote-fs-pre.target iscsi-shutdown.service +-ConditionDirectoryNotEmpty=|/var/lib/iscsi/nodes +-ConditionDirectoryNotEmpty=|/sys/class/iscsi_session ++Documentation=man:iscsiadm(8) man:iscsid(8) ++Before=remote-fs.target ++After=network.target network-online.target iscsid.service ++ConditionPathExists=/etc/iscsi/initiatorname.iscsi + + [Service] + Type=oneshot +-RemainAfterExit=true +-ExecStart=-/usr/libexec/iscsi-mark-root-nodes + ExecStart=-/sbin/iscsiadm -m node --loginall=automatic +-ExecReload=-/sbin/iscsiadm -m node --loginall=automatic ++ExecStop=/sbin/iscsiadm -m node --logoutall=automatic ++ExecStop=/sbin/iscsiadm -m node --logoutall=manual ++SuccessExitStatus=21 ++RemainAfterExit=true + + [Install] +-WantedBy=sysinit.target ++WantedBy=remote-fs.target +diff --git a/etc/systemd/iscsid.service b/etc/systemd/iscsid.service +index 653dd08..f5e8979 100644 +--- a/etc/systemd/iscsid.service ++++ b/etc/systemd/iscsid.service +@@ -1,16 +1,16 @@ + [Unit] + Description=Open-iSCSI +-Documentation=man:iscsid(8) man:iscsiadm(8) ++Documentation=man:iscsid(8) man:iscsiuio(8) man:iscsiadm(8) + DefaultDependencies=no +-Conflicts=shutdown.target + After=network.target iscsiuio.service + Before=remote-fs-pre.target + + [Service] +-Type=forking +-PIDFile=/var/run/iscsid.pid +-ExecStart=/usr/sbin/iscsid +-ExecStop=/sbin/iscsiadm -k 0 2 ++Type=notify ++NotifyAccess=main ++ExecStart=/sbin/iscsid -f ++KillMode=mixed + + [Install] + WantedBy=multi-user.target ++Also=iscsid.socket +diff --git a/etc/systemd/iscsiuio.service b/etc/systemd/iscsiuio.service +index f0410b7..e4d9fd0 100644 +--- a/etc/systemd/iscsiuio.service ++++ b/etc/systemd/iscsiuio.service +@@ -9,9 +9,11 @@ After=network.target + Before=remote-fs-pre.target iscsid.service + + [Service] +-Type=forking +-PIDFile=/var/run/iscsiuio.pid +-ExecStart=/usr/sbin/iscsiuio ++Type=notify ++NotifyAccess=main ++ExecStart=/sbin/iscsiuio -f ++KillMode=mixed ++Restart=on-failure + + [Install] + WantedBy=multi-user.target +diff --git a/iscsiuio/configure.ac b/iscsiuio/configure.ac +index 7d53323..b41df0e 100644 +--- a/iscsiuio/configure.ac ++++ b/iscsiuio/configure.ac +@@ -63,6 +63,14 @@ AC_ARG_ENABLE(debug, + CFLAGS="${CFLAGS} -g -O0" + fi]) + AM_CONDITIONAL([DEBUG], [test x$debug = xtrue]) ++## check for systemd support, default on ++AC_ARG_WITH([systemd], ++ AS_HELP_STRING([--without-systemd], [Build without systemd]), ++ [case "${withval}" in ++ yes) LDFLAGS="`pkg-config --libs libsystemd`" ;; ++ no) CFLAGS="${CFLAGS} -DNO_SYSTEMD" ;; ++ *) AC_MSG_ERROR([bad value $withval for --with-systemd]) ;; ++ esac],[LDFLAGS="`pkg-config --libs libsystemd`"]) + + AC_CONFIG_COMMANDS([default],[[ + if [ -n "$SOURCE_DATE_EPOCH" ] ; then +diff --git a/iscsiuio/src/unix/logger.c b/iscsiuio/src/unix/logger.c +index d41f9e8..87e16cd 100644 +--- a/iscsiuio/src/unix/logger.c ++++ b/iscsiuio/src/unix/logger.c +@@ -135,7 +135,7 @@ int init_logger(char *filename) + } + main_log.fp = fopen(filename, "a"); + if (main_log.fp == NULL) { +- printf("Could not create log file: %s <%s>\n", ++ fprintf(stderr, "WARN: Could not create log file: %s <%s>\n", + filename, strerror(errno)); + rc = -EIO; + } +diff --git a/iscsiuio/src/unix/main.c b/iscsiuio/src/unix/main.c +index 39d5339..188b96e 100644 +--- a/iscsiuio/src/unix/main.c ++++ b/iscsiuio/src/unix/main.c +@@ -48,6 +48,9 @@ + #include + #include + #include ++#ifndef NO_SYSTEMD ++#include ++#endif + + #include "uip.h" + #include "uip_arp.h" +@@ -146,7 +149,7 @@ signal_wait: + fini_logger(SHUTDOWN_LOGGER); + rc = init_logger(main_log.log_file); + if (rc != 0) +- printf("Could not initialize the logger in " ++ fprintf(stderr, "WARN: Could not initialize the logger in " + "signal!\n"); + goto signal_wait; + default: +@@ -239,6 +242,7 @@ int main(int argc, char *argv[]) + int foreground = 0; + pid_t pid; + pthread_attr_t attr; ++ int pipefds[2]; + + /* Record the start time for the user space daemon */ + opt.start_time = time(NULL); +@@ -281,7 +285,7 @@ int main(int argc, char *argv[]) + /* initialize the logger */ + rc = init_logger(main_log.log_file); + if (rc != 0 && opt.debug == DEBUG_ON) +- printf("WARN: Could not initialize the logger\n"); ++ fprintf(stderr, "WARN: Could not initialize the logger\n"); + } + + LOG_INFO("Started iSCSI uio stack: Ver " PACKAGE_VERSION); +@@ -316,38 +320,53 @@ int main(int argc, char *argv[]) + + fd = open(pid_file, O_WRONLY | O_CREAT, 0644); + if (fd < 0) { +- printf("Unable to create pid file: %s", pid_file); ++ fprintf(stderr, "ERR: Unable to create pid file: %s\n", ++ pid_file); ++ exit(1); ++ } ++ ++ if (pipe(pipefds) < 0) { ++ fprintf(stderr, "ERR: Unable to create a PIPE: %s\n", ++ strerror(errno)); + exit(1); + } + + pid = fork(); + if (pid < 0) { +- printf("Starting daemon failed"); ++ fprintf(stderr, "ERR: Starting daemon failed\n"); + exit(1); + } else if (pid) { ++ char msgbuf[4]; ++ ++ /* parent: wait for child msg then exit */ ++ close(pipefds[1]); ++ read(pipefds[0], msgbuf, sizeof(msgbuf)); + exit(0); + } + ++ /* the child */ + rc = chdir("/"); + if (rc == -1) +- printf("Unable to chdir(\") [%s]", strerror(errno)); ++ fprintf(stderr, "WARN: Unable to chdir(\") [%s]\n", strerror(errno)); + + if (lockf(fd, F_TLOCK, 0) < 0) { +- printf("Unable to lock pid file: %s [%s]", ++ fprintf(stderr, "ERR: Unable to lock pid file: %s [%s]\n", + pid_file, strerror(errno)); + exit(1); + } + + rc = ftruncate(fd, 0); + if (rc == -1) +- printf("ftruncate(%d, 0) failed [%s]", ++ fprintf(stderr, "WARN: ftruncate(%d, 0) failed [%s]\n", + fd, strerror(errno)); + + sprintf(buf, "%d\n", getpid()); + written_bytes = write(fd, buf, strlen(buf)); +- if (written_bytes == -1) +- printf("Could not write pid file [%s]", ++ if (written_bytes == -1) { ++ fprintf(stderr, "ERR: Could not write pid file [%s]\n", + strerror(errno)); ++ exit(1); ++ } + close(fd); + + daemon_init(); +@@ -393,6 +412,18 @@ int main(int argc, char *argv[]) + if (rc != 0) + goto error; + ++ if (!foreground) { ++ /* signal parent they can go away now */ ++ close(pipefds[0]); ++ write(pipefds[1], "ok\n", 3); ++ close(pipefds[1]); ++ } ++ ++#ifndef NO_SYSTEMD ++ sd_notify(0, "READY=1\n" ++ "STATUS=Ready to process requests\n"); ++#endif ++ + /* NetLink connection to listen to NETLINK_ISCSI private messages */ + if (nic_nl_open() != 0) + goto error; +diff --git a/usr/Makefile b/usr/Makefile +index 865d001..742a0fb 100644 +--- a/usr/Makefile ++++ b/usr/Makefile +@@ -28,10 +28,18 @@ IPC_OBJ=ioctl.o + endif + endif + ++PKG_CONFIG = /usr/bin/pkg-config ++ + CFLAGS ?= -O2 -g + WARNFLAGS ?= -Wall -Wstrict-prototypes + CFLAGS += $(WARNFLAGS) -I../include -I. -I../utils/open-isns \ + -D$(OSNAME) $(IPC_CFLAGS) -DISNS_ENABLE ++CFLAGS += $(shell $(PKG_CONFIG) --cflags libkmod) ++CFLAGS += $(shell $(PKG_CONFIG) --cflags libsystemd) ++LDFLAGS += $(shell $(PKG_CONFIG) --libs libkmod) ++ifeq ($(NO_SYSTEMD),) ++LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd) ++endif + PROGRAMS = iscsid iscsiadm iscsistart + + # libc compat files +@@ -55,14 +63,14 @@ all: $(PROGRAMS) + + iscsid: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(DISCOVERY_SRCS) \ + iscsid.o session_mgmt.o discoveryd.o mntcheck.o +- $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -L../utils/open-isns -lisns -lrt -lmount ++ $(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns -lrt -lmount $(LDFLAGS) + + iscsiadm: $(ISCSI_LIB_SRCS) $(DISCOVERY_SRCS) iscsiadm.o session_mgmt.o mntcheck.o +- $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -L../utils/open-isns -lisns -lmount ++ $(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns -lmount $(LDFLAGS) + + iscsistart: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \ + iscsistart.o statics.o +- $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -lrt ++ $(CC) $(CFLAGS) $^ -o $@ -lrt $(LDFLAGS) + clean: + rm -f *.o $(PROGRAMS) .depend $(LIBSYS) + +diff --git a/usr/event_poll.c b/usr/event_poll.c +index ac25044..4cf4ce2 100644 +--- a/usr/event_poll.c ++++ b/usr/event_poll.c +@@ -41,6 +41,10 @@ + + static unsigned int reap_count; + ++/* track pid of reload fork, while running */ ++static pid_t reload_pid = 0; ++static void (*reload_callback)(void); ++ + #define REAP_WAKEUP 1000 /* in millisecs */ + + void reap_inc(void) +@@ -48,9 +52,18 @@ void reap_inc(void) + reap_count++; + } + ++/* track the reload process to be reaped, when done */ ++void reap_track_reload_process(pid_t reload_proc_pid, void (*reload_done_callback)(void)) ++{ ++ reload_pid = reload_proc_pid; ++ reload_callback = reload_done_callback; ++ reap_inc(); ++} ++ + void reap_proc(void) + { +- int rc, i, max_reaps; ++ int i, max_reaps; ++ pid_t rc; + + /* + * We don't really need reap_count, but calling wait() all the +@@ -60,9 +73,13 @@ void reap_proc(void) + for (i = 0; i < max_reaps; i++) { + rc = waitpid(0, NULL, WNOHANG); + if (rc > 0) { ++ if (rc == reload_pid) { ++ log_debug(6, "reaped reload process"); ++ reload_callback(); ++ } + reap_count--; + log_debug(6, "reaped pid %d, reap_count now %d", +- rc, reap_count); ++ (int)rc, reap_count); + } + } + } +diff --git a/usr/event_poll.h b/usr/event_poll.h +index c0eed5c..f23132b 100644 +--- a/usr/event_poll.h ++++ b/usr/event_poll.h +@@ -25,6 +25,7 @@ struct queue_task; + int shutdown_callback(pid_t pid); + void reap_proc(void); + void reap_inc(void); ++void reap_track_reload_process(pid_t realod_proc_pid, void (*reload_done_callback)(void)); + void event_loop(struct iscsi_ipc *ipc, int control_fd, int mgmt_ipc_fd); + void event_loop_exit(struct queue_task *qtask); + +diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c +index 3395590..b9d5a84 100644 +--- a/usr/iscsi_sysfs.c ++++ b/usr/iscsi_sysfs.c +@@ -1512,6 +1512,50 @@ free_info: + return rc; + } + ++/* ++ * count the number of sessions -- a much-simplified ++ * version of iscsi_sysfs_for_each_session ++ * ++ * TODO: return an array of the session info we find, for use ++ * by iscsi_sysfs_for_each_session(), so it doesn't have to ++ * do it all over again ++ */ ++int iscsi_sysfs_count_sessions(void) ++{ ++ struct dirent **namelist = NULL; ++ int n, i; ++ struct session_info *info; ++ ++ ++ info = calloc(1, sizeof(*info)); ++ if (!info) ++ /* no sessions found */ ++ return 0; ++ ++ n = scandir(ISCSI_SESSION_DIR, &namelist, trans_filter, alphasort); ++ if (n <= 0) ++ /* no sessions found */ ++ goto free_info; ++ ++ /* ++ * try to get session info for each session found, but ignore ++ * errors if any since it may be a race condition ++ */ ++ for (i = 0; i < n; i++) ++ if (iscsi_sysfs_get_sessioninfo_by_id(info, ++ namelist[i]->d_name) != 0) ++ log_warning("could not find session info for %s", ++ namelist[i]->d_name); ++ ++ for (i = 0; i < n; i++) ++ free(namelist[i]); ++ free(namelist); ++ ++free_info: ++ free(info); ++ return n; ++} ++ + int iscsi_sysfs_get_session_state(char *state, int sid) + { + char id[NAME_SIZE]; +diff --git a/usr/iscsi_sysfs.h b/usr/iscsi_sysfs.h +index cdcefa6..1d0377f 100644 +--- a/usr/iscsi_sysfs.h ++++ b/usr/iscsi_sysfs.h +@@ -53,6 +53,7 @@ extern int iscsi_sysfs_for_each_iface_on_host(void *data, uint32_t host_no, + extern int iscsi_sysfs_for_each_session(void *data, int *nr_found, + iscsi_sysfs_session_op_fn *fn, + int in_parallel); ++extern int iscsi_sysfs_count_sessions(void); + extern int iscsi_sysfs_for_each_host(void *data, int *nr_found, + iscsi_sysfs_host_op_fn *fn); + extern uint32_t iscsi_sysfs_get_host_no_from_sid(uint32_t sid, int *err); +diff --git a/usr/iscsid.c b/usr/iscsid.c +index 01b90c9..b0629f4 100644 +--- a/usr/iscsid.c ++++ b/usr/iscsid.c +@@ -34,6 +34,9 @@ + #include + #include + #include ++#ifndef NO_SYSTEMD ++#include ++#endif + + #include "iscsid.h" + #include "mgmt_ipc.h" +@@ -62,6 +65,7 @@ static pid_t log_pid; + static gid_t gid; + static int daemonize = 1; + static int mgmt_ipc_fd; ++static int sessions_to_recover = 0; + + static struct option const long_options[] = { + {"config", required_argument, NULL, 'c'}, +@@ -334,6 +338,30 @@ static void missing_iname_warn(char *initiatorname_file) + "ignored.", initiatorname_file, initiatorname_file); + } + ++/* called right before we enter the event loop */ ++static void set_state_to_ready(void) ++{ ++#ifndef NO_SYSTEMD ++ if (sessions_to_recover) ++ sd_notify(0, "READY=1\n" ++ "RELOADING=1\n" ++ "STATUS=Syncing existing session(s)\n"); ++ else ++ sd_notify(0, "READY=1\n" ++ "STATUS=Ready to process requests\n"); ++#endif ++} ++ ++/* called when recovery process has been reaped */ ++static void set_state_done_reloading(void) ++{ ++#ifndef NO_SYSTEMD ++ sessions_to_recover = 0; ++ sd_notifyf(0, "READY=1\n" ++ "STATUS=Ready to process requests\n"); ++#endif ++} ++ + int main(int argc, char *argv[]) + { + struct utsname host_info; /* will use to compound initiator alias */ +@@ -526,18 +554,31 @@ int main(int argc, char *argv[]) + daemon_config.safe_logout = 1; + free(safe_logout); + +- pid = fork(); +- if (pid == 0) { +- int nr_found = 0; +- /* child */ +- /* TODO - test with async support enabled */ +- iscsi_sysfs_for_each_session(NULL, &nr_found, sync_session, 0); +- exit(0); +- } else if (pid < 0) { +- log_error("Fork failed error %d: existing sessions" +- " will not be synced", errno); +- } else +- reap_inc(); ++ /* see if we have any stale sessions to recover */ ++ sessions_to_recover = iscsi_sysfs_count_sessions(); ++ if (sessions_to_recover) { ++ ++ /* ++ * recover stale sessions in the background ++ */ ++ ++ pid = fork(); ++ if (pid == 0) { ++ int nr_found; /* not used */ ++ /* child */ ++ /* TODO - test with async support enabled */ ++ iscsi_sysfs_for_each_session(NULL, &nr_found, sync_session, 0); ++ exit(0); ++ } else if (pid < 0) { ++ log_error("Fork failed error %d: existing sessions" ++ " will not be synced", errno); ++ } else { ++ /* parent */ ++ log_debug(8, "forked child (pid=%d) to recover %d session(s)", ++ (int)pid, sessions_to_recover); ++ reap_track_reload_process(pid, set_state_done_reloading); ++ } ++ } + + iscsi_initiator_init(); + increase_max_files(); +@@ -554,6 +595,7 @@ int main(int argc, char *argv[]) + exit(ISCSI_ERR); + } + ++ set_state_to_ready(); + event_loop(ipc, control_fd, mgmt_ipc_fd); + + idbm_terminate(); +-- +2.21.0 + diff --git a/SOURCES/0001-fix-upstream-build-breakage-of-iscsiuio-LDFLAGS.patch b/SOURCES/0001-fix-upstream-build-breakage-of-iscsiuio-LDFLAGS.patch new file mode 100644 index 0000000..810502b --- /dev/null +++ b/SOURCES/0001-fix-upstream-build-breakage-of-iscsiuio-LDFLAGS.patch @@ -0,0 +1,29 @@ +From 674462fbdc837dd17cc9f2bb227fbaf44aca3a30 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Wed, 16 Oct 2019 23:17:20 -0700 +Subject: [PATCH 1/1] fix upstream build breakage of iscsiuio LDFLAGS + +--- + iscsiuio/configure.ac | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/iscsiuio/configure.ac b/iscsiuio/configure.ac +index b41df0e..a856cc5 100644 +--- a/iscsiuio/configure.ac ++++ b/iscsiuio/configure.ac +@@ -67,10 +67,10 @@ AM_CONDITIONAL([DEBUG], [test x$debug = xtrue]) + AC_ARG_WITH([systemd], + AS_HELP_STRING([--without-systemd], [Build without systemd]), + [case "${withval}" in +- yes) LDFLAGS="`pkg-config --libs libsystemd`" ;; ++ yes) LDFLAGS="${LDFLAGS} `pkg-config --libs libsystemd`" ;; + no) CFLAGS="${CFLAGS} -DNO_SYSTEMD" ;; + *) AC_MSG_ERROR([bad value $withval for --with-systemd]) ;; +- esac],[LDFLAGS="`pkg-config --libs libsystemd`"]) ++ esac],[LDFLAGS="${LDFLAGS} `pkg-config --libs libsystemd`"]) + + AC_CONFIG_COMMANDS([default],[[ + if [ -n "$SOURCE_DATE_EPOCH" ] ; then +-- +2.21.0 + diff --git a/SOURCES/0001-improve-systemd-service-files-for-boot-session-handl.patch b/SOURCES/0001-improve-systemd-service-files-for-boot-session-handl.patch new file mode 100644 index 0000000..83fc490 --- /dev/null +++ b/SOURCES/0001-improve-systemd-service-files-for-boot-session-handl.patch @@ -0,0 +1,81 @@ +From 80603fd5378a7ec4e274188bd5582fa94ec69b27 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Mon, 28 Oct 2019 10:20:56 -0700 +Subject: [PATCH 1/1] improve systemd service files for boot session handling + +--- + etc/systemd/iscsi-mark-root-nodes | 6 +++++- + etc/systemd/iscsi-onboot.service | 15 +++++++++++++++ + etc/systemd/iscsi.service | 8 ++------ + 3 files changed, 22 insertions(+), 7 deletions(-) + create mode 100644 etc/systemd/iscsi-onboot.service + +diff --git a/etc/systemd/iscsi-mark-root-nodes b/etc/systemd/iscsi-mark-root-nodes +index 6bddf6c..cc76100 100644 +--- a/etc/systemd/iscsi-mark-root-nodes ++++ b/etc/systemd/iscsi-mark-root-nodes +@@ -9,7 +9,11 @@ while read t num p target flash; do + portal=${p%,*} + transport=${t%:} + +- $ISCSIADM -m node -p $portal -T $target -o update -n node.startup -v onboot ++ # use session number to find the iface name in use ++ num=${num#[}; num=${num%]} ++ iface=$(iscsiadm -m session -r $num | grep iface.iscsi_ifacename | cut -d= -f2) ++ ++ $ISCSIADM -m node -p $portal -T $target -I $iface -o update -n node.startup -v onboot + + start_iscsid=1 + +diff --git a/etc/systemd/iscsi-onboot.service b/etc/systemd/iscsi-onboot.service +new file mode 100644 +index 0000000..42ced68 +--- /dev/null ++++ b/etc/systemd/iscsi-onboot.service +@@ -0,0 +1,15 @@ ++[Unit] ++Description=Special handling of early boot iSCSI sessions ++Documentation=man:iscsiadm(8) man:iscsid(8) ++DefaultDependencies=no ++RefuseManualStart=true ++Before=iscsi.service ++After=systemd-remount-fs.service ++ConditionDirectoryNotEmpty=/sys/class/iscsi_session ++ ++[Service] ++Type=oneshot ++ExecStart=-/usr/libexec/iscsi-mark-root-nodes ++ ++[Install] ++WantedBy=sysinit.target +diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service +index f09b3a0..1d52882 100644 +--- a/etc/systemd/iscsi.service ++++ b/etc/systemd/iscsi.service +@@ -2,21 +2,17 @@ + Description=Login and scanning of iSCSI devices + Documentation=man:iscsiadm(8) man:iscsid(8) + DefaultDependencies=no +-Conflicts=shutdown.target + Before=remote-fs-pre.target + After=network.target network-online.target iscsid.service iscsiuio.service systemd-remount-fs.service + Wants=remote-fs-pre.target iscsi-shutdown.service +-ConditionPathExists=/etc/iscsi/initiatorname.iscsi +-ConditionDirectoryNotEmpty=|/var/lib/iscsi/nodes +-ConditionDirectoryNotEmpty=|/sys/class/iscsi_session ++ConditionDirectoryNotEmpty=/var/lib/iscsi/nodes + + [Service] + Type=oneshot +-ExecStart=-/usr/libexec/iscsi-mark-root-nodes ++RemainAfterExit=true + ExecStart=-/sbin/iscsiadm -m node --loginall=automatic + ExecReload=-/sbin/iscsiadm -m node --loginall=automatic + SuccessExitStatus=21 +-RemainAfterExit=true + + [Install] + WantedBy=remote-fs.target +-- +2.21.0 + diff --git a/SOURCES/0001-iscsid-Update-boot-gateway-information-during-sync_s.patch b/SOURCES/0001-iscsid-Update-boot-gateway-information-during-sync_s.patch new file mode 100644 index 0000000..10e22ca --- /dev/null +++ b/SOURCES/0001-iscsid-Update-boot-gateway-information-during-sync_s.patch @@ -0,0 +1,33 @@ +From d295d0745829f9eee1f4f0e1e3328f9bb4f2dc16 Mon Sep 17 00:00:00 2001 +From: Manish Rangankar +Date: Wed, 20 Jun 2018 16:19:24 +0530 +Subject: [PATCH 1/1] iscsid: Update boot gateway information during + sync_session. + +During boot for SAN scenario after switch root iscsid not +passing gateway information to iscsiuio. + +Signed-off-by: Manish Rangankar +--- + usr/iscsi_sysfs.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c +index fdc26c7..8e89b30 100644 +--- a/usr/iscsi_sysfs.c ++++ b/usr/iscsi_sysfs.c +@@ -706,6 +706,11 @@ static int iscsi_sysfs_read_boot(struct iface_rec *iface, char *session) + log_debug(5, "could not read %s/%s/subnet", boot_root, + boot_nic); + ++ if (sysfs_get_str(boot_nic, boot_root, "gateway", ++ iface->gateway, NI_MAXHOST)) ++ log_debug(5, "could not read %s/%s/gateway", boot_root, ++ boot_nic); ++ + log_debug(5, "sysfs read boot returns %s/%s/ vlan = %d subnet = %s", + boot_root, boot_nic, iface->vlan_id, iface->subnet_mask); + return 0; +-- +2.21.0 + diff --git a/SOURCES/0001-iscsiuio-allow-processing-of-iscsid-requests-in-DHCP.patch b/SOURCES/0001-iscsiuio-allow-processing-of-iscsid-requests-in-DHCP.patch new file mode 100644 index 0000000..ca6319c --- /dev/null +++ b/SOURCES/0001-iscsiuio-allow-processing-of-iscsid-requests-in-DHCP.patch @@ -0,0 +1,47 @@ +From 6997f36c44cd7046d1be1248fd864d9a068faff5 Mon Sep 17 00:00:00 2001 +From: Nilesh Javali +Date: Tue, 25 Jun 2019 01:05:01 -0400 +Subject: [PATCH 1/1] iscsiuio: allow processing of iscsid requests in DHCP + failure condition + +In the event of DHCP failure, killing of enable_nic_thread did not +process any iscsid requests leading to error, +iscsistart: Could not broadcast to uIP after 5 tries +and login failure to next active path. +Do not kill enable_nic_thread and allow further processing of iscsid +requests and performing login to next active path. + +Signed-off-by: Nilesh Javali +--- + iscsiuio/src/unix/nic.c | 15 --------------- + 1 file changed, 15 deletions(-) + +diff --git a/iscsiuio/src/unix/nic.c b/iscsiuio/src/unix/nic.c +index bd415c2..f449935 100644 +--- a/iscsiuio/src/unix/nic.c ++++ b/iscsiuio/src/unix/nic.c +@@ -1318,21 +1318,6 @@ static int do_acquisition(nic_t *nic, nic_interface_t *nic_iface, + /* For DHCPv4 failure, the ustack must be cleaned so + it can re-acquire on the next iscsid request */ + uip_reset(&nic_iface->ustack); +- +- /* Signal that the device enable is +- done */ +- pthread_cond_broadcast(&nic->enable_done_cond); +- pthread_mutex_unlock(&nic->nic_mutex); +- +- if (nic->enable_thread == INVALID_THREAD) +- goto dhcp_err; +- +- rc = pthread_cancel(nic->enable_thread); +- if (rc != 0) +- LOG_ERR(PFX "%s: Couldn't cancel " +- "enable nic thread", nic->log_name); +-dhcp_err: +- pthread_mutex_lock(&nic->nic_mutex); + goto error; + } + +-- +2.21.0 + diff --git a/SOURCES/0001-iscsiuio-update-version-to-0.7.8.6.patch b/SOURCES/0001-iscsiuio-update-version-to-0.7.8.6.patch new file mode 100644 index 0000000..c57f09f --- /dev/null +++ b/SOURCES/0001-iscsiuio-update-version-to-0.7.8.6.patch @@ -0,0 +1,80 @@ +From fb7e87dbe5bad120c88f7e430dfdc627d247fa4c Mon Sep 17 00:00:00 2001 +From: Nilesh Javali +Date: Thu, 27 Jun 2019 05:39:43 -0400 +Subject: [PATCH 1/1] iscsiuio: update version to 0.7.8.6 + +Signed-off-by: Nilesh Javali +--- + iscsiuio/README | 4 ++-- + iscsiuio/RELEASE.TXT | 19 +++++++++++++++++-- + iscsiuio/configure.ac | 4 ++-- + 3 files changed, 21 insertions(+), 6 deletions(-) + +diff --git a/iscsiuio/README b/iscsiuio/README +index 1915005..53b700c 100644 +--- a/iscsiuio/README ++++ b/iscsiuio/README +@@ -1,6 +1,6 @@ + Iscsiuio Userspace Tool +-Version 0.7.8.5 +-Nov 20, 2018 ++Version 0.7.8.6 ++Jun 27, 2019 + ------------------------------------------------------ + + This tool is to be used in conjunction with the QLogic NetXtreme II Linux +diff --git a/iscsiuio/RELEASE.TXT b/iscsiuio/RELEASE.TXT +index 0ebf27f..28e681b 100644 +--- a/iscsiuio/RELEASE.TXT ++++ b/iscsiuio/RELEASE.TXT +@@ -1,7 +1,7 @@ + Release Notes + QLogic uIP Linux Driver +- Version 0.7.8.5 +- 11/20/2018 ++ Version 0.7.8.6 ++ 06/27/2019 + + QLogic Corporation + 26650 Aliso Viejo Pkwy, +@@ -11,6 +11,21 @@ + Copyright (c) 2014, QLogic Corporation + All rights reserved + ++uIP v0.7.8.6 (Jun 27, 2019) ++======================================================= ++ Fixes: ++ ------- ++ 1. Problem: OS fails to boot after one path is ++ disconnected from iSCSI MPIO config. ++ Change: In the event of DHCP failure, killing of enable_nic_thread did ++ not process any iscsid requests leading to error, ++ iscsistart: Could not broadcast to uIP after 5 tries ++ and login failure of active path. ++ Added fix to not kill enable_nic_thread and allow further ++ processing of iscsid requests and performing login ++ to next active path. ++ Impact: All ++ + uIP v0.7.8.5 (Nov 20, 2018) + ======================================================= + Fixes: +diff --git a/iscsiuio/configure.ac b/iscsiuio/configure.ac +index ae23078..7d53323 100644 +--- a/iscsiuio/configure.ac ++++ b/iscsiuio/configure.ac +@@ -12,9 +12,9 @@ dnl Benjamin Li (benli@broadcom.com) + dnl + + PACKAGE=iscsiuio +-VERSION=0.7.8.5 ++VERSION=0.7.8.6 + +-AC_INIT([iscsiuio], [0.7.8.5], [QLogic-Storage-Upstream@cavium.com]) ++AC_INIT([iscsiuio], [0.7.8.6], [QLogic-Storage-Upstream@cavium.com]) + + AM_INIT_AUTOMAKE + AC_CONFIG_HEADER(config.h) +-- +2.21.0 + diff --git a/SOURCES/0001-rec-update-disable-the-idbm_lock-in-read-write-when-.patch b/SOURCES/0001-rec-update-disable-the-idbm_lock-in-read-write-when-.patch new file mode 100644 index 0000000..5fa66f5 --- /dev/null +++ b/SOURCES/0001-rec-update-disable-the-idbm_lock-in-read-write-when-.patch @@ -0,0 +1,517 @@ +From c64a92e32187d24dda44d983809f36e20d9cb92f Mon Sep 17 00:00:00 2001 +From: Xiubo Li +Date: Tue, 18 Jun 2019 10:12:31 +0800 +Subject: [PATCH 1/1] rec update: disable the idbm_lock in read/write when + updating the rec + +The iscsiadm is getting a file lock while writing out records, and +updates are a read-modify-write operation and currently only the +write is locked. + +So the parallel requests are reading in the pre-update record and +then overwriting each other with the writes. + +Fixing RHBZ#1624670 + +Signed-off-by: Xiubo Li +--- + usr/idbm.c | 132 +++++++++++++++++++++++++++++++------------------ + usr/idbm.h | 17 ++++--- + usr/iface.c | 2 +- + usr/iscsiadm.c | 18 +++---- + usr/iscsid.c | 2 +- + 5 files changed, 105 insertions(+), 66 deletions(-) + +diff --git a/usr/idbm.c b/usr/idbm.c +index c238cc7..ca2557f 100644 +--- a/usr/idbm.c ++++ b/usr/idbm.c +@@ -1401,7 +1401,12 @@ static FILE *idbm_open_rec_r(char *portal, char *config) + return fopen(portal, "r"); + } + +-static int __idbm_rec_read(node_rec_t *out_rec, char *conf) ++/* ++ * When the disable_lock param is true, the idbm_lock/idbm_unlock needs ++ * to be holt by the caller, this will avoid overwriting each other in ++ * case of updating(read-modify-write) the recs in parallel. ++ */ ++static int __idbm_rec_read(node_rec_t *out_rec, char *conf, bool disable_lock) + { + recinfo_t *info; + FILE *f; +@@ -1411,9 +1416,11 @@ static int __idbm_rec_read(node_rec_t *out_rec, char *conf) + if (!info) + return ISCSI_ERR_NOMEM; + +- rc = idbm_lock(); +- if (rc) +- goto free_info; ++ if (!disable_lock) { ++ rc = idbm_lock(); ++ if (rc) ++ goto free_info; ++ } + + f = fopen(conf, "r"); + if (!f) { +@@ -1430,15 +1437,21 @@ static int __idbm_rec_read(node_rec_t *out_rec, char *conf) + fclose(f); + + unlock: +- idbm_unlock(); ++ if (!disable_lock) ++ idbm_unlock(); + free_info: + free(info); + return rc; + } + ++/* ++ * When the disable_lock param is true, the idbm_lock/idbm_unlock needs ++ * to be holt by the caller, this will avoid overwriting each other in ++ * case of updating(read-modify-write) the recs in parallel. ++ */ + int + idbm_rec_read(node_rec_t *out_rec, char *targetname, int tpgt, +- char *ip, int port, struct iface_rec *iface) ++ char *ip, int port, struct iface_rec *iface, bool disable_lock) + { + struct stat statb; + char *portal; +@@ -1470,7 +1483,7 @@ idbm_rec_read(node_rec_t *out_rec, char *targetname, int tpgt, + } + + read: +- rc = __idbm_rec_read(out_rec, portal); ++ rc = __idbm_rec_read(out_rec, portal, disable_lock); + free_portal: + free(portal); + return rc; +@@ -1526,7 +1539,7 @@ static int idbm_print_discovered(discovery_rec_t *drec, int info_level) + int num_found = 0; + + if (info_level < 1) +- idbm_for_each_rec(&num_found, drec, print_discovered_flat); ++ idbm_for_each_rec(&num_found, drec, print_discovered_flat, false); + else { + struct discovered_tree_info tree_info; + struct node_rec last_rec; +@@ -1536,7 +1549,7 @@ static int idbm_print_discovered(discovery_rec_t *drec, int info_level) + tree_info.drec = drec; + tree_info.last_rec = &last_rec; + +- idbm_for_each_rec(&num_found, &tree_info, print_discovered_tree); ++ idbm_for_each_rec(&num_found, &tree_info, print_discovered_tree, false); + } + return num_found; + } +@@ -1708,9 +1721,9 @@ int idbm_print_all_discovery(int info_level) + * fn should return -1 if it skipped the rec, an ISCSI_ERR error code if + * the operation failed or 0 if fn was run successfully. + */ +-static int idbm_for_each_iface(int *found, void *data, +- idbm_iface_op_fn *fn, +- char *targetname, int tpgt, char *ip, int port) ++static int idbm_for_each_iface(int *found, void *data, idbm_iface_op_fn *fn, ++ char *targetname, int tpgt, char *ip, int port, ++ bool ruw_lock) + { + DIR *iface_dirfd; + struct dirent *iface_dent; +@@ -1735,7 +1748,7 @@ static int idbm_for_each_iface(int *found, void *data, + goto free_portal; + } + +- rc = __idbm_rec_read(&rec, portal); ++ rc = __idbm_rec_read(&rec, portal, ruw_lock); + if (rc) + goto free_portal; + +@@ -1768,7 +1781,7 @@ read_iface: + memset(portal, 0, PATH_MAX); + snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%d/%s", NODE_CONFIG_DIR, + targetname, ip, port, tpgt, iface_dent->d_name); +- if (__idbm_rec_read(&rec, portal)) ++ if (__idbm_rec_read(&rec, portal, ruw_lock)) + continue; + + curr_rc = fn(data, &rec); +@@ -1790,7 +1803,7 @@ free_portal: + * The portal could be a file or dir with interfaces + */ + int idbm_for_each_portal(int *found, void *data, idbm_portal_op_fn *fn, +- char *targetname) ++ char *targetname, bool ruw_lock) + { + DIR *portal_dirfd; + struct dirent *portal_dent; +@@ -1827,7 +1840,8 @@ int idbm_for_each_portal(int *found, void *data, idbm_portal_op_fn *fn, + + curr_rc = fn(found, data, targetname, + tmp_tpgt ? atoi(tmp_tpgt) : -1, +- portal_dent->d_name, atoi(tmp_port)); ++ portal_dent->d_name, atoi(tmp_port), ++ ruw_lock); + /* less than zero means it was not a match */ + if (curr_rc > 0 && !rc) + rc = curr_rc; +@@ -1838,7 +1852,7 @@ done: + return rc; + } + +-int idbm_for_each_node(int *found, void *data, idbm_node_op_fn *fn) ++int idbm_for_each_node(int *found, void *data, idbm_node_op_fn *fn, bool ruw_lock) + { + DIR *node_dirfd; + struct dirent *node_dent; +@@ -1859,7 +1873,7 @@ int idbm_for_each_node(int *found, void *data, idbm_node_op_fn *fn) + continue; + + log_debug(5, "searching %s", node_dent->d_name); +- curr_rc = fn(found, data, node_dent->d_name); ++ curr_rc = fn(found, data, node_dent->d_name, ruw_lock); + /* less than zero means it was not a match */ + if (curr_rc > 0 && !rc) + rc = curr_rc; +@@ -1877,18 +1891,30 @@ static int iface_fn(void *data, node_rec_t *rec) + } + + static int portal_fn(int *found, void *data, char *targetname, +- int tpgt, char *ip, int port) ++ int tpgt, char *ip, int port, bool ruw_lock) + { +- return idbm_for_each_iface(found, data, iface_fn, targetname, +- tpgt, ip, port); ++ int rc; ++ ++ if (ruw_lock) { ++ rc = idbm_lock(); ++ if (rc) ++ return rc; ++ } ++ ++ rc = idbm_for_each_iface(found, data, iface_fn, targetname, ++ tpgt, ip, port, ruw_lock); ++ if (ruw_lock) ++ idbm_unlock(); ++ ++ return rc; + } + +-static int node_fn(int *found, void *data, char *targetname) ++static int node_fn(int *found, void *data, char *targetname, bool ruw_lock) + { +- return idbm_for_each_portal(found, data, portal_fn, targetname); ++ return idbm_for_each_portal(found, data, portal_fn, targetname, ruw_lock); + } + +-int idbm_for_each_rec(int *found, void *data, idbm_iface_op_fn *fn) ++int idbm_for_each_rec(int *found, void *data, idbm_iface_op_fn *fn, bool ruw_lock) + { + struct rec_op_data op_data; + +@@ -1896,7 +1922,7 @@ int idbm_for_each_rec(int *found, void *data, idbm_iface_op_fn *fn) + op_data.data = data; + op_data.fn = fn; + +- return idbm_for_each_node(found, &op_data, node_fn); ++ return idbm_for_each_node(found, &op_data, node_fn, ruw_lock); + } + + static struct { +@@ -2141,7 +2167,12 @@ free_portal: + return rc; + } + +-static int idbm_rec_write(node_rec_t *rec) ++/* ++ * When the disable_lock param is true, the idbm_lock/idbm_unlock needs ++ * to be holt by the caller, this will avoid overwriting each other in ++ * case of updating(read-modify-write) the recs in parallel. ++ */ ++static int idbm_rec_write(node_rec_t *rec, bool disable_lock) + { + char *portal; + int rc = 0; +@@ -2172,9 +2203,11 @@ static int idbm_rec_write(node_rec_t *rec) + } + } + +- rc = idbm_lock(); +- if (rc) +- goto free_portal; ++ if (!disable_lock) { ++ rc = idbm_lock(); ++ if (rc) ++ goto free_portal; ++ } + + if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN) + /* old style portal as config */ +@@ -2182,7 +2215,8 @@ static int idbm_rec_write(node_rec_t *rec) + else + rc = idbm_rec_write_new(rec); + +- idbm_unlock(); ++ if (!disable_lock) ++ idbm_unlock(); + free_portal: + free(portal); + return rc; +@@ -2357,18 +2391,24 @@ static int setup_disc_to_node_link(char *disc_portal, node_rec_t *rec) + int idbm_add_node(node_rec_t *newrec, discovery_rec_t *drec, int overwrite) + { + node_rec_t rec; +- char *node_portal, *disc_portal; ++ char *node_portal = NULL, *disc_portal; + int rc; + ++ rc = idbm_lock(); ++ if (rc) ++ return rc; ++ + if (!idbm_rec_read(&rec, newrec->name, newrec->tpgt, + newrec->conn[0].address, newrec->conn[0].port, +- &newrec->iface)) { +- if (!overwrite) +- return 0; ++ &newrec->iface, true)) { ++ if (!overwrite) { ++ rc = 0; ++ goto unlock; ++ } + + rc = idbm_delete_node(&rec); + if (rc) +- return rc; ++ goto unlock; + log_debug(7, "overwriting existing record"); + } else + log_debug(7, "adding new DB record"); +@@ -2379,17 +2419,19 @@ int idbm_add_node(node_rec_t *newrec, discovery_rec_t *drec, int overwrite) + strcpy(newrec->disc_address, drec->address); + } + +- rc = idbm_rec_write(newrec); ++ rc = idbm_rec_write(newrec, true); + /* + * if a old app passed in a bogus tpgt then we do not create links + * since it will set a different tpgt in another iscsiadm call + */ + if (rc || !drec || newrec->tpgt == PORTAL_GROUP_TAG_UNKNOWN) +- return rc; ++ goto unlock; + + node_portal = calloc(2, PATH_MAX); +- if (!node_portal) +- return ISCSI_ERR_NOMEM; ++ if (!node_portal) { ++ rc = ISCSI_ERR_NOMEM; ++ goto unlock; ++ } + + disc_portal = node_portal + PATH_MAX; + snprintf(node_portal, PATH_MAX, "%s/%s/%s,%d,%d", NODE_CONFIG_DIR, +@@ -2397,15 +2439,11 @@ int idbm_add_node(node_rec_t *newrec, discovery_rec_t *drec, int overwrite) + newrec->tpgt); + rc = setup_disc_to_node_link(disc_portal, newrec); + if (rc) +- goto free_portal; ++ goto unlock; + + log_debug(7, "node addition making link from %s to %s", node_portal, + disc_portal); + +- rc = idbm_lock(); +- if (rc) +- goto free_portal; +- + if (symlink(node_portal, disc_portal)) { + if (errno == EEXIST) + log_debug(7, "link from %s to %s exists", node_portal, +@@ -2417,8 +2455,8 @@ int idbm_add_node(node_rec_t *newrec, discovery_rec_t *drec, int overwrite) + strerror(errno)); + } + } ++unlock: + idbm_unlock(); +-free_portal: + free(node_portal); + return rc; + } +@@ -2657,7 +2695,7 @@ static int idbm_remove_disc_to_node_link(node_rec_t *rec, + rec->name, rec->conn[0].address, rec->conn[0].port, rec->tpgt, + rec->iface.name); + +- rc = __idbm_rec_read(tmprec, portal); ++ rc = __idbm_rec_read(tmprec, portal, false); + if (rc) { + /* old style recs will not have tpgt or a link so skip */ + rc = 0; +@@ -2884,7 +2922,7 @@ int idbm_node_set_param(void *data, node_rec_t *rec) + if (rc) + return rc; + +- return idbm_rec_write(rec); ++ return idbm_rec_write(rec, true); + } + + int idbm_discovery_set_param(void *data, discovery_rec_t *rec) +diff --git a/usr/idbm.h b/usr/idbm.h +index 411dd82..8571a8c 100644 +--- a/usr/idbm.h ++++ b/usr/idbm.h +@@ -23,6 +23,7 @@ + #define IDBM_H + + #include ++#include + #include + #include "initiator.h" + #include "config.h" +@@ -91,22 +92,22 @@ struct user_param { + }; + + typedef int (idbm_iface_op_fn)(void *data, node_rec_t *rec); +-typedef int (idbm_portal_op_fn)(int *found, void *data, +- char *targetname, int tpgt, char *ip, int port); ++typedef int (idbm_portal_op_fn)(int *found, void *data, char *targetname, ++ int tpgt, char *ip, int port, bool ruw_lock); + typedef int (idbm_node_op_fn)(int *found, void *data, +- char *targetname); ++ char *targetname, bool ruw_lock); + + struct rec_op_data { + void *data; + node_rec_t *match_rec; + idbm_iface_op_fn *fn; + }; +-extern int idbm_for_each_portal(int *found, void *data, +- idbm_portal_op_fn *fn, char *targetname); ++extern int idbm_for_each_portal(int *found, void *data, idbm_portal_op_fn *fn, ++ char *targetname, bool ruw_lock); + extern int idbm_for_each_node(int *found, void *data, +- idbm_node_op_fn *fn); ++ idbm_node_op_fn *fn, bool ruw_lock); + extern int idbm_for_each_rec(int *found, void *data, +- idbm_iface_op_fn *fn); ++ idbm_iface_op_fn *fn, bool ruw_lock); + + + typedef int (idbm_drec_op_fn)(void *data, discovery_rec_t *drec); +@@ -145,7 +146,7 @@ extern int idbm_discovery_read(discovery_rec_t *rec, int type, char *addr, + int port); + extern int idbm_rec_read(node_rec_t *out_rec, char *target_name, + int tpgt, char *addr, int port, +- struct iface_rec *iface); ++ struct iface_rec *iface, bool disable_lock); + extern int idbm_node_set_rec_from_param(struct list_head *params, + node_rec_t *rec, int verify); + extern int idbm_node_set_param(void *data, node_rec_t *rec); +diff --git a/usr/iface.c b/usr/iface.c +index 74e63f6..b2e6db6 100644 +--- a/usr/iface.c ++++ b/usr/iface.c +@@ -855,7 +855,7 @@ int iface_print_tree(void *data, struct iface_rec *iface) + print_data.match_iface = iface; + print_data.last_rec = &last_rec; + +- idbm_for_each_rec(&num_found, &print_data, iface_print_nodes); ++ idbm_for_each_rec(&num_found, &print_data, iface_print_nodes, false); + return 0; + } + +diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c +index 6245e89..c2b047e 100644 +--- a/usr/iscsiadm.c ++++ b/usr/iscsiadm.c +@@ -398,7 +398,7 @@ __logout_by_startup(void *data, struct list_head *list, + memset(&rec, 0, sizeof(node_rec_t)); + if (idbm_rec_read(&rec, info->targetname, info->tpgt, + info->persistent_address, +- info->persistent_port, &info->iface)) { ++ info->persistent_port, &info->iface, false)) { + /* + * this is due to a HW driver or some other driver + * not hooked in +@@ -515,7 +515,7 @@ login_by_startup(char *mode) + startup.mode = mode; + INIT_LIST_HEAD(&startup.all_logins); + INIT_LIST_HEAD(&startup.leading_logins); +- err = idbm_for_each_rec(&nr_found, &startup, link_startup_recs); ++ err = idbm_for_each_rec(&nr_found, &startup, link_startup_recs, false); + if (err && (!list_empty(&startup.all_logins) || + !list_empty(&startup.leading_logins))) + /* log msg and try to log into what we found */ +@@ -662,7 +662,7 @@ static int __for_each_matched_rec(int verbose, struct node_rec *rec, + op_data.match_rec = rec; + op_data.fn = fn; + +- rc = idbm_for_each_rec(&nr_found, &op_data, rec_match_fn); ++ rc = idbm_for_each_rec(&nr_found, &op_data, rec_match_fn, true); + if (rc) { + if (verbose) + log_error("Could not execute operation on all " +@@ -915,8 +915,8 @@ done: + return rc; + } + +-static int add_static_portal(int *found, void *data, +- char *targetname, int tpgt, char *ip, int port) ++static int add_static_portal(int *found, void *data, char *targetname, ++ int tpgt, char *ip, int port, bool ruw_lock) + { + node_rec_t *rec = data; + +@@ -932,7 +932,7 @@ static int add_static_portal(int *found, void *data, + } + + static int add_static_node(int *found, void *data, +- char *targetname) ++ char *targetname, bool ruw_lock) + { + node_rec_t *rec = data; + +@@ -950,14 +950,14 @@ static int add_static_node(int *found, void *data, + rec->conn[0].port, &rec->iface); + search: + return idbm_for_each_portal(found, data, add_static_portal, +- targetname); ++ targetname, false); + } + + static int add_static_recs(struct node_rec *rec) + { + int rc, nr_found = 0; + +- rc = idbm_for_each_node(&nr_found, rec, add_static_node); ++ rc = idbm_for_each_node(&nr_found, rec, add_static_node, false); + if (rc) + goto done; + /* success */ +@@ -1048,7 +1048,7 @@ exec_disc_op_on_recs(discovery_rec_t *drec, struct list_head *rec_list, + + /* clean up node db */ + if (op & OP_DELETE) +- idbm_for_each_rec(&found, rec_list, delete_stale_rec); ++ idbm_for_each_rec(&found, rec_list, delete_stale_rec, false); + + if (op & OP_NEW || op & OP_UPDATE) { + /* now add/update records */ +diff --git a/usr/iscsid.c b/usr/iscsid.c +index f0017e5..01b90c9 100644 +--- a/usr/iscsid.c ++++ b/usr/iscsid.c +@@ -233,7 +233,7 @@ static int sync_session(void *data, struct session_info *info) + + if (idbm_rec_read(&rec, info->targetname, info->tpgt, + info->persistent_address, info->persistent_port, +- &info->iface)) { ++ &info->iface, false)) { + log_warning("Could not read data from db. Using default and " + "currently negotiated values"); + setup_rec_from_negotiated_values(&rec, info); +-- +2.21.0 + diff --git a/SOURCES/0001-restore-some-service-file-differences.patch b/SOURCES/0001-restore-some-service-file-differences.patch new file mode 100644 index 0000000..01d6843 --- /dev/null +++ b/SOURCES/0001-restore-some-service-file-differences.patch @@ -0,0 +1,67 @@ +From 0c8744b08e717e011eb51fe663a4db33c9c0f9b0 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Wed, 16 Oct 2019 16:27:38 -0700 +Subject: [PATCH 1/1] Restore some service file differences + +--- + etc/systemd/iscsi.service | 13 +++++++++---- + etc/systemd/iscsid.service | 1 + + etc/systemd/iscsiuio.service | 1 - + 3 files changed, 10 insertions(+), 5 deletions(-) + +diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service +index 0edcf51..f09b3a0 100644 +--- a/etc/systemd/iscsi.service ++++ b/etc/systemd/iscsi.service +@@ -1,15 +1,20 @@ + [Unit] + Description=Login and scanning of iSCSI devices + Documentation=man:iscsiadm(8) man:iscsid(8) +-Before=remote-fs.target +-After=network.target network-online.target iscsid.service ++DefaultDependencies=no ++Conflicts=shutdown.target ++Before=remote-fs-pre.target ++After=network.target network-online.target iscsid.service iscsiuio.service systemd-remount-fs.service ++Wants=remote-fs-pre.target iscsi-shutdown.service + ConditionPathExists=/etc/iscsi/initiatorname.iscsi ++ConditionDirectoryNotEmpty=|/var/lib/iscsi/nodes ++ConditionDirectoryNotEmpty=|/sys/class/iscsi_session + + [Service] + Type=oneshot ++ExecStart=-/usr/libexec/iscsi-mark-root-nodes + ExecStart=-/sbin/iscsiadm -m node --loginall=automatic +-ExecStop=/sbin/iscsiadm -m node --logoutall=automatic +-ExecStop=/sbin/iscsiadm -m node --logoutall=manual ++ExecReload=-/sbin/iscsiadm -m node --loginall=automatic + SuccessExitStatus=21 + RemainAfterExit=true + +diff --git a/etc/systemd/iscsid.service b/etc/systemd/iscsid.service +index f5e8979..4fef168 100644 +--- a/etc/systemd/iscsid.service ++++ b/etc/systemd/iscsid.service +@@ -10,6 +10,7 @@ Type=notify + NotifyAccess=main + ExecStart=/sbin/iscsid -f + KillMode=mixed ++Restart=on-failure + + [Install] + WantedBy=multi-user.target +diff --git a/etc/systemd/iscsiuio.service b/etc/systemd/iscsiuio.service +index e4d9fd0..48501b6 100644 +--- a/etc/systemd/iscsiuio.service ++++ b/etc/systemd/iscsiuio.service +@@ -2,7 +2,6 @@ + Description=iSCSI UserSpace I/O driver + Documentation=man:iscsiuio(8) + DefaultDependencies=no +-Conflicts=shutdown.target + Requires=iscsid.service + BindTo=iscsid.service + After=network.target +-- +2.21.0 + diff --git a/SOURCES/0154-add-libiscsi.patch b/SOURCES/0154-add-libiscsi.patch index c8737ec..1f66b96 100644 --- a/SOURCES/0154-add-libiscsi.patch +++ b/SOURCES/0154-add-libiscsi.patch @@ -1,49 +1,4 @@ -From 2b8ba79bfa079177962465c215d5ea2fccfda400 Mon Sep 17 00:00:00 2001 -From: Chris Leech -Date: Mon, 19 Nov 2012 16:43:15 -0800 -Subject: add libiscsi - ---- - Makefile | 2 + - libiscsi/Makefile | 61 ++ - libiscsi/libiscsi.c | 620 +++++++++++ - libiscsi/libiscsi.doxy | 1473 +++++++++++++++++++++++++++ - libiscsi/libiscsi.h | 344 +++++++ - libiscsi/pylibiscsi.c | 638 ++++++++++++ - libiscsi/setup.py | 9 + - libiscsi/tests/test_discovery_firmware.c | 53 + - libiscsi/tests/test_discovery_sendtargets.c | 60 ++ - libiscsi/tests/test_get_auth.c | 70 ++ - libiscsi/tests/test_get_initiator_name.c | 38 + - libiscsi/tests/test_get_network_config.c | 45 + - libiscsi/tests/test_login.c | 52 + - libiscsi/tests/test_logout.c | 51 + - libiscsi/tests/test_params.c | 103 ++ - libiscsi/tests/test_set_auth.c | 58 ++ - usr/Makefile | 2 +- - usr/discovery.c | 5 + - usr/idbm.c | 6 +- - usr/idbm.h | 3 + - usr/iscsi_ipc.h | 2 + - 21 files changed, 3691 insertions(+), 4 deletions(-) - create mode 100644 libiscsi/Makefile - create mode 100644 libiscsi/libiscsi.c - create mode 100644 libiscsi/libiscsi.doxy - create mode 100644 libiscsi/libiscsi.h - create mode 100644 libiscsi/pylibiscsi.c - create mode 100644 libiscsi/setup.py - create mode 100644 libiscsi/tests/test_discovery_firmware.c - create mode 100644 libiscsi/tests/test_discovery_sendtargets.c - create mode 100644 libiscsi/tests/test_get_auth.c - create mode 100644 libiscsi/tests/test_get_initiator_name.c - create mode 100644 libiscsi/tests/test_get_network_config.c - create mode 100644 libiscsi/tests/test_login.c - create mode 100644 libiscsi/tests/test_logout.c - create mode 100644 libiscsi/tests/test_params.c - create mode 100644 libiscsi/tests/test_set_auth.c - -diff --git a/Makefile b/Makefile -index c8cd00e09b00..cf028cfd078a 100644 +unchanged: --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ user: iscsiuio/Makefile @@ -62,9 +17,7 @@ index c8cd00e09b00..cf028cfd078a 100644 $(MAKE) -C utils/sysdeps clean $(MAKE) -C utils/fwparam_ibft clean $(MAKE) -C utils clean -diff --git a/libiscsi/Makefile b/libiscsi/Makefile -new file mode 100644 -index 000000000000..317a7ec4db30 +unchanged: --- /dev/null +++ b/libiscsi/Makefile @@ -0,0 +1,61 @@ @@ -129,9 +82,7 @@ index 000000000000..317a7ec4db30 + gcc $(CFLAGS) -M `ls *.c` > .depend + +-include .depend ../usr/.depend -diff --git a/libiscsi/libiscsi.c b/libiscsi/libiscsi.c -new file mode 100644 -index 000000000000..6e6846a5162e +unchanged: --- /dev/null +++ b/libiscsi/libiscsi.c @@ -0,0 +1,620 @@ @@ -755,9 +706,7 @@ index 000000000000..6e6846a5162e + + return 0; +} -diff --git a/libiscsi/libiscsi.doxy b/libiscsi/libiscsi.doxy -new file mode 100644 -index 000000000000..663770f3e939 +unchanged: --- /dev/null +++ b/libiscsi/libiscsi.doxy @@ -0,0 +1,1473 @@ @@ -2234,9 +2183,7 @@ index 000000000000..663770f3e939 +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO -diff --git a/libiscsi/libiscsi.h b/libiscsi/libiscsi.h -new file mode 100644 -index 000000000000..756590e14d8b +unchanged: --- /dev/null +++ b/libiscsi/libiscsi.h @@ -0,0 +1,344 @@ @@ -2584,9 +2531,7 @@ index 000000000000..756590e14d8b +#endif /* __cplusplus */ + +#endif -diff --git a/libiscsi/pylibiscsi.c b/libiscsi/pylibiscsi.c -new file mode 100644 -index 000000000000..4b09aa7b956a +unchanged: --- /dev/null +++ b/libiscsi/pylibiscsi.c @@ -0,0 +1,638 @@ @@ -3228,9 +3173,7 @@ index 000000000000..4b09aa7b956a + Py_INCREF(&PyIscsiNode_Type); + PyModule_AddObject(m, "node", (PyObject *) &PyIscsiNode_Type); +} -diff --git a/libiscsi/setup.py b/libiscsi/setup.py -new file mode 100644 -index 000000000000..bb4329bc2158 +unchanged: --- /dev/null +++ b/libiscsi/setup.py @@ -0,0 +1,9 @@ @@ -3243,9 +3186,7 @@ index 000000000000..bb4329bc2158 + +setup (name = 'PyIscsi',version = '1.0', + description = 'libiscsi python bindings', ext_modules = [module1]) -diff --git a/libiscsi/tests/test_discovery_firmware.c b/libiscsi/tests/test_discovery_firmware.c -new file mode 100644 -index 000000000000..76e852a37019 +unchanged: --- /dev/null +++ b/libiscsi/tests/test_discovery_firmware.c @@ -0,0 +1,53 @@ @@ -3302,9 +3243,7 @@ index 000000000000..76e852a37019 + + return rc; +} -diff --git a/libiscsi/tests/test_discovery_sendtargets.c b/libiscsi/tests/test_discovery_sendtargets.c -new file mode 100644 -index 000000000000..1a3c12ef684b +unchanged: --- /dev/null +++ b/libiscsi/tests/test_discovery_sendtargets.c @@ -0,0 +1,60 @@ @@ -3368,9 +3307,7 @@ index 000000000000..1a3c12ef684b + + return rc; +} -diff --git a/libiscsi/tests/test_get_auth.c b/libiscsi/tests/test_get_auth.c -new file mode 100644 -index 000000000000..5e234dadd0de +unchanged: --- /dev/null +++ b/libiscsi/tests/test_get_auth.c @@ -0,0 +1,70 @@ @@ -3444,9 +3381,7 @@ index 000000000000..5e234dadd0de + + return rc; +} -diff --git a/libiscsi/tests/test_get_initiator_name.c b/libiscsi/tests/test_get_initiator_name.c -new file mode 100644 -index 000000000000..997c053e5bf6 +unchanged: --- /dev/null +++ b/libiscsi/tests/test_get_initiator_name.c @@ -0,0 +1,38 @@ @@ -3488,9 +3423,7 @@ index 000000000000..997c053e5bf6 + + return 0; +} -diff --git a/libiscsi/tests/test_get_network_config.c b/libiscsi/tests/test_get_network_config.c -new file mode 100644 -index 000000000000..2dedd6102858 +unchanged: --- /dev/null +++ b/libiscsi/tests/test_get_network_config.c @@ -0,0 +1,45 @@ @@ -3539,9 +3472,7 @@ index 000000000000..2dedd6102858 + + return 0; +} -diff --git a/libiscsi/tests/test_login.c b/libiscsi/tests/test_login.c -new file mode 100644 -index 000000000000..3eb70d63e111 +unchanged: --- /dev/null +++ b/libiscsi/tests/test_login.c @@ -0,0 +1,52 @@ @@ -3597,9 +3528,7 @@ index 000000000000..3eb70d63e111 + + return rc; +} -diff --git a/libiscsi/tests/test_logout.c b/libiscsi/tests/test_logout.c -new file mode 100644 -index 000000000000..b734dca58773 +unchanged: --- /dev/null +++ b/libiscsi/tests/test_logout.c @@ -0,0 +1,51 @@ @@ -3654,9 +3583,7 @@ index 000000000000..b734dca58773 + + return rc; +} -diff --git a/libiscsi/tests/test_params.c b/libiscsi/tests/test_params.c -new file mode 100644 -index 000000000000..d3223be1e894 +unchanged: --- /dev/null +++ b/libiscsi/tests/test_params.c @@ -0,0 +1,103 @@ @@ -3763,9 +3690,7 @@ index 000000000000..d3223be1e894 + + return rc; +} -diff --git a/libiscsi/tests/test_set_auth.c b/libiscsi/tests/test_set_auth.c -new file mode 100644 -index 000000000000..a21f88806ab9 +unchanged: --- /dev/null +++ b/libiscsi/tests/test_set_auth.c @@ -0,0 +1,58 @@ @@ -3827,8 +3752,7 @@ index 000000000000..a21f88806ab9 + + return rc; +} -diff --git a/usr/Makefile b/usr/Makefile -index c1866b6a4ed8..6d3ce2e8b6ce 100644 +unchanged: --- a/usr/Makefile +++ b/usr/Makefile @@ -30,7 +30,7 @@ endif @@ -3840,8 +3764,7 @@ index c1866b6a4ed8..6d3ce2e8b6ce 100644 PROGRAMS = iscsid iscsiadm iscsistart # libc compat files -diff --git a/usr/discovery.c b/usr/discovery.c -index 593d22650f0d..de8267f08f8a 100644 +unchanged: --- a/usr/discovery.c +++ b/usr/discovery.c @@ -36,6 +36,7 @@ @@ -3881,39 +3804,32 @@ index 593d22650f0d..de8267f08f8a 100644 int discovery_fw(void *data, struct iface_rec *iface, struct list_head *rec_list) -diff --git a/usr/idbm.c b/usr/idbm.c -index a749cc8ea3f8..979fefb7a5d7 100644 +unchanged: --- a/usr/idbm.c +++ b/usr/idbm.c -@@ -1709,9 +1709,9 @@ int idbm_print_all_discovery(int info_level) +@@ -1725,7 +1725,7 @@ int idbm_print_all_discovery(int info_level) * fn should return -1 if it skipped the rec, an ISCSI_ERR error code if * the operation failed or 0 if fn was run successfully. */ --static int idbm_for_each_iface(int *found, void *data, -- idbm_iface_op_fn *fn, -- char *targetname, int tpgt, char *ip, int port) -+int idbm_for_each_iface(int *found, void *data, -+ idbm_iface_op_fn *fn, -+ char *targetname, int tpgt, char *ip, int port) +-static int idbm_for_each_iface(int *found, void *data, idbm_iface_op_fn *fn, ++int idbm_for_each_iface(int *found, void *data, idbm_iface_op_fn *fn, + char *targetname, int tpgt, char *ip, int port, + bool ruw_lock) { - DIR *iface_dirfd; - struct dirent *iface_dent; -diff --git a/usr/idbm.h b/usr/idbm.h -index b89ddffe55df..36312621f06c 100644 +unchanged: --- a/usr/idbm.h +++ b/usr/idbm.h -@@ -102,6 +102,9 @@ struct rec_op_data { +@@ -103,6 +103,9 @@ struct rec_op_data { node_rec_t *match_rec; idbm_iface_op_fn *fn; }; +extern int idbm_for_each_iface(int *found, void *data, + idbm_iface_op_fn *fn, -+ char *targetname, int tpgt, char *ip, int port); - extern int idbm_for_each_portal(int *found, void *data, - idbm_portal_op_fn *fn, char *targetname); ++ char *targetname, int tpgt, char *ip, int port, bool ruw_lock); + extern int idbm_for_each_portal(int *found, void *data, idbm_portal_op_fn *fn, + char *targetname, bool ruw_lock); extern int idbm_for_each_node(int *found, void *data, -diff --git a/usr/iscsi_ipc.h b/usr/iscsi_ipc.h -index 5087b5c6343d..a6dc40a55d78 100644 +unchanged: --- a/usr/iscsi_ipc.h +++ b/usr/iscsi_ipc.h @@ -166,4 +166,6 @@ struct iscsi_ipc { @@ -3923,6 +3839,34 @@ index 5087b5c6343d..a6dc40a55d78 100644 +struct iscsi_ipc *ipc; + #endif /* ISCSI_IPC_H */ --- -2.9.3 - +only in patch2: +unchanged: +--- a/libiscsi/libiscsi.c ++++ b/libiscsi/libiscsi.c +@@ -425,7 +425,7 @@ int libiscsi_node_login(struct libiscsi_context *context, + + CHECK(idbm_for_each_iface(&nr_found, (void*)node->iface, login_helper, + (char *)node->name, node->tpgt, +- (char *)node->address, node->port)) ++ (char *)node->address, node->port, false)) + if (nr_found == 0) { + strcpy(context->error_str, "No such node"); + rc = ENODEV; +@@ -487,7 +487,7 @@ int libiscsi_node_set_parameter(struct libiscsi_context *context, + + CHECK(idbm_for_each_iface(&nr_found, ¶ms, idbm_node_set_param, + (char *)node->name, node->tpgt, +- (char *)node->address, node->port)) ++ (char *)node->address, node->port, false)) + if (nr_found == 0) { + strcpy(context->error_str, "No such node"); + rc = ENODEV; +@@ -549,7 +549,7 @@ int libiscsi_node_get_parameter(struct libiscsi_context *context, + as most settings should be the same independent of the iface. */ + CHECK(idbm_for_each_iface(&nr_found, context, get_parameter_helper, + (char *)node->name, node->tpgt, +- (char *)node->address, node->port)) ++ (char *)node->address, node->port, false)) + if (nr_found == 0) { + strcpy(context->error_str, "No such node"); + rc = ENODEV; diff --git a/SOURCES/0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch b/SOURCES/0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch index a5ffb65..a930370 100644 --- a/SOURCES/0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch +++ b/SOURCES/0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch @@ -16,7 +16,7 @@ index 20f07946be1f..baa8c00c7185 100644 * some other maintainer could merge a patch without going through us */ -#define ISCSI_VERSION_STR "2.0-874" -+#define ISCSI_VERSION_STR "6.2.0.874-10" ++#define ISCSI_VERSION_STR "6.2.0.874-17" #define ISCSI_VERSION_FILE "/sys/module/scsi_transport_iscsi/version" #endif diff --git a/SPECS/iscsi-initiator-utils.spec b/SPECS/iscsi-initiator-utils.spec index a14f622..cb3c105 100644 --- a/SPECS/iscsi-initiator-utils.spec +++ b/SPECS/iscsi-initiator-utils.spec @@ -4,7 +4,7 @@ Summary: iSCSI daemon and utility programs Name: iscsi-initiator-utils Version: 6.%{open_iscsi_version}.%{open_iscsi_build} -Release: 11%{?dist} +Release: 17%{?dist} Group: System Environment/Daemons License: GPLv2+ URL: http://www.open-iscsi.org @@ -31,26 +31,6 @@ Patch145: 0145-idbm_rec_write-seperate-old-and-new-style-writes.patch Patch146: 0146-idbw_rec_write-pick-tpgt-from-existing-record.patch Patch149: 0149-update-systemd-service-files-add-iscsi.service-for-s.patch Patch150: 0150-iscsi-boot-related-service-file-updates.patch -# distro specific modifications -Patch151: 0151-update-initscripts-and-docs.patch -Patch152: 0152-use-var-for-config.patch -Patch153: 0153-use-red-hat-for-name.patch -Patch154: 0154-add-libiscsi.patch -Patch156: 0156-remove-the-offload-boot-supported-ifdef.patch -Patch159: 0159-iscsiuio-systemd-unit-files.patch -Patch160: 0160-use-systemctl-to-start-iscsid.patch -Patch161: 0161-resolve-565245-multilib-issues-caused-by-doxygen.patch -Patch162: 0162-Don-t-check-for-autostart-sessions-if-iscsi-is-not-u.patch -Patch164: 0164-libiscsi-fix-incorrect-strncpy-use.patch -Patch166: 0166-start-socket-listeners-on-iscsiadm-command.patch -Patch167: 0167-Revert-iscsiadm-return-error-when-login-fails.patch -Patch168: 0168-update-handling-of-boot-sessions.patch -Patch169: 0169-update-iscsi.service-for-boot-session-recovery.patch -Patch170: 0170-fix-systemd-unit-wants.patch -Patch172: 0172-move-cleanup-to-seperate-service.patch -Patch175: open-iscsi-2.0.876-41-vlan-setting-sync-across-ipv4-ipv6-for-be2iscsi.patch -Patch176: 0001-enable-MaxOutstandingR2T-negotiation.patch - Patch177: open-iscsi-2.0.874-30-iscsiuio-fix-dhcpv6-transaction-id-mismatch-error.patch Patch178: open-iscsi-2.0.874-31-iscsiuio-serialize-xmit_mutex-lock-to-prevent-iscsiuio-seg-fault.patch Patch179: open-iscsi-2.0.874-32-iscsiuio-allow-ARP-for-non-matching-src-and-dst-addresses.patch @@ -78,21 +58,51 @@ Patch209: open-iscsi-2.0.875-21-tell-git-to-ignore-the-iscsiuio-binary.patch Patch210: open-iscsi-2.0.875-30-Cleanup-iscsiuio-master-Makefile-template.patch Patch211: open-iscsi-2.0.876-5-bnx2x.c-Reorder-the-includes-to-avoid-duplicate-defines-with-musl.patch Patch212: open-iscsi-2.0.876-6-Use-correct-size-when-copying-nic-name.patch -Patch213: open-iscsi-2.0.876-56-iscsiuio-Release-xmit_mutex-in-error-code-path.patch -Patch214: open-iscsi-2.0.876-57-iscsiuio-limit-retries-of-performing-dhcpv6-before-declaring-dhcp-failure.patch -Patch215: open-iscsi-2.0.876-58-iscsiuio-Do-not-flush-tx-queue-on-each-uio-interrupt.patch -Patch216: open-iscsi-2.0.876-59-qedi-Set-buf_size-in-case-of-ICMP-and-ARP-packet.patch -Patch217: open-iscsi-2.0.876-60-qedi-Use-uio-BD-index-instead-on-buffer-index.patch -Patch218: open-iscsi-2.0.876-61-iscsiuio-v0.7.8.5.patch -Patch219: open-iscsi-2.0.876-66-Close-file-handles-when-writing-pid-files.patch -Patch220: open-iscsi-2.0.876-66-iscsiuio-avoid-loosing-bad-rc-in-nic_nl_open.patch -Patch221: open-iscsi-2.0.876-67-iscsiuio-fail-on-nic_nl_open-failing.patch +Patch213: 0001-Keep-iscsi_if-in-sync-with-kernel-version.patch +Patch214: 0001-Add-error-message-for-new-ISCSI_ERR_NOP_TIMEDOUT.patch +Patch215: open-iscsi-2.0.876-56-iscsiuio-Release-xmit_mutex-in-error-code-path.patch +Patch216: open-iscsi-2.0.876-57-iscsiuio-limit-retries-of-performing-dhcpv6-before-declaring-dhcp-failure.patch +Patch217: open-iscsi-2.0.876-58-iscsiuio-Do-not-flush-tx-queue-on-each-uio-interrupt.patch +Patch218: open-iscsi-2.0.876-59-qedi-Set-buf_size-in-case-of-ICMP-and-ARP-packet.patch +Patch219: open-iscsi-2.0.876-60-qedi-Use-uio-BD-index-instead-on-buffer-index.patch +Patch220: open-iscsi-2.0.876-61-iscsiuio-v0.7.8.5.patch +Patch221: open-iscsi-2.0.876-66-Close-file-handles-when-writing-pid-files.patch +Patch222: open-iscsi-2.0.876-66-iscsiuio-avoid-loosing-bad-rc-in-nic_nl_open.patch +Patch223: open-iscsi-2.0.876-67-iscsiuio-fail-on-nic_nl_open-failing.patch +Patch224: 0001-rec-update-disable-the-idbm_lock-in-read-write-when-.patch +Patch225: 0001-iscsiuio-allow-processing-of-iscsid-requests-in-DHCP.patch +Patch226: 0001-iscsiuio-update-version-to-0.7.8.6.patch +Patch227: 0001-iscsid-Update-boot-gateway-information-during-sync_s.patch + +# distro specific modifications +Patch351: 0151-update-initscripts-and-docs.patch +Patch352: 0152-use-var-for-config.patch +Patch353: 0153-use-red-hat-for-name.patch +Patch354: 0154-add-libiscsi.patch +Patch356: 0156-remove-the-offload-boot-supported-ifdef.patch +Patch359: 0159-iscsiuio-systemd-unit-files.patch +Patch360: 0160-use-systemctl-to-start-iscsid.patch +Patch361: 0161-resolve-565245-multilib-issues-caused-by-doxygen.patch +Patch362: 0162-Don-t-check-for-autostart-sessions-if-iscsi-is-not-u.patch +Patch364: 0164-libiscsi-fix-incorrect-strncpy-use.patch +Patch366: 0166-start-socket-listeners-on-iscsiadm-command.patch +Patch367: 0167-Revert-iscsiadm-return-error-when-login-fails.patch +Patch368: 0168-update-handling-of-boot-sessions.patch +Patch369: 0169-update-iscsi.service-for-boot-session-recovery.patch +Patch370: 0170-fix-systemd-unit-wants.patch +Patch372: 0172-move-cleanup-to-seperate-service.patch +Patch375: open-iscsi-2.0.876-41-vlan-setting-sync-across-ipv4-ipv6-for-be2iscsi.patch +Patch376: 0001-enable-MaxOutstandingR2T-negotiation.patch # upstream removed internal open-isns, but not taking that here just yet # it requires repackaging isns-utils to provide a debug package -Patch300: keep-open-isns.patch +Patch380: keep-open-isns.patch # version string, needs to be updated with each build Patch400: 0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch +Patch401: 0001-Update-service-files-and-add-sd_notify-support-to-is.patch +Patch402: 0001-restore-some-service-file-differences.patch +Patch403: 0001-fix-upstream-build-breakage-of-iscsiuio-LDFLAGS.patch +Patch404: 0001-improve-systemd-service-files-for-boot-session-handl.patch BuildRequires: flex bison python-devel doxygen kmod-devel systemd-devel libmount-devel autoconf automake libtool # For dir ownership @@ -182,6 +192,7 @@ touch $RPM_BUILD_ROOT/var/lock/iscsi/lock %{__install} -d $RPM_BUILD_ROOT%{_unitdir} %{__install} -pm 644 etc/systemd/iscsi.service $RPM_BUILD_ROOT%{_unitdir} +%{__install} -pm 644 etc/systemd/iscsi-onboot.service $RPM_BUILD_ROOT%{_unitdir} %{__install} -pm 644 etc/systemd/iscsi-shutdown.service $RPM_BUILD_ROOT%{_unitdir} %{__install} -pm 644 etc/systemd/iscsid.service $RPM_BUILD_ROOT%{_unitdir} %{__install} -pm 644 etc/systemd/iscsid.socket $RPM_BUILD_ROOT%{_unitdir} @@ -211,7 +222,7 @@ touch $RPM_BUILD_ROOT/var/lock/iscsi/lock %post /sbin/ldconfig -%systemd_post iscsi.service iscsi-shutdown.service iscsid.service iscsid.socket +%systemd_post iscsi.service iscsi-onboot.service iscsi-shutdown.service iscsid.service iscsid.socket if [ $1 -eq 1 ]; then if [ ! -f %{_sysconfdir}/iscsi/initiatorname.iscsi ]; then @@ -219,6 +230,7 @@ if [ $1 -eq 1 ]; then fi # enable socket activation and persistant session startup by default /bin/systemctl enable iscsi.service >/dev/null 2>&1 || : + /bin/systemctl enable iscsi-onboot.service >/dev/null 2>&1 || : /bin/systemctl enable iscsid.socket >/dev/null 2>&1 || : /bin/systemctl start iscsid.socket >/dev/null 2>&1 || : fi @@ -232,7 +244,7 @@ if [ $1 -eq 1 ]; then fi %preun -%systemd_preun iscsi.service iscsi-shutdown.service iscsid.service iscsiuio.service iscsid.socket iscsiuio.socket +%systemd_preun iscsi.service iscsi-onboot.service iscsi-shutdown.service iscsid.service iscsiuio.service iscsid.socket iscsiuio.socket %preun iscsiuio %systemd_preun iscsiuio.service iscsiuio.socket @@ -281,6 +293,7 @@ fi %ghost %{_var}/lock/iscsi %ghost %{_var}/lock/iscsi/lock %{_unitdir}/iscsi.service +%{_unitdir}/iscsi-onboot.service %{_unitdir}/iscsi-shutdown.service %{_unitdir}/iscsid.service %{_unitdir}/iscsid.socket @@ -313,7 +326,28 @@ fi %{_includedir}/libiscsi.h %changelog -* Wed Mar 06 2019 Chris Leech - 6.2.0.874-12 +* Mon Oct 28 2019 Chris Leech - 6.2.0.874-17 +- 1518367 boot from iSCSI not establishing all sessions persistently +- 1667965 A manual restart of iscsi.service modifies records node.startup value + +* Thu Oct 17 2019 Chris Leech - 6.2.0.874-16 +- upstream iscsiuio/configure.ac changes were breaking build hardening + +* Wed Oct 16 2019 Chris Leech - 6.2.0.874-15 +- 1396651 Update service files, support sd_notify instead of pid files, stop forking + +* Wed Sep 11 2019 Chris Leech - 6.2.0.874-14 +- 1598647 update boot gateway information during sync_session + +* Fri Aug 23 2019 Chris Leech - 6.2.0.874-13 +- 1724579 iscsiuio update, allow processing requests in DHCP failure condition + +* Tue Aug 20 2019 Chris Leech - 6.2.0.874-12 +- 1389071 handle newer ISCSI_ERR_NOP_TIMEDOUT code from the kernel +- 1624670 Login negotiation failed due to CHAP_N values do not match + (rec update race condition) + +* Wed Mar 06 2019 Chris Leech - 6.2.0.874-11 - 1649401, 1649413 iscsiuio updates * Wed Aug 29 2018 Chris Leech - 6.2.0.874-10