Commit Graph

56 Commits

Author SHA1 Message Date
Edward Tomasz Napierala
938bcb04fc Fix iSCSI initiator crash that could happen with out-of-memory
conditions with in-flight IO and subsequent reconnection.

PR:		199117
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5673
2016-03-25 16:01:40 +00:00
Edward Tomasz Napierala
e204e2cd93 Add lock assertion.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-03-18 13:26:16 +00:00
Steven Hartland
481b36c66a Close iSCSI sessions on shutdown
Ensure that all iSCSI sessions are correctly terminated during shutdown.

* Enhances the changes done by r286226 (D3052).
* Add shutdown post sync event to run after filesystem shutdown
  (SHUTDOWN_PRI_FIRST) but before CAM shutdown (SHUTDOWN_PRI_DEFAULT).
* Changes iscsi_maintenance_thread to processes terminate in preference to
  reconnect.

Reviewed by:	trasz
MFC after:	2 weeks
Sponsored by:	Multiplay
Differential Revision:	https://reviews.freebsd.org/D4429
2016-01-11 10:24:30 +00:00
Navdeep Parhar
1e86840331 MFP r291227, r291228, and r292618.
r291227:
s/is->is_conn/ic to shorten things a bit.

r291228:
Do not generate PDUs with payload greater than max_data_segment_length.

It is perhaps preferable to have a separate limit for send instead of
reusing the receive limit.  I'll discuss with trasz@ and mav@ before
pulling this into head.

r292618:
Add comment to go with r291228.
2015-12-24 02:35:59 +00:00
Navdeep Parhar
c8b73c2cc7 Add comment to go with r291228.
Submitted by:	trasz@
2015-12-22 20:03:49 +00:00
Steven Hartland
c82d74037f Fix panic on shutdown due to iscsi event priority
iscsi's shutdown_pre_sync prio was SHUTDOWN_PRI_FIRST which caused it to
run before other high priority handlers such as filesystems e.g. ZFS.

This meant the iscsi sessions where removed before the ZFS geom consumer
was closed, resulting in a panic from g_access calls on debug kernels
due to negative acr.

Instead use the same as the old iscsi_initiator SHUTDOWN_PRI_DEFAULT-1
which allows it to run before dashutdown etc but after filesystems.

MFC after:	2 weeks
Sponsored by:	Multiplay
2015-12-07 02:56:08 +00:00
Navdeep Parhar
7ceec7e48d Do not generate PDUs with payload greater than max_data_segment_length.
It is perhaps preferable to have a separate limit for send instead of
reusing the receive limit.  I'll discuss with trasz@ and mav@ before
pulling this into head.
2015-11-24 01:12:17 +00:00
Navdeep Parhar
f5cadbc463 s/is->is_conn/ic to shorten things a bit. 2015-11-24 01:07:57 +00:00
Edward Tomasz Napierala
e553ca4994 Rework the way iSCSI initiator handles system shutdown. This fixes
hangs on shutdown with LUNs with mounted filesystems over a disconnected
iSCSI session.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3052
2015-08-03 11:57:11 +00:00
Edward Tomasz Napierala
7a03d007cf Extend ICL to add receive offload methods. For software ICL backend
they are no-ops.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-08 19:15:14 +00:00
Edward Tomasz Napierala
674074da06 Don't call callout_drain() with iscsi mutex held; this fixes a warning
that was introduced recently.  While here, don't try to access is_terminating
without lock.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-05 07:46:34 +00:00
Edward Tomasz Napierala
09f2b94bf4 Fix error handling.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-05 07:16:45 +00:00
Edward Tomasz Napierala
82babffba9 Make it possible to set (via iscsi.conf(5)) and query (via iscsictl -v)
initiator iSCSI offload.  Pass maximum data segment size supported by
chosen offload module to iscsid(8), and make iscsid(8) not try to negotiate
anything larger than that.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-05 06:37:59 +00:00
Edward Tomasz Napierala
321b17ec15 Add kobj interface between ICL and the rest of the iSCSI stack.
Review note - icl.c was moved to icl_soft.c.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-01-31 07:49:50 +00:00
Alexander Motin
3f9e1172b7 Slightly polish iSCSI parameters negotiation.
MFC after:	1 week
2014-12-19 01:12:22 +00:00
Alexander Motin
2124e3b07f Make sequence numbers checks more strict.
While we don't support MCS, hole in received sequence numbers may mean
only PDU loss.  While we don't support lost PDU recovery, terminate the
connection to avoid stuck commands.

While there, improve handling of sequence numbers wrap after 2^32 PDUs.

MFC after:	2 weeks
2014-12-17 15:13:21 +00:00
Alexander Motin
73e2e95d94 Fix use-after-free introduced in r274843.
I've missed that iscsi_outstanding_remove() frees the second pointer,
so it should no longer be used.  And in fact we don't really need to.

