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

Subscribers

People subscribed via source and target branches