Add a feature to request transparent reconnects without any UA
Normal applications want the current behaviour where we have the library consume any/all of the UnitAttentions that the target may have queued on the initial connection, but when we reconnect the session after a failure the library will pass all the UAs back to the application to process. Some applications, such as the test suite or really trivial applications might not want to have to deal with handling of UAs and just "make it work". Those applications can now request that upon any reconnection of the session that libiscsi will automatically consume any and all UAs and hide them from the application. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -130,7 +130,11 @@ iscsi_login_cb(struct iscsi_context *iscsi, int status, void *command_data _U_,
|
||||
return;
|
||||
}
|
||||
|
||||
if (ct->lun != -1 && !iscsi->old_iscsi) {
|
||||
/* If the application has requested no UA on reconnect OR if this is
|
||||
the initial connection attempt then we need to consume any/all
|
||||
UAs that might be present.
|
||||
*/
|
||||
if (iscsi->no_ua_on_reconnect || (ct->lun != -1 && !iscsi->old_iscsi)) {
|
||||
if (iscsi_testunitready_task(iscsi, ct->lun,
|
||||
iscsi_testunitready_cb, ct) == NULL) {
|
||||
iscsi_set_error(iscsi, "iscsi_testunitready_async failed.");
|
||||
@@ -210,6 +214,18 @@ void iscsi_set_noautoreconnect(struct iscsi_context *iscsi, int state)
|
||||
}
|
||||
}
|
||||
|
||||
/* Set ua reconnect status. The default is that we just reconnect and then
|
||||
any/all UAs that are generated by the target will be passed back to the
|
||||
application.
|
||||
|
||||
For test applications it can be more convenient to just reconnect
|
||||
and have any UAs be consumed and ignored by the library.
|
||||
*/
|
||||
void iscsi_set_no_ua_on_reconnect(struct iscsi_context *iscsi, int state)
|
||||
{
|
||||
iscsi->no_ua_on_reconnect = state;
|
||||
}
|
||||
|
||||
void iscsi_set_reconnect_max_retries(struct iscsi_context *iscsi, int count)
|
||||
{
|
||||
iscsi->reconnect_max_retries = count;
|
||||
@@ -413,6 +429,7 @@ int iscsi_reconnect(struct iscsi_context *old_iscsi)
|
||||
iscsi->tcp_syncnt = old_iscsi->tcp_syncnt;
|
||||
iscsi->cache_allocations = old_iscsi->cache_allocations;
|
||||
iscsi->scsi_timeout = old_iscsi->scsi_timeout;
|
||||
iscsi->no_ua_on_reconnect = old_iscsi->no_ua_on_reconnect;
|
||||
|
||||
iscsi->reconnect_max_retries = old_iscsi->reconnect_max_retries;
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ iscsi_set_isid_en
|
||||
iscsi_set_isid_oui
|
||||
iscsi_set_isid_random
|
||||
iscsi_set_isid_reserved
|
||||
iscsi_set_no_ua_on_reconnect
|
||||
iscsi_set_session_type
|
||||
iscsi_set_target_username_pwd
|
||||
iscsi_set_targetname
|
||||
|
||||
@@ -96,6 +96,7 @@ iscsi_set_isid_en
|
||||
iscsi_set_isid_oui
|
||||
iscsi_set_isid_random
|
||||
iscsi_set_isid_reserved
|
||||
iscsi_set_no_ua_on_reconnect
|
||||
iscsi_set_session_type
|
||||
iscsi_set_target_username_pwd
|
||||
iscsi_set_targetname
|
||||
|
||||
Reference in New Issue
Block a user