From 9d6f0690f8bf16b596eacdd6775acae852e9cc8c Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Fri, 27 Mar 2015 11:08:37 +0100 Subject: [PATCH] iscsi-perf: add NOPs to the perf stream and account for timeouts Signed-off-by: Peter Lieven --- utils/iscsi-perf.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/utils/iscsi-perf.c b/utils/iscsi-perf.c index a9a84c3..ed10e11 100644 --- a/utils/iscsi-perf.c +++ b/utils/iscsi-perf.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "iscsi.h" #include "scsi-lowlevel.h" @@ -33,7 +34,11 @@ #define VERSION "0.1" +#define NOP_INTERVAL 5 +#define MAX_NOP_FAILURES 3 + const char *initiator = "iqn.2010-11.libiscsi:iscsi-perf"; +int proc_alarm = 0; int max_in_flight = 32; int blocks_per_io = 8; uint64_t runtime = 0; @@ -202,8 +207,17 @@ void usage(void) { exit(1); } -void sig_handler (int signum _U_) { - finished = 1; +void sig_handler (int signum ) { + if (signum == SIGALRM) { + if (proc_alarm) { + fprintf(stderr, "\n\nABORT: Last alarm was not processed.\n"); + exit(10); + } + proc_alarm = 1; + alarm(NOP_INTERVAL); + } else { + finished = 1; + } } int main(int argc, char *argv[]) @@ -340,6 +354,7 @@ int main(int argc, char *argv[]) sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); + sigaction(SIGALRM, &sa, NULL); printf("\n"); @@ -347,10 +362,21 @@ int main(int argc, char *argv[]) fill_read_queue(&client); + alarm(NOP_INTERVAL); + while (client.in_flight && !client.err_cnt) { pfd[0].fd = iscsi_get_fd(client.iscsi); pfd[0].events = iscsi_which_events(client.iscsi); + if (proc_alarm) { + if (iscsi_get_nops_in_flight(client.iscsi) > MAX_NOP_FAILURES) { + fprintf(stderr, "\n\nABORT: NOP timeout.\n"); + exit(10); + } + iscsi_nop_out_async(client.iscsi, NULL, NULL, 0, NULL); + proc_alarm = 0; + } + if (poll(&pfd[0], 1, -1) < 0) { continue; } @@ -359,6 +385,8 @@ int main(int argc, char *argv[]) break; } } + + alarm(0); progress(&client);