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

Proposed by Rafael David Tinoco
Status: Merged
Approved by: Rafael David Tinoco
Approved revision: dc2d0705253394b383beac6d8b30ca363debc1ff
Merged at revision: dc2d0705253394b383beac6d8b30ca363debc1ff
Proposed branch: ~rafaeldtinoco/ubuntu/+source/open-iscsi:lp1877617-bionic
Merge into: ubuntu/+source/open-iscsi:ubuntu/bionic-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) Needs Information
Canonical Server Pending
Review via email: mp+383682@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Changelog, Patch headers and the patch itself LGTM.
Since it does not change the default, but only provides a way to change the behavior it seems good for an SRU to me.

The addition of node.session.scan = auto to the conffile is fine.
But we have to consider people might upgrade with a custom iscsid.conf and NOT take the changes.
This will make the value unset.

The code reading it is:
+ __recinfo_int_o2(SESSION_SCAN, ri, r,
+ session.scan, IDBM_SHOW, "manual", "auto",
+ num, 1);

I was trying to check the code but I'm not entirely sure.
Target should be that if the user declines the conffile change then it should still behave like before (as if auto was set). Could you test that before pushing a SRU?

+1 to SRU this after the new version is in groovy and the above is checked.

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

(k)rafaeldtinoco@bionicvmdev:~$ TARGET_IQN=$(iscsi-iname)
(k)rafaeldtinoco@bionicvmdev:~$ INITIATOR_IQN=$(sudo awk -F = '/InitiatorName=/ {print $2}' /etc/iscsi/initiatorname.iscsi)

(k)rafaeldtinoco@bionicvmdev:~$ sudo targetcli /iscsi create $TARGET_IQN
Created target iqn.2005-03.org.open-iscsi:b1d5ef68d55e.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.

(k)rafaeldtinoco@bionicvmdev:~$ sudo targetcli /iscsi/$TARGET_IQN/tpg1/acls create $INITIATOR_IQN
Created Node ACL for iqn.1993-08.org.debian:01:c8d8c9ccc8

(k)rafaeldtinoco@bionicvmdev:~$ sudo targetcli /backstores/fileio create lun1 /lun1 1G
Created fileio lun1 with size 1073741824

(k)rafaeldtinoco@bionicvmdev:~$ sudo targetcli /iscsi/$TARGET_IQN/tpg1/luns create /backstores/fileio/lun1 1
Created LUN 1.
Created LUN 1->1 mapping in node ACL iqn.1993-08.org.debian:01:c8d8c9ccc8

(k)rafaeldtinoco@bionicvmdev:~$ sudo targetcli /backstores/fileio create lun2 /lun2 1G
Created fileio lun2 with size 1073741824

(k)rafaeldtinoco@bionicvmdev:~$ sudo targetcli /iscsi/$TARGET_IQN/tpg1/luns create /backstores/fileio/lun2 2
Created LUN 2.
Created LUN 2->2 mapping in node ACL iqn.1993-08.org.debian:01:c8d8c9ccc8

(k)rafaeldtinoco@bionicvmdev:~$ 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:b1d5ef68d55e] added

(k)rafaeldtinoco@bionicvmdev:~$ 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:b1d5ef68d55e, portal: 127.0.0.1,3260] (multiple)
Login to [iface: default, target: iqn.2005-03.org.open-iscsi:b1d5ef68d55e, portal: 127.0.0.1,3260] successful.

(k)rafaeldtinoco@bionicvmdev:~$ eval "DISKS=\$(sudo iscsiadm -m session -P3 | awk '/Attached scsi disk/ {print \$4}')"

(k)rafaeldtinoco@bionicvmdev:~$ echo $DISKS
sdd sdc

This is the same behavior as before and the package from PPA is being used:

(k)rafaeldtinoco@bionicvmdev:~$ apt-cache policy open-iscsi
open-iscsi:
  Installed: 2.0.874-5ubuntu2.10
  Candidate: 2.0.874-5ubuntu2.10
  Version table:
 *** 2.0.874-5ubuntu2.10 500
        500 http://ppa.launchpad.net/rafaeldtinoco/lp1877617/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status
     2.0.874-5ubuntu2.9 500
        500 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
     2.0.874-5ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

so it is good to go.

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

(c)rafaeldtinoco@bionic:~/.../sources/ubuntu/open-iscsi$ git describe
upload/2.0.874-5ubuntu2.10

(c)rafaeldtinoco@bionic:~/.../sources/ubuntu/open-iscsi$ git push pkg upload/2.0.874-5ubuntu2.10
Counting objects: 12, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (12/12), 4.86 KiB | 1.21 MiB/s, done.
Total 12 (delta 7), reused 0 (delta 0)
remote: Checking connectivity: 12, done.
To ssh://git.launchpad.net/ubuntu/+source/open-iscsi
 * [new tag] upload/2.0.874-5ubuntu2.10 -> upload/2.0.874-5ubuntu2.10

(c)rafaeldtinoco@bionic:~/.../sources/ubuntu/open-iscsi$ dput ubuntu ../open-iscsi_2.0.874-5ubuntu2.10_source.changes
Checking signature on .changes
gpg: ../open-iscsi_2.0.874-5ubuntu2.10_source.changes: Valid signature from A93E0E0AD83C0D0F
Checking signature on .dsc
gpg: ../open-iscsi_2.0.874-5ubuntu2.10.dsc: Valid signature from A93E0E0AD83C0D0F
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading open-iscsi_2.0.874-5ubuntu2.10.dsc: done.
  Uploading open-iscsi_2.0.874-5ubuntu2.10.debian.tar.xz: done.
  Uploading open-iscsi_2.0.874-5ubuntu2.10_source.buildinfo: done.
  Uploading open-iscsi_2.0.874-5ubuntu2.10_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 28bb3f8..67521bb 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,12 @@
6+open-iscsi (2.0.874-5ubuntu2.10) bionic; 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 01:27:31 +0000
14+
15 open-iscsi (2.0.874-5ubuntu2.9) bionic; urgency=medium
16
17 * Ship open-iscsi finalrd hook. LP: #1800681
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 34608a6..6a070b6 100644
313--- a/debian/patches/series
314+++ b/debian/patches/series
315@@ -13,3 +13,5 @@ security/Ensure-strings-from-peer-are-copied-correctly.patch
316 security/Skip-useless-strcopy-and-validate-CIDR-length.patch
317 security/Check-iscsiuio-ping-data-length-for-validity.patch
318 iscid-conf-use-systemd.socket-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