MFC after:	2 weeks
2014-11-22 09:45:32 +00:00
Alexander Motin
c215ad3aa8 Move icl_pdu_get_data() and xpt_done() out of initiator's session lock.
During heavy reads data copying in icl_pdu_get_data() may consume large
percent of CPU time.  Moving it out of the lock significantly reduces
lock hold time and respectively lock congestion on read operations.

MFC after:	2 weeks
2014-11-22 09:05:54 +00:00
Edward Tomasz Napierala
d2d52b0013 s/icl_pdu_new_bhs/icl_pdu_new/; no functional changes, just a little
nicer code.

Sponsored by:	The FreeBSD Foundation
2014-11-03 11:15:51 +00:00
Edward Tomasz Napierala
6cc1e267f3 When removing an iSCSI session, check whether all conditions match,
not if any of them matches.  This fixes "iscsictl -Rn" removing
unrelated sessions.

PR:		194034
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-10-16 09:09:43 +00:00
Alexander Motin
259f12da87 Make iSCSI connection close somewhat less aggressive.
It allows to push out some final data from the send queue to the socket
before its close.  In particular, it increases chances for logout response
to be delivered to the initiator.
2014-10-09 09:12:08 +00:00
Edward Tomasz Napierala
17cf3eb152 Fix LUN discovery for targets that don't support REPORT_LUNS, broken
in r263741.  At least with CTL (slightly modified to report SPC2) there
is still some problem: it doesn't seem to find LUNs higher than 7.

Sponsored by:	The FreeBSD Foundation
2014-09-17 07:55:23 +00:00
Edward Tomasz Napierala
2c5b89e54b Make sure we handle less than zero timeouts in iSCSI initiator and target
in a reasonable way.

Sponsored by:	The FreeBSD Foundation
2014-09-10 14:04:10 +00:00
Edward Tomasz Napierala
ddc5fd903d Use proper include paths in kernel iSCSI code.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-08-21 16:08:17 +00:00
Edward Tomasz Napierala
b7a65e3936 Make the iSCSI stack use __FBSDID() properly.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-08-21 15:32:38 +00:00
Alexander Motin
aa75114c57 Add XPT_ABORT support to iSCSI initiator.
While CAM does not use it normally, it is useful for targets testing.

MFC after:	2 weeks
2014-07-08 09:37:41 +00:00
Alexander Motin
462cf3ba2a Make XPT_GET_TRAN_SETTINGS to report CAM that command queueing is enabled,
but make couple changes to handle non-queued commands too, if happen.

MFC after:	2 weeks
2014-07-07 17:34:48 +00:00
Alexander Motin
ffe82e05b3 Make iSCSI initiator keep Initiator Session ID (ISID) across reconnects.
Previously ISID was changed every time, that made impossible correct
persistent reservation, because reconnected session was identified as
completely new one.

Reviewed by:	trasz
MFC after:	1 week
2014-07-06 17:37:49 +00:00
Hans Petter Selasky
af3b2549c4 Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
Glen Barber
37a107a407 Revert r267961, r267973:
These changes prevent sysctl(8) from returning proper output,
such as:

 1) no output from sysctl(8)
 2) erroneously returning ENOMEM with tools like truss(1)
    or uname(1)
 truss: can not get etype: Cannot allocate memory
2014-06-27 22:05:21 +00:00
Hans Petter Selasky
3da1cf1e88 Extend the meaning of the CTLFLAG_TUN flag to automatically check if
there is an environment variable which shall initialize the SYSCTL
during early boot. This works for all SYSCTL types both statically and
dynamically created ones, except for the SYSCTL NODE type and SYSCTLs
which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to
be used in the case a tunable sysctl has a custom initialisation
function allowing the sysctl to still be marked as a tunable. The
kernel SYSCTL API is mostly the same, with a few exceptions for some
special operations like iterating childrens of a static/extern SYSCTL
node. This operation should probably be made into a factored out
common macro, hence some device drivers use this. The reason for
changing the SYSCTL API was the need for a SYSCTL parent OID pointer
and not only the SYSCTL parent OID list pointer in order to quickly
generate the sysctl path. The motivation behind this patch is to avoid
parameter loading cludges inside the OFED driver subsystem. Instead of
adding special code to the OFED driver subsystem to post-load tunables
into dynamically created sysctls, we generalize this in the kernel.

