NOP count in flight of client generated NOP-Outs

This patch adds the abilitiy to libiscsi to count the number
of consecutive outstanding NOPs.

With this ability its fairly easy to implement a keepalive
check with NOPs in your application.

Periodically (e.g. every 5 secs) create a NOP-Out with:

iscsi_nop_out_async(iscsi, NULL, NULL, 0, NULL);

At that time check the number of consecutive missing NOP-Ins
with

iscsi_get_nops_in_flight(iscsi) > N.

Where N is the number of missing NOP-Ins you will allow.
Please note that it is legitime for the Target to ignore
a NOP if the load is very high as those packet are mark
as IMMEDIATE.

Signed-off-by: Peter Lieven <pl@kamp.de>
This commit is contained in:
Peter Lieven
2012-12-06 10:03:01 +01:00
parent d1344a666b
commit 237729545a
5 changed files with 26 additions and 1 deletions

View File

@@ -95,6 +95,7 @@ struct iscsi_context {
int is_loggedin;
int is_reconnecting;
int bind_interfaces_cnt;
int nops_in_flight;
int chap_a;
int chap_i;
@@ -122,7 +123,7 @@ struct iscsi_context {
int no_auto_reconnect;
int reconnect_deferred;
int reconnect_max_retries;
int log_level;
iscsi_log_fn log_fn;

View File

@@ -35,6 +35,7 @@ struct sockaddr;
/* FEATURES */
#define LIBISCSI_FEATURE_IOVECTOR (1)
#define LIBISCSI_FEATURE_NOP_COUNTER (1)
#define MAX_STRING_SIZE (255)
@@ -474,10 +475,17 @@ struct iscsi_discovery_address {
* structure containing the data returned from
* the server.
* ISCSI_STATUS_CANCELLED: Discovery was aborted. Command_data is NULL.
*
* The callback may be NULL if you only want to let libiscsi count the in-flight
* NOPs.
*/
EXTERN int iscsi_nop_out_async(struct iscsi_context *iscsi, iscsi_command_cb cb,
unsigned char *data, int len, void *private_data);
/* read out the number of consecutive nop outs that did not receive an answer */
EXTERN int iscsi_get_nops_in_flight(struct iscsi_context *iscsi);
struct scsi_task;
enum iscsi_task_mgmt_funcs {