diff --git a/configure.ac b/configure.ac index 1d28579..ba9c8a4 100644 --- a/configure.ac +++ b/configure.ac @@ -128,6 +128,9 @@ AC_CHECK_MEMBER([struct CU_SuiteInfo.pSetUpFunc], #include ]]) +AC_SEARCH_LIBS(clock_gettime, rt, [ + AC_DEFINE([HAVE_CLOCK_GETTIME],1,[Define if clock_gettime is available])]) + AC_CONFIG_FILES([Makefile] [lib/Makefile] diff --git a/test-tool/test_preventallow_cold_reset.c b/test-tool/test_preventallow_cold_reset.c index a604b2e..3f8da1e 100644 --- a/test-tool/test_preventallow_cold_reset.c +++ b/test-tool/test_preventallow_cold_reset.c @@ -61,7 +61,8 @@ test_preventallow_cold_reset(void) logging(LOG_VERBOSE, "Perform cold reset on target"); ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx); logging(LOG_VERBOSE, "Wait until all unit attentions clear"); - while (testunitready(sd, EXPECT_STATUS_GOOD) != 0); + while (testunitready(sd, EXPECT_STATUS_GOOD) != 0) + ; CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_preventallow_lun_reset.c b/test-tool/test_preventallow_lun_reset.c index f7c0502..ae5c3db 100644 --- a/test-tool/test_preventallow_lun_reset.c +++ b/test-tool/test_preventallow_lun_reset.c @@ -62,7 +62,8 @@ test_preventallow_lun_reset(void) ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Wait until all unit attentions clear"); - while (testunitready(sd, EXPECT_STATUS_GOOD) != 0); + while (testunitready(sd, EXPECT_STATUS_GOOD) != 0) + ; logging(LOG_VERBOSE, "Try to eject the medium"); diff --git a/test-tool/test_preventallow_warm_reset.c b/test-tool/test_preventallow_warm_reset.c index 42604d1..cb0970a 100644 --- a/test-tool/test_preventallow_warm_reset.c +++ b/test-tool/test_preventallow_warm_reset.c @@ -62,7 +62,8 @@ test_preventallow_warm_reset(void) ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Wait until all unit attentions clear"); - while (testunitready(sd, EXPECT_STATUS_GOOD) != 0); + while (testunitready(sd, EXPECT_STATUS_GOOD) != 0) + ; logging(LOG_VERBOSE, "Try to eject the medium"); diff --git a/utils/Makefile.am b/utils/Makefile.am index 30e34ba..6624880 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -1,6 +1,6 @@ -AM_CPPFLAGS=-I../include "-D_U_=__attribute__((unused))" \ +AM_CPPFLAGS = -I../include "-D_U_=__attribute__((unused))" \ "-D_R_(A,B)=__attribute__((format(printf,A,B)))" -AM_CFLAGS=$(WARN_CFLAGS) -lrt +AM_CFLAGS = $(WARN_CFLAGS) LDADD = ../lib/libiscsi.la bin_PROGRAMS = iscsi-inq iscsi-ls iscsi-perf iscsi-readcapacity16 \ diff --git a/utils/iscsi-perf.c b/utils/iscsi-perf.c index e7c3aa7..45c5b09 100644 --- a/utils/iscsi-perf.c +++ b/utils/iscsi-perf.c @@ -27,6 +27,10 @@ #include "iscsi.h" #include "scsi-lowlevel.h" +#ifndef HAVE_CLOCK_GETTIME +#include +#endif + #define VERSION "0.1" const char *initiator = "iqn.2010-11.libiscsi:iscsi-perf"; @@ -55,12 +59,23 @@ struct client { }; u_int64_t get_clock_ns(void) { - struct timespec tp; - if (clock_gettime (CLOCK_MONOTONIC, &tp) == -1) { - fprintf(stderr,"could not get clock monotonic\n"); + int res; + u_int64_t ns; + +#ifdef HAVE_CLOCK_GETTIME + struct timespec ts; + res = clock_gettime (CLOCK_MONOTONIC, &tp); + ns = ts.tv_sec * 1000000000 + ts.tv_nsec; +#else + struct timeval tv; + res = gettimeofday(&tv, NULL); + ns = tv.tv_sec * 1000000000 + tv.tv_usec * 1000; +#endif + if (res == -1) { + fprintf(stderr,"could not get requested clock\n"); exit(10); } - return tp.tv_sec*1000000000+tp.tv_nsec; + return ns; } void fill_read_queue(struct client *client); @@ -76,12 +91,12 @@ void progress(struct client *client) { uint64_t aiops = 1000000000UL * (client->iops) / (now - client->first_ns); if (!_runtime) { finished = 1; - printf ("iops average %lu (%lu MB/s) ", aiops, (aiops * blocks_per_io * client->blocksize) >> 20); + printf ("iops average %llu (%llu MB/s) ", aiops, (aiops * blocks_per_io * client->blocksize) >> 20); } else { uint64_t iops = 1000000000UL * (client->iops - client->last_iops) / (now - client->last_ns); - printf ("%02lu:%02lu:%02lu - ", (_runtime % 3600) / 60, _runtime / 60, _runtime % 60); - printf ("lba %lu, iops current %lu (%lu MB/s), ", client->pos, iops, (iops * blocks_per_io * client->blocksize) >> 20); - printf ("iops average %lu (%lu MB/s) ", aiops, (aiops * blocks_per_io * client->blocksize) >> 20); + printf ("%02llu:%02llu:%02llu - ", (_runtime % 3600) / 60, _runtime / 60, _runtime % 60); + printf ("lba %llu, iops current %llu (%llu MB/s), ", client->pos, iops, (iops * blocks_per_io * client->blocksize) >> 20); + printf ("iops average %llu (%llu MB/s) ", aiops, (aiops * blocks_per_io * client->blocksize) >> 20); } fflush(stdout); client->last_ns = now; @@ -274,14 +289,14 @@ int main(int argc, char *argv[]) scsi_free_scsi_task(task); - printf("capacity is %lu blocks or %lu byte (%lu MB)\n", client.num_blocks, client.num_blocks * client.blocksize, + printf("capacity is %llu blocks or %llu byte (%llu MB)\n", client.num_blocks, client.num_blocks * client.blocksize, (client.num_blocks * client.blocksize) >> 20); printf("performing %s READ with %d parallel requests\nfixed transfer size of %d blocks (%d byte)\n", client.random ? "random" : "sequential", max_in_flight, blocks_per_io, blocks_per_io * client.blocksize); if (runtime) { - printf("will run for %lu seconds.\n", runtime); + printf("will run for %llu seconds.\n", runtime); } else { printf("infinite runtime - press CTRL-C to abort.\n"); }