Other changes:
- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"
to "hw.pcic.intr_mask".
- Removed redundant TUNABLE statements throughout the kernel.
- Some minor code rewrites in connection to removing not needed
TUNABLE statements.
- Added a missing SYSCTL_DECL().
- Wrapped two very long lines.
- Avoid malloc()/free() inside sysctl string handling, in case it is
called to initialize a sysctl from a tunable, hence malloc()/free() is
not ready when sysctls from the sysctl dataset are registered.
- Bumped FreeBSD version to indicate SYSCTL API change.

MFC after:	2 weeks
Sponsored by:	Mellanox Technologies
2014-06-27 16:33:43 +00:00
Edward Tomasz Napierala
51be90b522 Implement redirection handling in initiator.
Sponsored by:	The FreeBSD Foundation
2014-06-18 17:35:40 +00:00
Edward Tomasz Napierala
57a4f20b8d Make it possible for the initiator side to operate in both proxy
and normal mode; this makes it possible to compile with the former
by default, but use it only when neccessary.  That's especially
important for the userland part.

Sponsored by:	The FreeBSD Foundation
2014-04-16 18:23:36 +00:00
Edward Tomasz Napierala
f1f12e40e6 Add kern.iscsi.fail_on_disconnection; this is required for gmultipath
to work.

Sponsored by:	The FreeBSD Foundation
2014-04-16 17:39:10 +00:00
Edward Tomasz Napierala
0341c3e1c7 Remove useless debug.
Sponsored by:	The FreeBSD Foundation
2014-04-16 11:28:38 +00:00
Edward Tomasz Napierala
2be596ad38 Be more strict with locking for is_waiting_for_iscsid variable.
Sponsored by:	The FreeBSD Foundation
2014-04-16 11:28:05 +00:00
Edward Tomasz Napierala
d24546759e Get rid of ISCSIDCLOSE; it wasn't used and is redundant anyway,
because of ISCSIDFAIL.

Sponsored by:	The FreeBSD Foundation
2014-04-16 11:19:49 +00:00
Edward Tomasz Napierala
2ebde326cb Add some stuff to make it easier to figure out for the system administrator
whether the ICL_KERNEL_PROXY stuff got compiled in correctly.

Sponsored by:	The FreeBSD Foundation
2014-04-16 10:18:44 +00:00
Alexander Motin
1f6b2af297 Remove unused val argument value from SYSCTL_INT() calls. 2014-04-11 20:44:09 +00:00
Edward Tomasz Napierala
605a34b065 All the iSCSI sysctls are also tunables; advertise that.
Sponsored by:	The FreeBSD Foundation
2014-04-04 08:48:55 +00:00
Edward Tomasz Napierala
16c158a562 We don't need TAILQ for iSCSI PDUs; STAILQ is enough.
Sponsored by:	The FreeBSD Foundation
2014-04-04 08:43:23 +00:00
Edward Tomasz Napierala
ecba49ddfc Instead of "icltx" and "iclrx", use thread names with prefix from upper
layer, so that one can see which side of the stack the threads are for.

Sponsored by:	The FreeBSD Foundation
2014-04-01 21:47:22 +00:00
Edward Tomasz Napierala
6ed8f5d236 Get rid of ICL lock; use upper-layer (initiator or target) lock instead.
This avoids extra locking in icl_pdu_queue(); the upper layer needs to call
it while holding its own lock anyway, to avoid sending PDUs out of order.

Sponsored by:	The FreeBSD Foundation
2014-04-01 21:40:46 +00:00
Edward Tomasz Napierala
cf23c509ed Fix harmless warning after reconnecting a session and not doing anything
with it.

Sponsored by:	The FreeBSD Foundation
2014-03-25 19:09:52 +00:00
Edward Tomasz Napierala
a9f2f291d3 Use newly added extended LUN support in CAM.
Sponsored by:	The FreeBSD Foundation
2014-03-25 19:05:05 +00:00
Edward Tomasz Napierala
b1277ad1f7 Use a less unusual syntax in debug printfs.
Sponsored by:	The FreeBSD Foundation
2014-03-25 18:30:57 +00:00
Edward Tomasz Napierala
0260023fbb Properly refuse handoff requests on already connected sessions. Previously
this would result in dropping the session.

MFC after:	2 days
Sponsored by:	The FreeBSD Foundation
2013-12-10 18:18:39 +00:00
Edward Tomasz Napierala
c4dfe4abe2 Fix hang on reboot with active iSCSI connections.
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2013-12-01 08:13:10 +00:00
Edward Tomasz Napierala
69647b7bcd Properly handle residual count in Data-In PDUs with S bit set.
Approved by:	re (gjb)
Sponsored by:	FreeBSD Foundation
2013-10-09 20:09:58 +00:00
Edward Tomasz Napierala
d43c9ec118 Be extra paranoid with values obtained from the target.
Approved by:	re (glebius)
Sponsored by:	FreeBSD Foundation
2013-10-09 19:30:13 +00:00