iscsi tools: Displaying timeout and CHAP in iscisadm info
[open-iscsi.git] / TODO
blob06777c424ca400f0f6d2dcd43c6471b9721c7615
1 iSCSI DEVELOPMENT HOWTO AND TODO
2 --------------------------------
3 July 7th 2011
6 If you are admin or user and just want to send a fix, just send the fix any
7 way you can. We can port the patch to the proper tree and fix up the patch
8 for you. Engineers that would like to do more advanced development then the
9 following guideline should be followed.
11 Submitting Patches
12 ------------------
13 Code should follow the Linux kernel codying style doc:
14 http://www.kernel.org/doc/Documentation/CodingStyle
16 Patches should be submitted to the open-iscsi list open-iscsi@googlegroups.com.
17 They should be made with "git diff" or "diff -up" or "diff -uprN", and
18 kernel patches must have a "Signed-off-by" line. See section 12
19 http://www.kernel.org/doc/Documentation/SubmittingPatches for more
20 information on the the signed off line.
22 Getting the Code
23 ----------------
24 Kernel patches should be made against the linux-2.6-iscsi tree. This can
25 be downloaded from kernel.org with git with the following commands:
27 git clone git://git.kernel.org/pub/scm/linux/kernel/git/mnc/linux-2.6-iscsi.git
29 Userspace patches should be made against the open-iscsi git tree:
31 git clone git://git.kernel.org/pub/scm/linux/kernel/git/mnc/open-iscsi.git
35 KERNEL TODO ITEMS
36 -----------------
38 1. Make iSCSI log messages humanly readable. In many cases the iscsi tools
39 and modules will log a error number value. The most well known is conn
40 error 1011. Users should not have to search on google for what this means.
42 We should:
44 1. Write a simple table to convert the error values to a string and print
45 them out.
47 2. Document the values, how you commonly hit them and common solutions
48 in the iSCSI docs.
50 See scsi_transport_iscsi.c:iscsi_conn_error_event for where the evil
51 "detected conn error 1011" is printed. See the enum iscsi_err in iscsi_if.h
52 for a definition of the error code values.
54 ---------------------------------------------------------------------------
56 2. Implement iSCSI dev loss support.
58 Currently if a session is down for longer than replacement/recovery_timeout
59 seconds, the iscsi layer will unblock the devices and fail IO. Other
60 transport, like FC and SAS, will do something similar. FC has a
61 fast_io_fail tmo which will unblock devices and fail IO, then it has a
62 dev_loss_tmo which will delete the devices accessed through that port.
64 iSCSI needs to implement dev_loss_tmo behavior, because apps are beginning
65 to expect this behavior. An initial path was made here:
66 http://groups.google.com/group/open-iscsi/msg/031510ab4cecccfd?dmode=source 
68 Since all drivers want this behavior we want to make it common. We need to
69 change the patch in that link to add a dev_loss_tmo handler callback to the
70 scsi_transport_template struct, and add some common sysfs and helpers
71 functions to manage the dev_loss_tmo variable.
74 *Being worked on by Vikek S
76 ---------------------------------------------------------------------------
78 3. Reduce locking contention between session lock.
80 The session lock is basically one big lock that protects everything
81 in the iscsi_session. This lock could be broken down into smaller locks
82 and maybe even replaced with something that would not require a lock.
84 For example:
86 1. The session lock serializes access to the current R2T the initiator is
87 handling (a R2T from the target or the initialR2T if being used). libiscsi/
88 libiscsi_tcp will call iscsi_tcp_get_curr_r2t and grab the session lock in
89 the xmit path from the xmit thread and then in the recv path
90 libiscsi_tcp/iscsi_tcp will call iscsi_tcp_r2t_rsp (this function is called
91 with the session lock held). We could add a new per iscsi_task lock and
92 use that to gaurd the R2T.
94 2. For iscsi_tcp and cxgb*i, libiscsi uses the session->cmdqueue linked list
95 and the session lock to queue IO from the queuecommand function (run from
96 scsi softirq or kblockd context) to the iscsi xmit thread. Once the task is
97 sent from that thread, it is deleted from the list.
99 It seems we should be able to remove the linked list use here. The tasks
100 are all preallocated in the session->cmds array. We can access that
101 array and check the task->state (see fail_scsi_tasks for an example).
102 We just need to come up with a way to safely set the task state,
103 wake the xmit thread and make sure that tasks are executed in the order
104 that the scsi layer sent them to our queuecommand function.
106 A starting point on the queueing:
107 We might be able to create a workqueue per processor, queue the work,
108 which in this case is the execution of the task, from the queuecommand,
109 then rely on the work queue synchronization and serialization code.
110 Not 100% sure about this.
112 Alternative to changing the threading:
113 Can we figure out a way to just remove the xmit thread? We currently
114 cannot because the network may only be able to send 1000 bytes, but
115 to send the current command we need to send 2000. We cannot sleep
116 from the queuecommand context until another 1000 bytes frees up and for
117 iscsi_tcp we cannot sleep from the recv conext (this happens because we
118 could have got a R2T from target and are handling it from the recv path).
121 Note: that for iser and offload drivers like bnx2i and be2iscsi their
122 is no xmit thread used.
124 Note2: cxgb*i does not actually need the xmit thread so a side project
125 could be to convert that driver.
128 ---------------------------------------------------------------------------
130 4. Make memory access more efficient on multi-processor machines.
131 We are moving twords per process queues in the block layer, so it would
132 be a good idea to move the iscsi structs to be allocated on a per process
133 basis.
135 ---------------------------------------------------------------------------
137 5. Make blk_iopoll support (see block/blk-iopoll.c and be2iscsi for an
138 example) being able to round robin IO across processors or complete
139 on the processor it was queued on
140 (today it always completes the IO on the processor the softirq was raised on),
141 and convert bnx2i, ib_iser and cxgb*i to it.
143 Not sure if it will help iscsi_tcp and cxgb, because their completion is done
144 from the network softirq which does polling already. With irq balancing it
145 can also be spread over all processors too.
147 ---------------------------------------------------------------------------
149 6. Replace iscsi_get_next_target_id with idr use.
151 iscsi_tcp and ib_iser allocate a session per host, so the target_id is
152 always just 0. The offload drivers allocate a host per pci resource, so they
153 will have multiple sessions for each host. When a session is added,
154 iscsi_add_session will try to find a target_id to use by looping over
155 all the targets on the host. We could replace that loop with idr.
158 * Being worked on by John Jose.
160 ---------------------------------------------------------------------------
162 7. When userspace calls into the kernel using the iscsi netlink interface
163 to execute oprations like creating/destroying a session, create a connection
164 to a target, etc the rx_queue_mutex is held the entire time (see
165 iscsi_if_rx for the iscsi netlink interface entry point). This means
166 if the driver should block every thing will be held up.
168 iscsi_tcp does not block, but some offload drivers might for a couple seconds
169 to 10 or 15 secs while it figures out what is going on or cleans up. This a 
170 major problem for things like multipath where one connection blocking up the
171 recovery of every other connection will delay IO from re-flowing quickly.
173 We should looking into breaking up the rx_queue_mutex into finer grained
174 locks or making it multi threaded. For the latter we could queue operations
175 into workqueues.
177 ---------------------------------------------------------------------------
179 7. Add tracing support to iscsi modules. See the scsi layer's
180 trace_scsi_dispatch_cmd_start for an example.
182 Well, actually in general look into all the tracing stuff available
183 (trace_printk/ftrace, etc) and use one.
185 See http://lwn.net/Articles/291091/ for some details on what is out
186 there. We can only use something that is upstream though.
188 ---------------------------------------------------------------------------
190 8. Improve the iscsi driver logging. Each driver has a different
191 way to control logging. We should unify them and make it managable
192 by iscsiadm. So each driver would use a common format, there would
193 be a common kernel interface to set the logging level, etc.
195 ---------------------------------------------------------------------------
197 9. Implement more features from the iSCSI RFC if they are worth it.
199 - Error Recovery Level (ERL) 1 support - will help tape support.
200 - Multi R2T support - Might improve write performance.
201 - OutOfOrder support - Might imrpove performance.
203 ---------------------------------------------------------------------------
205 10. Add support for digest/CRC offload.
207 ---------------------------------------------------------------------------
209 11. Finish intel IOAT support. I started this here:
210 http://groups.google.com/group/open-iscsi/msg/2626b8606edbe690?dmode=source
211 but could only test on boxes with 1 gig interfaces which showed no
212 difference in performance. Intel had said they saw significant throughput
213 gains when using 10 gig.
215 ---------------------------------------------------------------------------
217 12. Remove the login buffer preallocated buffer. Storage drivers must be able
218 to make forward process, so that they can always write out a page incase the
219 kernel needs to allocate the page to another process. If the connection were
220 to be disconnected and the initiator needed to relogin to the target at this
221 time, we might not be abe to allocate a page for the login commands buffer.
223 To work around the problem the initiator prealloctes a 8K (sometimes
224 more depending on the page size) buffer for each session (see iscsi_conn_setup'
225 s __get_free_pages call). This is obviously very wasteful since it will be
226 a rate occurance. Can we think of a way to allow multiple sessions to
227 be relogged in at the same time, but not have to preallocate so many
228 buffers?
230 ---------------------------------------------------------------------------
232 13. Support iSCSI over swap safely.
234 Basically just need to hook iscsi_tcp into the patches that
235 were submitted here for NBD.
237 https://lwn.net/Articles/446831/
240 ---------------------------------------------------------------------------
246 USERSPACE TODO ITEMS
247 --------------------
248 1. The iscsi tools, iscsid, iscsiadm and iscsid, have a debug flag, -d N, that
249 allows the user to control the amount of output that is logged. The argument
250 N is a integer from 1 to 8, with 8 printing out the most output.
252 The problem is that the values from 1 to 8 do not really mean much. It would
253 helpful if we could replace them with something that controls what exactly
254 the iscsi tools and kernel modules log.
256 For example, if we made the debug level argument a bitmap then
258 iscsiadm -m node --login -d LOGIN_ERRS,PDUS,FUNCTION
260 might print out extended iscsi login error information (LOGIN_ERRS),
261 the iSCSI packets that were sent/receieved (PDUS), and the functions
262 that were run (FUNCTION). Note, the use of a bitmapp and the debug
263 levels are just an example. Feel free to do something else.
266 We would want to be able to have iscsiadm control the iscsi kernel
267 logging as well. There are interfaces like
268 /sys/module/libiscsi/paramters/*debug*
269 /sys/module/libiscsi_tcp/paramters/*debug*
270 /sys/module/iscsi_tcp/paramters/*debug*
271 /sys/module/scsi_transport_iscsi/paramters/*debug*
273 but we would want to extend the debugging options to be finer grained
274 and we would want to make it supportable by all iscsi drivers.
275 (see #8 on the kernel todo).
277 ---------------------------------------------------------------------------
279 2. "iscsiadm -m session -P 3" can print out a lot of information about the
280 session, but not all configuration values are printed.
282 iscsiadm should be modified to print out other settings like timeouts,
283 Chap settings,  the iSCSI values that were requested vs negotiated for, etc.
285 ---------------------------------------------------------------------------
287 3. iscsiadm cannot update a setting of a running session. If you want
288 to change a timeout you have to run the iscsiadm logout command,
289 then update the record value, then login:
291 iscsiadm -m node -T target -p ip -u
292 iscsidm -m node -T target -p ip -o update -n node.session.timeo.replacement_timeout -v 30
293 iscsiadm -m node -T target -p ip -l
295 iscsiadm should be modified to allow updating of a setting without having
296 to run the iscsiadm command.
298 Note that for some settings like iSCSI ones (ImmediateData, FirstBurstLength,
299 etc)  that must be negotiated with the target we will have to logout the
300 target then re-login, but we should not have to completely destroy the session
301 and scsi devices like is done when running the iscsiadm logout command. We
302 should be able to pass iscsid the new values and then have iscsid logout and
303 relogin.
305 Other settings like the abort timeout will not need a logout/login. We can
306 just pass those to the kernel or iscsid to use.
309 *Being worked on by Tomoaki Nishimura
311 ---------------------------------------------------------------------------
313 4. iscsiadm will attempt to perform logins/logouts in parallel. Running
314 iscsiadm -m node -L, will cause iscsiadm to login to all portals with
315 the startup=automatic field set at the same time.
317 To log into a target, iscsiadm opens a socket to iscsid, sends iscsid a
318 request to login to a target, iscsid performs the iSCSI login operation,
319 then iscsid sends iscsiadm a reply.
321 To perform multiple logins iscsiadm will open a socket for each login
322 request, then wait for a reply. This is a problem because for 1000s of targets
323 we will have 1000s of sockets open. There is a rlimit to control how many
324 files a process can have open and iscsiadm currently runs setrlimit to
325 increase this.
327 With users creating lots of virtual iscsi interfaces on the target and
328 initiator with each having multiple paths it beomes inefficient to open
329 a socket for each requests.
331 At the very least we want to handle setrlimit RLIMIT_NOFILE limit better,
332 and it would be best to just stop openening a socket per login request.
334 ---------------------------------------------------------------------------
336 5. Make iSCSI log messages humanly readable. In many cases the iscsi tools
337 will log a error number value. The most well known is conn error 1011.
338 Users should not have to search on google for what this means.
340 We should:
342 1. Write a simple table to convert the error values to a string and print
343 them out.
345 2. Document the values, how you commonly hit them and common solutions
346 in the iSCSI docs.
349 See session_conn_error and __check_iscsi_status_class as a start.
351 ---------------------------------------------------------------------------
353 6. Implement broadcast/multicasts support, so the initiator can
354 find iSNS servers without the user having to set the iSNS server address.
357 5.6.5.14. Name Service Heartbeat (Heartbeat)
359 http://tools.ietf.org/html//rfc4171
361 ---------------------------------------------------------------------------
363 7. Open-iscsi uses the open-isns iSNS library. The library might be a little
364 too complicated and a little too heavy for what we need. Investigate
365 replacing it.
367 Also explore merging the open-isns and linux-isns projects, so we do not have
368 to support multiple isns clients/servers in linux.
370 ---------------------------------------------------------------------------
372 8. Implement the DHCP iSNS option support, so we the initiator can
373 find the iSNS sever without the user having to set the iSNS server address.
374 See:
375 http://www.ietf.org/rfc/rfc4174.txt
377 ---------------------------------------------------------------------------
379 9. Some iscsiadm/iscsid operations that access the iscsi DB and sysfs can be
380 up to Big O(N^2). Some of the code was written when we thought 64 sessions
381 would be a lot and the norm would be 4 or 8. Due to virtualization, cloud use,
382 and targets like equallogic that do a target per logical unit (device) we can
383 see 1000s of sessions.
385 - We should look into making the record DB more efficient. Maybe
386 time to use a real DB (something small simple and efficient since this
387 needs to run in places like the initramfs).
389 - Rewrite code to look up a running session so we do not have loop
390 over every session in sysfs.
393 ---------------------------------------------------------------------------
395 10. Look into using udev's libudev for our sysfs access in iscsiadm/iscsid/
396 iscsistart.
398 ---------------------------------------------------------------------------
400 11. iSCSI lib.
402 I am working on this one. Hopefully it should be done soon.
404 ---------------------------------------------------------------------------