Merge ~rafaeldtinoco/ubuntu/+source/open-iscsi:lp1877617-focal into ubuntu/+source/open-iscsi:ubuntu/focal-devel

Proposed by Rafael David Tinoco
Status: Merged
Approved by: Rafael David Tinoco
Approved revision: c91a0d2d0f33017f83fd6819000a9c7e23cec8f3
Merged at revision: c91a0d2d0f33017f83fd6819000a9c7e23cec8f3
Proposed branch: ~rafaeldtinoco/ubuntu/+source/open-iscsi:lp1877617-focal
Merge into: ubuntu/+source/open-iscsi:ubuntu/focal-devel
Diff against target: 320 lines (+292/-0)
4 files modified
debian/changelog (+9/-0)
debian/patches/lp1877617-Allow-disabling-auto-LUN-scans.patch (+227/-0)
debian/patches/lp1877617-Fix-manual-LUN-scans-feature.patch (+54/-0)
debian/patches/series (+2/-0)
Reviewer Review Type Date Requested Status
Rafael David Tinoco (community) Approve
Christian Ehrhardt  (community) Approve
Canonical Server Pending
Review via email: mp+383684@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
review: Approve
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

(c)rafaeldtinoco@focalvmdev:~$ sudo iscsiadm -m node -p 127.0.0.1 -T $TARGET_IQN -o new
New iSCSI node [tcp:[hw=,ip=,net_if=,iscsi_if=default] 127.0.0.1,3260,-1 iqn.2005-03.org.open-iscsi:964aab345716] added
(c)rafaeldtinoco@focalvmdev:~$ sudo iscsiadm -m node -p 127.0.0.1 -T $TARGET_IQN --login
Logging in to [iface: default, target: iqn.2005-03.org.open-iscsi:964aab345716, portal: 127.0.0.1,3260] (multiple)
Login to [iface: default, target: iqn.2005-03.org.open-iscsi:964aab345716, portal: 127.0.0.1,3260] successful.
(c)rafaeldtinoco@focalvmdev:~$ eval "DISKS=\$(sudo iscsiadm -m session -P3 | awk '/Attached scsi disk/ {print \$4}')"
(c)rafaeldtinoco@focalvmdev:~$ echo $DISKS
sdd sdc

Same behavior as before the patch, like suggested.

(c)rafaeldtinoco@focalvmdev:~$ apt-cache policy open-iscsi
open-iscsi:
  Installed: 2.0.874-7.1ubuntu6.1
  Candidate: 2.0.874-7.1ubuntu6.1
  Version table:
 *** 2.0.874-7.1ubuntu6.1 500
        500 http://ppa.launchpad.net/rafaeldtinoco/lp1877617/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status
     2.0.874-7.1ubuntu6 500
        500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages

review: Approve
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

(c)rafaeldtinoco@focal:~/.../sources/ubuntu/open-iscsi$ git ubuntu tag --upload

(c)rafaeldtinoco@focal:~/.../sources/ubuntu/open-iscsi$ git describe
upload/2.0.874-7.1ubuntu6.1

(c)rafaeldtinoco@focal:~/.../sources/ubuntu/open-iscsi$ git push pkg upload/2.0.874-7.1ubuntu6.1
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 8 threads
Compressing objects: 100% (12/12), done.
Writing objects: 100% (12/12), 4.75 KiB | 1.19 MiB/s, done.
Total 12 (delta 8), reused 0 (delta 0)
To ssh://git.launchpad.net/ubuntu/+source/open-iscsi
 * [new tag] upload/2.0.874-7.1ubuntu6.1 -> upload/2.0.874-7.1ubuntu6.1

