Add a new "iscsi_queue_length()" which will tell us how many commands

are in flight at the moment.
Aside from commands, we also consider the "has not yet connected completely" as being an i/o.

When this command returns 0 it means we are connected ant the iscsi connection is idle, with no commands in flight.

KVM needs a function to detect idleness like this for its block layer io_flush
function.
This commit is contained in:
Ronnie Sahlberg
2011-02-03 19:08:16 +11:00
parent d22a2aee3c
commit c29b9a2aae
2 changed files with 23 additions and 0 deletions

View File

@@ -47,6 +47,10 @@ int iscsi_which_events(struct iscsi_context *iscsi);
* file descriptor.
*/
int iscsi_service(struct iscsi_context *iscsi, int revents);
/*
* How many commands are in flight.
*/
int iscsi_queue_length(struct iscsi_context *iscsi);

View File

@@ -188,6 +188,25 @@ iscsi_which_events(struct iscsi_context *iscsi)
return events;
}
int
iscsi_queue_length(struct iscsi_context *iscsi)
{
int i = 0;
struct iscsi_pdu *pdu;
for (pdu = iscsi->outqueue; pdu; pdu = pdu->next) {
i++;
}
for (pdu = iscsi->waitpdu; pdu; pdu = pdu->next) {
i++;
}
if (iscsi->is_connected == 0) {
i++;
}
return i;
}
static int
iscsi_read_from_socket(struct iscsi_context *iscsi)
{