Fix get_bsg_major

fix error handling in get_bsg_major() return error code if the device
file in /sys/class/bsg failed to open; use fscanf to read an integer
major number directly (instead of reading and parsing the string),
return error and print appropriate messages when scanf fails.

Signed-off-by: Alexander Nezhinsky <alexandern@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
return Reject in iscsi login text failure

If param check fails during iscsi login text processing, answer that
key with Reject. According to iscsi spec (5.2) the target can choose
between responding bad values with key=Reject, sending an admissible
value and closing the connection by returning a login error. Here the
Reject option is implemented. Any objections?

Signed-off-by: Alexander Nezhinsky <alexandern@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
iscsi: show iscsi initiator alias

Store iscsi initiator alias in connection, copy it to iscsi session,
show it in session info.

Signed-off-by: Alexander Nezhinsky <alexandern@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
sbc: fix compiler warning in synchronize cache

In sbc.c implementation of synchronize cache, set resid to 0
unconditionally and remove unused len=0, as const zero is used in set
resid.

Signed-off-by: Alexander Nezhinsky <alexandern@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
improve str_to_int macro

There is a potential problem when a user-supplied value overflows the
accepting variable; to cope with this the string is converted to a
64-bit value first then assigned to the variable, then the macro
checks if they represent the same value. Thus the natural type
boundaries are automatically guarded. This means that there is no need
to use type's range limits (e.g. 0 and USHRT_MAX for unsigned
short). Thus the range limit parameters are removed from str_to_int()
-- it's enough for the (most frequent) cases when any value fitting a
certain integer type is admissible. When the min/max values are
relevant they can be passed to one of the new macros str_to_int_gt,
str_to_int_ge, str_to_int_lt, str_to_int_range, requiring that the int
value should be greater than, greater or equal, less than, or within a
range, correspondingly.

Signed-off-by: Alexander Nezhinsky <alexandern@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
iser: Fix "set but not used" compile warning

Fix "set but not used" warning in iser.c: comment out irdsl related
lines; irdsl value is not used meanwhile, as we use a shortcut to
cover up an initiator glitch

Signed-off-by: Alexander Nezhinsky <alexandern@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
return TGTADM_SUCCESS if adding Unit Attention sense fails upon target destroy

If adding Unit Attention sense fails upon target destroy, just print
error message and still return TGTADM_SUCCESS.

Signed-off-by: Alexander Nezhinsky <alexandern@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_aio: use 64bit to read eventfd counter

when using eventfd, each time the fd becomes readable, the number of
io completions can be read; this number is provided as a 64-bit
integer, thus enough space (at least 8 bytes) should be given to
read(). This patch adds a comment which explicitely states the above
requirement. The actual number of completions in bs_aio is limited by
a very small value, thus when reading, a 64-bit variable should be
used, then it can be casted to unsigned int and processed as such.

Signed-off-by: Alexander Nezhinsky <alexandern@mellanox.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>