(c)rafaeldtinoco@focal:~/.../sources/ubuntu/open-iscsi$ dput ubuntu ../open-iscsi_2.0.874-7.1ubuntu6.1_source.changes
Checking signature on .changes
gpg: ../open-iscsi_2.0.874-7.1ubuntu6.1_source.changes: Valid signature from A93E0E0AD83C0D0F
Checking signature on .dsc
gpg: ../open-iscsi_2.0.874-7.1ubuntu6.1.dsc: Valid signature from A93E0E0AD83C0D0F
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading open-iscsi_2.0.874-7.1ubuntu6.1.dsc: done.
  Uploading open-iscsi_2.0.874-7.1ubuntu6.1.debian.tar.xz: done.
  Uploading open-iscsi_2.0.874-7.1ubuntu6.1_source.buildinfo: done.
  Uploading open-iscsi_2.0.874-7.1ubuntu6.1_source.changes: done.
Successfully uploaded packages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index c812bc7..4dc56b9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
1open-iscsi (2.0.874-7.1ubuntu6.1) focal; urgency=medium
2
3 [ Ben Swartzlander ]
4 * allow open-iscsi to disable auto-scan feature (LP: #1877617)
5 - d/p/lp1877617-Allow-disabling-auto-LUN-scans.patch
6 - d/p/lp1877617-Fix-manual-LUN-scans-feature.patch
7
8 -- Rafael David Tinoco <rafaeldtinoco@ubuntu.com> Mon, 11 May 2020 02:03:33 +0000
9
1open-iscsi (2.0.874-7.1ubuntu6) focal; urgency=medium10open-iscsi (2.0.874-7.1ubuntu6) focal; urgency=medium
211
3 * d/extra/initramfs.local-{top,bottom}: move removal of open-iscsi.interface12 * d/extra/initramfs.local-{top,bottom}: move removal of open-iscsi.interface
diff --git a/debian/patches/lp1877617-Allow-disabling-auto-LUN-scans.patch b/debian/patches/lp1877617-Allow-disabling-auto-LUN-scans.patch
4new file mode 10064413new file mode 100644
index 0000000..1f41157
--- /dev/null
+++ b/debian/patches/lp1877617-Allow-disabling-auto-LUN-scans.patch
@@ -0,0 +1,227 @@
1Description: Allow disabling auto LUN scans
2
3Existing behavior of auto scanning LUNs is problematic for some
4deployments, particularly in cases where we are:
5
6- Accessing different LUNs from the same target on different machines
7 and we don't want the other LUNs automatically exposed in other
8 systems.
9
10- LUNs are constantly being created and removed from the target by
11 another machine and we don't want our systems polluted by no longer
12 available logical units, since default udev rules don't remove them
13 automatically from the system once they have been added automatically.
14
15This is a little more problematic when working with multipaths as we end
16up with a lot of leftover device maps.
17
18This patch introduces a new configuration option at the session level
19called "scan", with "auto" and "manual" as acceptable values, that
20allows us to disable the autoscan in the following cases:
21
22- On iscsid start
23- On login
24- On AEN/AER messages reporting LUNs data has changed.
25
26For HW drivers all sessions will use the value defined in the
27configuration file.
28
29Default value for this new option is "auto" to maintain existing
30behavior.
31
32Author: Gorka Eguileor <geguileo@redhat.com>
33Origin: upstream, https://github.com/open-iscsi/open-iscsi/commit/5e32aea957
34Bug-Ubuntu: https://launchpad.net/bugs/1877617
35Reviewed-By: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>
36Last-Update: 2020-05-11
37
38--- a/etc/iscsid.conf
39+++ b/etc/iscsid.conf
40@@ -306,3 +306,11 @@
41 # a task management function like an ABORT TASK or LOGICAL UNIT RESET, that
42 # it continue to respond to R2Ts. To enable this uncomment this line
43 # node.session.iscsi.FastAbort = No
44+
45+# To prevent doing automatic scans that would add unwanted luns to the system
46+# we can disable them and have sessions only do manually requested scans.
47+# Automatic scans are performed on startup, on login, and on AEN/AER reception
48+# on devices supporting it. For HW drivers all sessions will use the value
49+# defined in the configuration file. This configuration option is independent
50+# of scsi_mod scan parameter. (The default behavior is auto):
51+node.session.scan = auto
52--- a/usr/config.h
53+++ b/usr/config.h
54@@ -190,6 +190,7 @@
55 int queue_depth;
56 int initial_login_retry_max;
57 int nr_sessions;
58+ int scan;
59 struct iscsi_auth_config auth;
60 struct iscsi_session_timeout_config timeo;
61 struct iscsi_error_timeout_config err_timeo;
62--- a/usr/idbm.c
63+++ b/usr/idbm.c
64@@ -462,6 +462,9 @@
65 session.iscsi.MaxOutstandingR2T, IDBM_SHOW, num, 1);
66 __recinfo_int(SESSION_ERL, ri, r,
67 session.iscsi.ERL, IDBM_SHOW, num, 1);
68+ __recinfo_int_o2(SESSION_SCAN, ri, r,
69+ session.scan, IDBM_SHOW, "manual", "auto",
70+ num, 1);
71
72 for (i = 0; i < ISCSI_CONN_MAX; i++) {
73 char key[NAME_MAXVAL];
74@@ -2490,7 +2493,7 @@
75 log_debug(5, "disc removal removing link %s %s %s %s",
76 target, address, port, iface_id);
77
78- memset(rec, 0, sizeof(*rec));
79+ memset(rec, 0, sizeof(*rec));
80 strlcpy(rec->name, target, TARGET_NAME_MAXLEN);
81 rec->tpgt = atoi(tpgt);
82 rec->conn[0].port = atoi(port);
83@@ -2726,6 +2729,14 @@
84 sizeof(struct iscsi_slp_config));
85 }
86
87+int
88+idbm_session_autoscan(struct iscsi_session *session)
89+{
90+ if (session)
91+ return session->nrec.session.scan;
92+ return db->nrec.session.scan;
93+}
94+
95 struct user_param *idbm_alloc_user_param(char *name, char *value)
96 {
97 struct user_param *param;
98@@ -2981,6 +2992,7 @@
99 rec->session.info = NULL;
100 rec->session.sid = 0;
101 rec->session.multiple = 0;
102+ rec->session.scan = DEF_INITIAL_SCAN;
103 idbm_setup_session_defaults(&rec->session.iscsi);
104
105 for (i=0; i<ISCSI_CONN_MAX; i++) {
106--- a/usr/idbm.h
107+++ b/usr/idbm.h
108@@ -140,6 +140,7 @@
109 extern void idbm_sendtargets_defaults(struct iscsi_sendtargets_config *cfg);
110 extern void idbm_isns_defaults(struct iscsi_isns_config *cfg);
111 extern void idbm_slp_defaults(struct iscsi_slp_config *cfg);
112+extern int idbm_session_autoscan(struct iscsi_session *session);
113 extern int idbm_discovery_read(discovery_rec_t *rec, int type, char *addr,
114 int port);
115 extern int idbm_rec_read(node_rec_t *out_rec, char *target_name,
116--- a/usr/idbm_fields.h
117+++ b/usr/idbm_fields.h
118@@ -45,6 +45,7 @@
119 #define SESSION_MAX_CONNS "node.session.iscsi.MaxConnections"
120 #define SESSION_MAX_R2T "node.session.iscsi.MaxOutstandingR2T"
121 #define SESSION_ERL "node.session.iscsi.ERL"
122+#define SESSION_SCAN "node.session.scan"
123
124 /* connections fields */
125 #define CONN_ADDR "node.conn[%d].address"
126--- a/usr/initiator.c
127+++ b/usr/initiator.c
128@@ -997,7 +997,7 @@
129 {
130 pid_t pid;
131
132- pid = iscsi_sysfs_scan_host(hostno, 1);
133+ pid = iscsi_sysfs_scan_host(hostno, 1, idbm_session_autoscan(session));
134 if (pid == 0) {
135 mgmt_ipc_write_rsp(qtask, ISCSI_SUCCESS);
136
137@@ -1201,7 +1201,8 @@
138 break;
139 }
140
141- if (sshdr.asc == 0x3f && sshdr.ascq == 0x0e)
142+ if (sshdr.asc == 0x3f && sshdr.ascq == 0x0e
143+ && idbm_session_autoscan(session))
144 session_scan_host(session, session->hostno, NULL);
145 break;
146 case ISCSI_ASYNC_MSG_REQUEST_LOGOUT:
147--- a/usr/iscsi_settings.h
148+++ b/usr/iscsi_settings.h
149@@ -45,3 +45,6 @@
150
151 /* login retries */
152 #define DEF_INITIAL_LOGIN_RETRIES_MAX 4
153+
154+/* autoscan enabled */
155+#define DEF_INITIAL_SCAN 1
156--- a/usr/iscsi_sysfs.c
157+++ b/usr/iscsi_sysfs.c
158@@ -1882,12 +1882,15 @@
159 strlen(write_buf));
160 }
161
162-pid_t iscsi_sysfs_scan_host(int hostno, int async)
163+pid_t iscsi_sysfs_scan_host(int hostno, int async, int full_scan)
164 {
165 char id[NAME_SIZE];
166- char *write_buf = "- - -";
167+ char write_buf[6] = "- - 0";
168 pid_t pid = 0;
169
170+ if (full_scan)
171+ write_buf[4] = '-';
172+
173 if (async)
174 pid = fork();
175 if (pid == 0) {
176--- a/usr/iscsi_sysfs.h
177+++ b/usr/iscsi_sysfs.h
178@@ -87,7 +87,7 @@
179 struct iscsi_session_operational_config *conf);
180 extern void iscsi_sysfs_get_negotiated_conn_conf(int sid,
181 struct iscsi_conn_operational_config *conf);
182-extern pid_t iscsi_sysfs_scan_host(int hostno, int async);
183+extern pid_t iscsi_sysfs_scan_host(int hostno, int async, int full);
184 extern int iscsi_sysfs_get_session_state(char *state, int sid);
185 extern int iscsi_sysfs_get_host_state(char *state, int host_no);
186 extern int iscsi_sysfs_get_device_state(char *state, int host_no, int target,
187--- a/usr/iscsiadm.c
188+++ b/usr/iscsiadm.c
189@@ -773,7 +773,7 @@
190 iscsi_sysfs_for_each_device(NULL, host_no, info->sid,
191 iscsi_sysfs_rescan_device);
192 /* now scan for new devices */
193- iscsi_sysfs_scan_host(host_no, 0);
194+ iscsi_sysfs_scan_host(host_no, 0, 1);
195 return 0;
196 }
197
198--- a/usr/iscsid.c
199+++ b/usr/iscsid.c
200@@ -216,7 +216,7 @@
201 iscsi_err_to_str(err));
202 return 0;
203 }
204- iscsi_sysfs_scan_host(host_no, 0);
205+ iscsi_sysfs_scan_host(host_no, 0, idbm_session_autoscan(NULL));
206 return 0;
207 }
208
209--- a/usr/iscsistart.c
210+++ b/usr/iscsistart.c
211@@ -140,6 +140,7 @@
212 rec->session.initial_login_retry_max = -1;
213 rec->conn[0].timeo.noop_out_interval = -1;
214 rec->conn[0].timeo.noop_out_timeout = -1;
215+ rec->session.scan = -1;
216
217 list_for_each_entry(param, &user_params, list) {
218 /*
219@@ -183,6 +184,8 @@
220 rec->conn[0].timeo.noop_out_interval = 0;
221 if (rec->conn[0].timeo.noop_out_timeout == -1)
222 rec->conn[0].timeo.noop_out_timeout = 0;
223+ if (rec->session.scan == -1)
224+ rec->session.scan = DEF_INITIAL_SCAN;
225
226 return 0;
227 }
diff --git a/debian/patches/lp1877617-Fix-manual-LUN-scans-feature.patch b/debian/patches/lp1877617-Fix-manual-LUN-scans-feature.patch
0new file mode 100644228new file mode 100644
index 0000000..82db80d
--- /dev/null
+++ b/debian/patches/lp1877617-Fix-manual-LUN-scans-feature.patch
@@ -0,0 +1,54 @@
1Description: Fix manual LUN scans feature
2
3The newly introduced feature to disable automatic scans should not be
4scanning *any* of the LUNs when the scan is set to manual, but it always
5scans for LUN0.
6
7This patch fixes this by skipping the sysfs call altogether, as it
8should have been doing from the start.
9
10Author: Gorka Eguileor <geguileo@redhat.com>
11Origin: upstream, https://github.com/open-iscsi/open-iscsi/commit/d5483b0df9
12Bug-Ubuntu: https://launchpad.net/bugs/1877617
13Reviewed-By: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>
14Last-Update: 2020-05-11
15
16--- open-iscsi-2.0.874.orig/usr/iscsi_sysfs.c
17+++ open-iscsi-2.0.874/usr/iscsi_sysfs.c
18@@ -1882,18 +1882,19 @@ void iscsi_sysfs_rescan_device(void *dat
19 strlen(write_buf));
20 }
21
22-pid_t iscsi_sysfs_scan_host(int hostno, int async, int full_scan)
23+pid_t iscsi_sysfs_scan_host(int hostno, int async, int autoscan)
24 {
25 char id[NAME_SIZE];
26- char write_buf[6] = "- - 0";
27+ char *write_buf = "- - -";
28 pid_t pid = 0;
29
30- if (full_scan)
31- write_buf[4] = '-';
32-
33 if (async)
34 pid = fork();
35- if (pid == 0) {
36+
37+ if (pid >= 0 && !autoscan) {
38+ if (pid)
39+ log_debug(4, "host%d in manual scan mode, skipping scan", hostno);
40+ } else if (pid == 0) {
41 /* child */
42 log_debug(4, "scanning host%d", hostno);
43
44--- open-iscsi-2.0.874.orig/usr/iscsi_sysfs.h
45+++ open-iscsi-2.0.874/usr/iscsi_sysfs.h
46@@ -87,7 +87,7 @@ extern void iscsi_sysfs_get_negotiated_s
47 struct iscsi_session_operational_config *conf);
48 extern void iscsi_sysfs_get_negotiated_conn_conf(int sid,
49 struct iscsi_conn_operational_config *conf);
50-extern pid_t iscsi_sysfs_scan_host(int hostno, int async, int full);
51+extern pid_t iscsi_sysfs_scan_host(int hostno, int async, int autoscan);
52 extern int iscsi_sysfs_get_session_state(char *state, int sid);
53 extern int iscsi_sysfs_get_host_state(char *state, int host_no);
54 extern int iscsi_sysfs_get_device_state(char *state, int host_no, int target,
diff --git a/debian/patches/series b/debian/patches/series
index 9931433..b04e65d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -14,3 +14,5 @@ security/Skip-useless-strcopy-and-validate-CIDR-length.patch
14security/Check-iscsiuio-ping-data-length-for-validity.patch14security/Check-iscsiuio-ping-data-length-for-validity.patch
15iscid-conf-use-systemd.socket-patch15iscid-conf-use-systemd.socket-patch
16include-sys-sysmacros.h-to-properly-define-minor.patch16include-sys-sysmacros.h-to-properly-define-minor.patch
17lp1877617-Allow-disabling-auto-LUN-scans.patch
18lp1877617-Fix-manual-LUN-scans-feature.patch

Subscribers

People subscribed via source and target branches