diff -Nru open-iscsi-2.0.874/debian/changelog open-iscsi-2.0.874/debian/changelog --- open-iscsi-2.0.874/debian/changelog 2019-10-09 20:10:37.000000000 +0000 +++ open-iscsi-2.0.874/debian/changelog 2020-05-11 01:42:57.000000000 +0000 @@ -1,3 +1,12 @@ +open-iscsi (2.0.874-7.1ubuntu3.1) eoan; urgency=medium + + [ Ben Swartzlander ] + * allow open-iscsi to disable auto-scan feature (LP: #1877617) + - d/p/lp1877617-Allow-disabling-auto-LUN-scans.patch + - d/p/lp1877617-Fix-manual-LUN-scans-feature.patch + + -- Rafael David Tinoco Mon, 11 May 2020 01:42:57 +0000 + open-iscsi (2.0.874-7.1ubuntu3) eoan; urgency=medium * Stop producing udebs on i386 where we no longer have d-i or a kernel. diff -Nru open-iscsi-2.0.874/debian/patches/lp1877617-Allow-disabling-auto-LUN-scans.patch open-iscsi-2.0.874/debian/patches/lp1877617-Allow-disabling-auto-LUN-scans.patch --- open-iscsi-2.0.874/debian/patches/lp1877617-Allow-disabling-auto-LUN-scans.patch 1970-01-01 00:00:00.000000000 +0000 +++ open-iscsi-2.0.874/debian/patches/lp1877617-Allow-disabling-auto-LUN-scans.patch 2020-05-11 01:42:57.000000000 +0000 @@ -0,0 +1,227 @@ +Description: Allow disabling auto LUN scans + +Existing behavior of auto scanning LUNs is problematic for some +deployments, particularly in cases where we are: + +- Accessing different LUNs from the same target on different machines + and we don't want the other LUNs automatically exposed in other + systems. + +- LUNs are constantly being created and removed from the target by + another machine and we don't want our systems polluted by no longer + available logical units, since default udev rules don't remove them + automatically from the system once they have been added automatically. + +This is a little more problematic when working with multipaths as we end +up with a lot of leftover device maps. + +This patch introduces a new configuration option at the session level +called "scan", with "auto" and "manual" as acceptable values, that +allows us to disable the autoscan in the following cases: + +- On iscsid start +- On login +- On AEN/AER messages reporting LUNs data has changed. + +For HW drivers all sessions will use the value defined in the +configuration file. + +Default value for this new option is "auto" to maintain existing +behavior. + +Author: Gorka Eguileor +Origin: upstream, https://github.com/open-iscsi/open-iscsi/commit/5e32aea957 +Bug-Ubuntu: https://launchpad.net/bugs/1877617 +Reviewed-By: Rafael David Tinoco +Last-Update: 2020-05-11 + +--- a/etc/iscsid.conf ++++ b/etc/iscsid.conf +@@ -306,3 +306,11 @@ + # a task management function like an ABORT TASK or LOGICAL UNIT RESET, that + # it continue to respond to R2Ts. To enable this uncomment this line + # node.session.iscsi.FastAbort = No ++ ++# To prevent doing automatic scans that would add unwanted luns to the system ++# we can disable them and have sessions only do manually requested scans. ++# Automatic scans are performed on startup, on login, and on AEN/AER reception ++# on devices supporting it. For HW drivers all sessions will use the value ++# defined in the configuration file. This configuration option is independent ++# of scsi_mod scan parameter. (The default behavior is auto): ++node.session.scan = auto +--- a/usr/config.h ++++ b/usr/config.h +@@ -190,6 +190,7 @@ + int queue_depth; + int initial_login_retry_max; + int nr_sessions; ++ int scan; + struct iscsi_auth_config auth; + struct iscsi_session_timeout_config timeo; + struct iscsi_error_timeout_config err_timeo; +--- a/usr/idbm.c ++++ b/usr/idbm.c +@@ -462,6 +462,9 @@ + session.iscsi.MaxOutstandingR2T, IDBM_SHOW, num, 1); + __recinfo_int(SESSION_ERL, ri, r, + session.iscsi.ERL, IDBM_SHOW, num, 1); ++ __recinfo_int_o2(SESSION_SCAN, ri, r, ++ session.scan, IDBM_SHOW, "manual", "auto", ++ num, 1); + + for (i = 0; i < ISCSI_CONN_MAX; i++) { + char key[NAME_MAXVAL]; +@@ -2490,7 +2493,7 @@ + log_debug(5, "disc removal removing link %s %s %s %s", + target, address, port, iface_id); + +- memset(rec, 0, sizeof(*rec)); ++ memset(rec, 0, sizeof(*rec)); + strlcpy(rec->name, target, TARGET_NAME_MAXLEN); + rec->tpgt = atoi(tpgt); + rec->conn[0].port = atoi(port); +@@ -2726,6 +2729,14 @@ + sizeof(struct iscsi_slp_config)); + } + ++int ++idbm_session_autoscan(struct iscsi_session *session) ++{ ++ if (session) ++ return session->nrec.session.scan; ++ return db->nrec.session.scan; ++} ++ + struct user_param *idbm_alloc_user_param(char *name, char *value) + { + struct user_param *param; +@@ -2981,6 +2992,7 @@ + rec->session.info = NULL; + rec->session.sid = 0; + rec->session.multiple = 0; ++ rec->session.scan = DEF_INITIAL_SCAN; + idbm_setup_session_defaults(&rec->session.iscsi); + + for (i=0; ihostno, NULL); + break; + case ISCSI_ASYNC_MSG_REQUEST_LOGOUT: +--- a/usr/iscsi_settings.h ++++ b/usr/iscsi_settings.h +@@ -45,3 +45,6 @@ + + /* login retries */ + #define DEF_INITIAL_LOGIN_RETRIES_MAX 4 ++ ++/* autoscan enabled */ ++#define DEF_INITIAL_SCAN 1 +--- a/usr/iscsi_sysfs.c ++++ b/usr/iscsi_sysfs.c +@@ -1882,12 +1882,15 @@ + strlen(write_buf)); + } + +-pid_t iscsi_sysfs_scan_host(int hostno, int async) ++pid_t iscsi_sysfs_scan_host(int hostno, int async, int full_scan) + { + char id[NAME_SIZE]; +- char *write_buf = "- - -"; ++ char write_buf[6] = "- - 0"; + pid_t pid = 0; + ++ if (full_scan) ++ write_buf[4] = '-'; ++ + if (async) + pid = fork(); + if (pid == 0) { +--- a/usr/iscsi_sysfs.h ++++ b/usr/iscsi_sysfs.h +@@ -87,7 +87,7 @@ + struct iscsi_session_operational_config *conf); + extern void iscsi_sysfs_get_negotiated_conn_conf(int sid, + struct iscsi_conn_operational_config *conf); +-extern pid_t iscsi_sysfs_scan_host(int hostno, int async); ++extern pid_t iscsi_sysfs_scan_host(int hostno, int async, int full); + extern int iscsi_sysfs_get_session_state(char *state, int sid); + extern int iscsi_sysfs_get_host_state(char *state, int host_no); + extern int iscsi_sysfs_get_device_state(char *state, int host_no, int target, +--- a/usr/iscsiadm.c ++++ b/usr/iscsiadm.c +@@ -773,7 +773,7 @@ + iscsi_sysfs_for_each_device(NULL, host_no, info->sid, + iscsi_sysfs_rescan_device); + /* now scan for new devices */ +- iscsi_sysfs_scan_host(host_no, 0); ++ iscsi_sysfs_scan_host(host_no, 0, 1); + return 0; + } + +--- a/usr/iscsid.c ++++ b/usr/iscsid.c +@@ -216,7 +216,7 @@ + iscsi_err_to_str(err)); + return 0; + } +- iscsi_sysfs_scan_host(host_no, 0); ++ iscsi_sysfs_scan_host(host_no, 0, idbm_session_autoscan(NULL)); + return 0; + } + +--- a/usr/iscsistart.c ++++ b/usr/iscsistart.c +@@ -140,6 +140,7 @@ + rec->session.initial_login_retry_max = -1; + rec->conn[0].timeo.noop_out_interval = -1; + rec->conn[0].timeo.noop_out_timeout = -1; ++ rec->session.scan = -1; + + list_for_each_entry(param, &user_params, list) { + /* +@@ -183,6 +184,8 @@ + rec->conn[0].timeo.noop_out_interval = 0; + if (rec->conn[0].timeo.noop_out_timeout == -1) + rec->conn[0].timeo.noop_out_timeout = 0; ++ if (rec->session.scan == -1) ++ rec->session.scan = DEF_INITIAL_SCAN; + + return 0; + } diff -Nru open-iscsi-2.0.874/debian/patches/lp1877617-Fix-manual-LUN-scans-feature.patch open-iscsi-2.0.874/debian/patches/lp1877617-Fix-manual-LUN-scans-feature.patch --- open-iscsi-2.0.874/debian/patches/lp1877617-Fix-manual-LUN-scans-feature.patch 1970-01-01 00:00:00.000000000 +0000 +++ open-iscsi-2.0.874/debian/patches/lp1877617-Fix-manual-LUN-scans-feature.patch 2020-05-11 01:42:57.000000000 +0000 @@ -0,0 +1,54 @@ +Description: Fix manual LUN scans feature + +The newly introduced feature to disable automatic scans should not be +scanning *any* of the LUNs when the scan is set to manual, but it always +scans for LUN0. + +This patch fixes this by skipping the sysfs call altogether, as it +should have been doing from the start. + +Author: Gorka Eguileor +Origin: upstream, https://github.com/open-iscsi/open-iscsi/commit/d5483b0df9 +Bug-Ubuntu: https://launchpad.net/bugs/1877617 +Reviewed-By: Rafael David Tinoco +Last-Update: 2020-05-11 + +--- open-iscsi-2.0.874.orig/usr/iscsi_sysfs.c ++++ open-iscsi-2.0.874/usr/iscsi_sysfs.c +@@ -1882,18 +1882,19 @@ void iscsi_sysfs_rescan_device(void *dat + strlen(write_buf)); + } + +-pid_t iscsi_sysfs_scan_host(int hostno, int async, int full_scan) ++pid_t iscsi_sysfs_scan_host(int hostno, int async, int autoscan) + { + char id[NAME_SIZE]; +- char write_buf[6] = "- - 0"; ++ char *write_buf = "- - -"; + pid_t pid = 0; + +- if (full_scan) +- write_buf[4] = '-'; +- + if (async) + pid = fork(); +- if (pid == 0) { ++ ++ if (pid >= 0 && !autoscan) { ++ if (pid) ++ log_debug(4, "host%d in manual scan mode, skipping scan", hostno); ++ } else if (pid == 0) { + /* child */ + log_debug(4, "scanning host%d", hostno); + +--- open-iscsi-2.0.874.orig/usr/iscsi_sysfs.h ++++ open-iscsi-2.0.874/usr/iscsi_sysfs.h +@@ -87,7 +87,7 @@ extern void iscsi_sysfs_get_negotiated_s + struct iscsi_session_operational_config *conf); + extern void iscsi_sysfs_get_negotiated_conn_conf(int sid, + struct iscsi_conn_operational_config *conf); +-extern pid_t iscsi_sysfs_scan_host(int hostno, int async, int full); ++extern pid_t iscsi_sysfs_scan_host(int hostno, int async, int autoscan); + extern int iscsi_sysfs_get_session_state(char *state, int sid); + extern int iscsi_sysfs_get_host_state(char *state, int host_no); + extern int iscsi_sysfs_get_device_state(char *state, int host_no, int target, diff -Nru open-iscsi-2.0.874/debian/patches/series open-iscsi-2.0.874/debian/patches/series --- open-iscsi-2.0.874/debian/patches/series 2019-04-29 23:13:37.000000000 +0000 +++ open-iscsi-2.0.874/debian/patches/series 2020-05-11 01:42:57.000000000 +0000 @@ -14,3 +14,5 @@ security/Check-iscsiuio-ping-data-length-for-validity.patch iscid-conf-use-systemd.socket-patch include-sys-sysmacros.h-to-properly-define-minor.patch +lp1877617-Allow-disabling-auto-LUN-scans.patch +lp1877617-Fix-manual-LUN-scans-feature.patch