Blame TODO

Packit eace71
iSCSI DEVELOPMENT HOWTO AND TODO
Packit eace71
--------------------------------
Packit eace71
July 7th 2011
Packit eace71
Packit eace71
Packit eace71
If you are admin or user and just want to send a fix, just send the fix any
Packit eace71
way you can. We can port the patch to the proper tree and fix up the patch
Packit eace71
for you. Engineers that would like to do more advanced development then the
Packit eace71
following guideline should be followed.
Packit eace71
Packit eace71
Submitting Patches
Packit eace71
------------------
Packit eace71
Code should follow the Linux kernel codying style doc:
Packit eace71
http://www.kernel.org/doc/Documentation/CodingStyle
Packit eace71
Packit eace71
Patches should be submitted to the open-iscsi list open-iscsi@googlegroups.com.
Packit eace71
They should be made with "git diff" or "diff -up" or "diff -uprN", and
Packit eace71
kernel patches must have a "Signed-off-by" line. See section 12
Packit eace71
http://www.kernel.org/doc/Documentation/SubmittingPatches for more
Packit eace71
information on the the signed off line.
Packit eace71
Packit eace71
Getting the Code
Packit eace71
----------------
Packit eace71
Kernel patches should be made against the linux-2.6-iscsi tree. This can
Packit eace71
be downloaded from kernel.org with git with the following commands:
Packit eace71
Packit eace71
git clone git://git.kernel.org/pub/scm/linux/kernel/git/mnc/linux-2.6-iscsi.git
Packit eace71
Packit eace71
Userspace patches should be made against the open-iscsi git tree:
Packit eace71
Packit eace71
git clone git://git.kernel.org/pub/scm/linux/kernel/git/mnc/open-iscsi.git
Packit eace71
Packit eace71
Packit eace71
Packit eace71
KERNEL TODO ITEMS
Packit eace71
-----------------
Packit eace71
Packit eace71
1. Make iSCSI log messages humanly readable. In many cases the iscsi tools
Packit eace71
and modules will log a error number value. The most well known is conn
Packit eace71
error 1011. Users should not have to search on google for what this means.
Packit eace71
Packit eace71
We should:
Packit eace71
Packit eace71
1. Write a simple table to convert the error values to a string and print
Packit eace71
them out.
Packit eace71
Packit eace71
2. Document the values, how you commonly hit them and common solutions
Packit eace71
in the iSCSI docs.
Packit eace71
Packit eace71
See scsi_transport_iscsi.c:iscsi_conn_error_event for where the evil
Packit eace71
"detected conn error 1011" is printed. See the enum iscsi_err in iscsi_if.h
Packit eace71
for a definition of the error code values.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
2. Implement iSCSI dev loss support.
Packit eace71
Packit eace71
Currently if a session is down for longer than replacement/recovery_timeout
Packit eace71
seconds, the iscsi layer will unblock the devices and fail IO. Other
Packit eace71
transport, like FC and SAS, will do something similar. FC has a
Packit eace71
fast_io_fail tmo which will unblock devices and fail IO, then it has a
Packit eace71
dev_loss_tmo which will delete the devices accessed through that port.
Packit eace71
Packit eace71
iSCSI needs to implement dev_loss_tmo behavior, because apps are beginning
Packit eace71
to expect this behavior. An initial path was made here:
Packit eace71
http://groups.google.com/group/open-iscsi/msg/031510ab4cecccfd?dmode=source 
Packit eace71
Packit eace71
Since all drivers want this behavior we want to make it common. We need to
Packit eace71
change the patch in that link to add a dev_loss_tmo handler callback to the
Packit eace71
scsi_transport_template struct, and add some common sysfs and helpers
Packit eace71
functions to manage the dev_loss_tmo variable.
Packit eace71
Packit eace71
Packit eace71
*Being worked on by Vikek S
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
3. Reduce locking contention between session lock.
Packit eace71
Packit eace71
The session lock is basically one big lock that protects everything
Packit eace71
in the iscsi_session. This lock could be broken down into smaller locks
Packit eace71
and maybe even replaced with something that would not require a lock.
Packit eace71
Packit eace71
For example:
Packit eace71
Packit eace71
1. The session lock serializes access to the current R2T the initiator is
Packit eace71
handling (a R2T from the target or the initialR2T if being used). libiscsi/
Packit eace71
libiscsi_tcp will call iscsi_tcp_get_curr_r2t and grab the session lock in
Packit eace71
the xmit path from the xmit thread and then in the recv path
Packit eace71
libiscsi_tcp/iscsi_tcp will call iscsi_tcp_r2t_rsp (this function is called
Packit eace71
with the session lock held). We could add a new per iscsi_task lock and
Packit eace71
use that to guard the R2T.
Packit eace71
Packit eace71
2. For iscsi_tcp and cxgb*i, libiscsi uses the session->cmdqueue linked list
Packit eace71
and the session lock to queue IO from the queuecommand function (run from
Packit eace71
scsi softirq or kblockd context) to the iscsi xmit thread. Once the task is
Packit eace71
sent from that thread, it is deleted from the list.
Packit eace71
Packit eace71
It seems we should be able to remove the linked list use here. The tasks
Packit eace71
are all preallocated in the session->cmds array. We can access that
Packit eace71
array and check the task->state (see fail_scsi_tasks for an example).
Packit eace71
We just need to come up with a way to safely set the task state,
Packit eace71
wake the xmit thread and make sure that tasks are executed in the order
Packit eace71
that the scsi layer sent them to our queuecommand function.
Packit eace71
Packit eace71
A starting point on the queueing:
Packit eace71
We might be able to create a workqueue per processor, queue the work,
Packit eace71
which in this case is the execution of the task, from the queuecommand,
Packit eace71
then rely on the work queue synchronization and serialization code.
Packit eace71
Not 100% sure about this.
Packit eace71
Packit eace71
Alternative to changing the threading:
Packit eace71
Can we figure out a way to just remove the xmit thread? We currently
Packit eace71
cannot because the network may only be able to send 1000 bytes, but
Packit eace71
to send the current command we need to send 2000. We cannot sleep
Packit eace71
from the queuecommand context until another 1000 bytes frees up and for
Packit eace71
iscsi_tcp we cannot sleep from the recv conext (this happens because we
Packit eace71
could have got a R2T from target and are handling it from the recv path).
Packit eace71
Packit eace71
Packit eace71
Note: that for iser and offload drivers like bnx2i and be2iscsi their
Packit eace71
is no xmit thread used.
Packit eace71
Packit eace71
Note2: cxgb*i does not actually need the xmit thread so a side project
Packit eace71
could be to convert that driver.
Packit eace71
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
4. Make memory access more efficient on multi-processor machines.
Packit eace71
We are moving twords per process queues in the block layer, so it would
Packit eace71
be a good idea to move the iscsi structs to be allocated on a per process
Packit eace71
basis.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
5. Make blk_iopoll support (see block/blk-iopoll.c and be2iscsi for an
Packit eace71
example) being able to round robin IO across processors or complete
Packit eace71
on the processor it was queued on
Packit eace71
(today it always completes the IO on the processor the softirq was raised on),
Packit eace71
and convert bnx2i, ib_iser and cxgb*i to it.
Packit eace71
Packit eace71
Not sure if it will help iscsi_tcp and cxgb, because their completion is done
Packit eace71
from the network softirq which does polling already. With irq balancing it
Packit eace71
can also be spread over all processors too.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
7. When userspace calls into the kernel using the iscsi netlink interface
Packit eace71
to execute oprations like creating/destroying a session, create a connection
Packit eace71
to a target, etc the rx_queue_mutex is held the entire time (see
Packit eace71
iscsi_if_rx for the iscsi netlink interface entry point). This means
Packit eace71
if the driver should block every thing will be held up.
Packit eace71
Packit eace71
iscsi_tcp does not block, but some offload drivers might for a couple seconds
Packit eace71
to 10 or 15 secs while it figures out what is going on or cleans up. This a 
Packit eace71
major problem for things like multipath where one connection blocking up the
Packit eace71
recovery of every other connection will delay IO from re-flowing quickly.
Packit eace71
Packit eace71
We should looking into breaking up the rx_queue_mutex into finer grained
Packit eace71
locks or making it multi threaded. For the latter we could queue operations
Packit eace71
into workqueues.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
7. Add tracing support to iscsi modules. See the scsi layer's
Packit eace71
trace_scsi_dispatch_cmd_start for an example.
Packit eace71
Packit eace71
Well, actually in general look into all the tracing stuff available
Packit eace71
(trace_printk/ftrace, etc) and use one.
Packit eace71
Packit eace71
See http://lwn.net/Articles/291091/ for some details on what is out
Packit eace71
there. We can only use something that is upstream though.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
8. Improve the iscsi driver logging. Each driver has a different
Packit eace71
way to control logging. We should unify them and make it manageable
Packit eace71
by iscsiadm. So each driver would use a common format, there would
Packit eace71
be a common kernel interface to set the logging level, etc.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
9. Implement more features from the iSCSI RFC if they are worth it.
Packit eace71
Packit eace71
- Error Recovery Level (ERL) 1 support - will help tape support.
Packit eace71
- Multi R2T support - Might improve write performance.
Packit eace71
- OutOfOrder support - Might imrpove performance.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
10. Add support for digest/CRC offload.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
11. Finish intel IOAT support. I started this here:
Packit eace71
http://groups.google.com/group/open-iscsi/msg/2626b8606edbe690?dmode=source
Packit eace71
but could only test on boxes with 1 gig interfaces which showed no
Packit eace71
difference in performance. Intel had said they saw significant throughput
Packit eace71
gains when using 10 gig.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
12. Remove the login buffer preallocated buffer. Storage drivers must be able
Packit eace71
to make forward process, so that they can always write out a page incase the
Packit eace71
kernel needs to allocate the page to another process. If the connection were
Packit eace71
to be disconnected and the initiator needed to relogin to the target at this
Packit eace71
time, we might not be abe to allocate a page for the login commands buffer.
Packit eace71
Packit eace71
To work around the problem the initiator prealloctes a 8K (sometimes
Packit eace71
more depending on the page size) buffer for each session (see iscsi_conn_setup'
Packit eace71
s __get_free_pages call). This is obviously very wasteful since it will be
Packit eace71
a rare occurrence. Can we think of a way to allow multiple sessions to
Packit eace71
be relogged in at the same time, but not have to preallocate so many
Packit eace71
buffers?
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
13. Support iSCSI over swap safely.
Packit eace71
Packit eace71
Basically just need to hook iscsi_tcp into the patches that
Packit eace71
were submitted here for NBD.
Packit eace71
Packit eace71
https://lwn.net/Articles/446831/
Packit eace71
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
Packit eace71
Packit eace71
Packit eace71
Packit eace71
USERSPACE TODO ITEMS
Packit eace71
--------------------
Packit eace71
1. The iscsi tools, iscsid, iscsiadm and iscsid, have a debug flag, -d N, that
Packit eace71
allows the user to control the amount of output that is logged. The argument
Packit eace71
N is a integer from 1 to 8, with 8 printing out the most output.
Packit eace71
Packit eace71
The problem is that the values from 1 to 8 do not really mean much. It would
Packit eace71
helpful if we could replace them with something that controls what exactly
Packit eace71
the iscsi tools and kernel modules log.
Packit eace71
Packit eace71
For example, if we made the debug level argument a bitmap then
Packit eace71
Packit eace71
iscsiadm -m node --login -d LOGIN_ERRS,PDUS,FUNCTION
Packit eace71
Packit eace71
might print out extended iscsi login error information (LOGIN_ERRS),
Packit eace71
the iSCSI packets that were sent/receieved (PDUS), and the functions
Packit eace71
that were run (FUNCTION). Note, the use of a bitmapp and the debug
Packit eace71
levels are just an example. Feel free to do something else.
Packit eace71
Packit eace71
Packit eace71
We would want to be able to have iscsiadm control the iscsi kernel
Packit eace71
logging as well. There are interfaces like
Packit eace71
/sys/module/libiscsi/paramters/*debug*
Packit eace71
/sys/module/libiscsi_tcp/paramters/*debug*
Packit eace71
/sys/module/iscsi_tcp/paramters/*debug*
Packit eace71
/sys/module/scsi_transport_iscsi/paramters/*debug*
Packit eace71
Packit eace71
but we would want to extend the debugging options to be finer grained
Packit eace71
and we would want to make it supportable by all iscsi drivers.
Packit eace71
(see #8 on the kernel todo).
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
2. "iscsiadm -m session -P 3" can print out a lot of information about the
Packit eace71
session, but not all configuration values are printed.
Packit eace71
Packit eace71
iscsiadm should be modified to print out other settings like timeouts,
Packit eace71
Chap settings,  the iSCSI values that were requested vs negotiated for, etc.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
3. iscsiadm cannot update a setting of a running session. If you want
Packit eace71
to change a timeout you have to run the iscsiadm logout command,
Packit eace71
then update the record value, then login:
Packit eace71
Packit eace71
iscsiadm -m node -T target -p ip -u
Packit eace71
iscsidm -m node -T target -p ip -o update -n node.session.timeo.replacement_timeout -v 30
Packit eace71
iscsiadm -m node -T target -p ip -l
Packit eace71
Packit eace71
iscsiadm should be modified to allow updating of a setting without having
Packit eace71
to run the iscsiadm command.
Packit eace71
Packit eace71
Note that for some settings like iSCSI ones (ImmediateData, FirstBurstLength,
Packit eace71
etc)  that must be negotiated with the target we will have to logout the
Packit eace71
target then re-login, but we should not have to completely destroy the session
Packit eace71
and scsi devices like is done when running the iscsiadm logout command. We
Packit eace71
should be able to pass iscsid the new values and then have iscsid logout and
Packit eace71
relogin.
Packit eace71
Packit eace71
Other settings like the abort timeout will not need a logout/login. We can
Packit eace71
just pass those to the kernel or iscsid to use.
Packit eace71
Packit eace71
Packit eace71
*Being worked on by Tomoaki Nishimura
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
4. iscsiadm will attempt to perform logins/logouts in parallel. Running
Packit eace71
iscsiadm -m node -L, will cause iscsiadm to login to all portals with
Packit eace71
the startup=automatic field set at the same time.
Packit eace71
Packit eace71
To log into a target, iscsiadm opens a socket to iscsid, sends iscsid a
Packit eace71
request to login to a target, iscsid performs the iSCSI login operation,
Packit eace71
then iscsid sends iscsiadm a reply.
Packit eace71
Packit eace71
To perform multiple logins iscsiadm will open a socket for each login
Packit eace71
request, then wait for a reply. This is a problem because for 1000s of targets
Packit eace71
we will have 1000s of sockets open. There is a rlimit to control how many
Packit eace71
files a process can have open and iscsiadm currently runs setrlimit to
Packit eace71
increase this.
Packit eace71
Packit eace71
With users creating lots of virtual iscsi interfaces on the target and
Packit eace71
initiator with each having multiple paths it beomes inefficient to open
Packit eace71
a socket for each requests.
Packit eace71
Packit eace71
At the very least we want to handle setrlimit RLIMIT_NOFILE limit better,
Packit eace71
and it would be best to just stop openening a socket per login request.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
6. Implement broadcast/multicasts support, so the initiator can
Packit eace71
find iSNS servers without the user having to set the iSNS server address.
Packit eace71
Packit eace71
See
Packit eace71
5.6.5.14. Name Service Heartbeat (Heartbeat)
Packit eace71
in
Packit eace71
http://tools.ietf.org/html//rfc4171
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
7. Open-iscsi uses the open-isns iSNS library. The library might be a little
Packit eace71
too complicated and a little too heavy for what we need. Investigate
Packit eace71
replacing it.
Packit eace71
Packit eace71
Also explore merging the open-isns and linux-isns projects, so we do not have
Packit eace71
to support multiple isns clients/servers in linux.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
8. Implement the DHCP iSNS option support, so we the initiator can
Packit eace71
find the iSNS sever without the user having to set the iSNS server address.
Packit eace71
See:
Packit eace71
http://www.ietf.org/rfc/rfc4174.txt
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
9. Some iscsiadm/iscsid operations that access the iscsi DB and sysfs can be
Packit eace71
up to Big O(N^2). Some of the code was written when we thought 64 sessions
Packit eace71
would be a lot and the norm would be 4 or 8. Due to virtualization, cloud use,
Packit eace71
and targets like equallogic that do a target per logical unit (device) we can
Packit eace71
see 1000s of sessions.
Packit eace71
Packit eace71
- We should look into making the record DB more efficient. Maybe
Packit eace71
time to use a real DB (something small simple and efficient since this
Packit eace71
needs to run in places like the initramfs).
Packit eace71
Packit eace71
- Rewrite code to look up a running session so we do not have loop
Packit eace71
over every session in sysfs.
Packit eace71
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
10. Look into using udev's libudev for our sysfs access in iscsiadm/iscsid/
Packit eace71
iscsistart.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
11. iSCSI lib.
Packit eace71
Packit eace71
I am working on this one. Hopefully it should be done soon.
Packit eace71
Packit eace71
---------------------------------------------------------------------------
Packit eace71
Packit eace71
12. Figure out how to stop using our own copy of iscsi_if.h, since
Packit eace71
it gets out of sync with the kernel version, and that's not good.
Packit eace71
Packit eace71
---------------------------------------------------------------------------