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:
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
19
lib/socket.c
19
lib/socket.c
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user