The following changes since commit c97f1ad6d2a2fb4fe9f3b15e40158aac21e5699e: Fix usr/sys/ctx/majf/minf for -USR1 usage (2013-03-28 15:08:49 -0600) are available in the git repository at: git://git.kernel.dk/fio.git master Bruce Cran (2): Fix rwlock error messages to specify the correct function names. Workaround pthreads-win32 pthread_rwlock_init limitation. Jens Axboe (5): configure: fixup build so that it's more resilient axmap: fix bug with max_bs/min_bs ratio being > 64 t/axmap: add test for multi bit sets axmap: get rid of old debug ->fail_ok checking parse: fix misparse of bs=64k-128k Makefile | 16 +++++----- configure | 8 ++-- lib/axmap.c | 32 ++++++++++++++----- mutex.c | 9 ++++-- parse.c | 20 +++++++++++- t/axmap.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 6 files changed, 146 insertions(+), 35 deletions(-) --- Diff of recent changes: diff --git a/Makefile b/Makefile index ea96a89..27e82c6 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,3 @@ -DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG -CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS) -OPTFLAGS= -O3 -g -ffast-math $(EXTFLAGS) -CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) -LIBS = -lm $(EXTLIBS) -PROGS = fio -SCRIPTS = fio_generate_plots - ifneq ($(wildcard config-host.mak),) all: include config-host.mak @@ -20,6 +12,14 @@ all: include config-host.mak endif +DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG +CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS) +OPTFLAGS= -O3 -g -ffast-math +CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS) +LIBS += -lm $(EXTLIBS) +PROGS = fio +SCRIPTS = fio_generate_plots + SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \ eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \ rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \ diff --git a/configure b/configure index 836d7ad..a3c51fb 100755 --- a/configure +++ b/configure @@ -38,8 +38,8 @@ fatal() { } # Default CFLAGS -CFLAGS="-D_GNU_SOURCE" -EXTFLAGS="-include config-host.h" +CFLAGS="-D_GNU_SOURCE -include config-host.h" +BUILD_CFLAGS="" # Print a helpful header at the top of config.log echo "# FIO configure log $(date)" >> config.log @@ -230,7 +230,7 @@ CYGWIN*) output_sym "CONFIG_SCHED_IDLE" output_sym "CONFIG_TCP_NODELAY" echo "CC=$CC" >> $config_host_mak - echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak + echo "BUILD_CFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak exit 0 ;; esac @@ -1088,4 +1088,4 @@ fi echo "LIBS+=$LIBS" >> $config_host_mak echo "CC=$cc" >> $config_host_mak -echo "EXTFLAGS=$EXTFLAGS $CFLAGS" >> $config_host_mak +echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak diff --git a/lib/axmap.c b/lib/axmap.c index eeb32d4..c9f3a4f 100644 --- a/lib/axmap.c +++ b/lib/axmap.c @@ -189,7 +189,6 @@ void axmap_clear(struct axmap *axmap, uint64_t bit_nr) struct axmap_set_data { unsigned int nr_bits; unsigned int set_bits; - unsigned int fail_ok; }; static unsigned long bit_masks[] = { @@ -229,10 +228,8 @@ static int axmap_set_fn(struct axmap_level *al, unsigned long offset, * Mask off any potential overlap, only sets contig regions */ overlap = al->map[offset] & mask; - if (overlap == mask) { - assert(data->fail_ok); + if (overlap == mask) return 1; - } while (overlap) { unsigned long clear_mask = ~(1UL << ffz(~overlap)); @@ -273,14 +270,14 @@ static void __axmap_set(struct axmap *axmap, uint64_t bit_nr, axmap_handler(axmap, bit_nr, axmap_set_fn, data); set_bits += data->set_bits; - if (data->set_bits != (BLOCKS_PER_UNIT - nr_bits)) + if (!data->set_bits || + data->set_bits != (BLOCKS_PER_UNIT - nr_bits)) break; nr_bits -= data->set_bits; bit_nr += data->set_bits; data->nr_bits = nr_bits; - data->fail_ok = 1; } data->set_bits = set_bits; @@ -295,10 +292,27 @@ void axmap_set(struct axmap *axmap, uint64_t bit_nr) unsigned int axmap_set_nr(struct axmap *axmap, uint64_t bit_nr, unsigned int nr_bits) { - struct axmap_set_data data = { .nr_bits = nr_bits, }; + unsigned int set_bits = 0; - __axmap_set(axmap, bit_nr, &data); - return data.set_bits; + do { + struct axmap_set_data data = { .nr_bits = nr_bits, }; + unsigned int max_bits, this_set; + + max_bits = BLOCKS_PER_UNIT - (bit_nr & BLOCKS_PER_UNIT_MASK); + if (max_bits < nr_bits) + data.nr_bits = max_bits; + + this_set = data.nr_bits; + __axmap_set(axmap, bit_nr, &data); + set_bits += data.set_bits; + if (data.set_bits != this_set) + break; + + nr_bits -= data.set_bits; + bit_nr += data.set_bits; + } while (nr_bits); + + return set_bits; } static int axmap_isset_fn(struct axmap_level *al, unsigned long offset, diff --git a/mutex.c b/mutex.c index 5a65e53..e1fbb60 100644 --- a/mutex.c +++ b/mutex.c @@ -196,18 +196,21 @@ struct fio_rwlock *fio_rwlock_init(void) ret = pthread_rwlockattr_init(&attr); if (ret) { - log_err("pthread_rwlock_init: %s\n", strerror(ret)); + log_err("pthread_rwlockattr_init: %s\n", strerror(ret)); goto err; } #ifdef FIO_HAVE_PSHARED_MUTEX ret = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); if (ret) { - log_err("pthread_rwlock_init: %s\n", strerror(ret)); + log_err("pthread_rwlockattr_setpshared: %s\n", strerror(ret)); goto destroy_attr; } -#endif ret = pthread_rwlock_init(&lock->lock, &attr); +#else + ret = pthread_rwlock_init(&lock->lock, NULL); +#endif + if (ret) { log_err("pthread_rwlock_init: %s\n", strerror(ret)); goto destroy_attr; diff --git a/parse.c b/parse.c index 51cefca..5b8e10f 100644 --- a/parse.c +++ b/parse.c @@ -140,6 +140,19 @@ static unsigned long get_mult_time(char c) } } +static int is_separator(char c) +{ + switch (c) { + case ':': + case '-': + case ',': + case '/': + return 1; + default: + return 0; + } +} + static unsigned long long __get_mult_bytes(const char *p, void *data, int *percent) { @@ -153,8 +166,13 @@ static unsigned long long __get_mult_bytes(const char *p, void *data, c = strdup(p); - for (i = 0; i < strlen(c); i++) + for (i = 0; i < strlen(c); i++) { c[i] = tolower(c[i]); + if (is_separator(c[i])) { + c[i] = '\0'; + break; + } + } if (!strcmp("pib", c)) { pow = 5; diff --git a/t/axmap.c b/t/axmap.c index 7ab500f..57c585b 100644 --- a/t/axmap.c +++ b/t/axmap.c @@ -18,49 +18,125 @@ void sfree(void *ptr) free(ptr); } -int main(int argc, char *argv[]) +static int test_regular(size_t size, int seed) { struct fio_lfsr lfsr; - size_t osize, size = (1UL << 28) - 200; struct axmap *map; + size_t osize; uint64_t ff; - int seed = 1; + int err; - if (argc > 1) { - size = strtoul(argv[1], NULL, 10); - if (argc > 2) - seed = strtoul(argv[2], NULL, 10); - } - - printf("Using %llu entries\n", (unsigned long long) size); + printf("Using %llu entries...", (unsigned long long) size); + fflush(stdout); lfsr_init(&lfsr, size, seed, seed & 0xF); map = axmap_new(size); osize = size; + err = 0; while (size--) { uint64_t val; if (lfsr_next(&lfsr, &val, osize)) { printf("lfsr: short loop\n"); + err = 1; break; } if (axmap_isset(map, val)) { printf("bit already set\n"); + err = 1; break; } axmap_set(map, val); if (!axmap_isset(map, val)) { printf("bit not set\n"); + err = 1; break; } } + if (err) + return err; + ff = axmap_next_free(map, osize); if (ff != (uint64_t) -1ULL) { printf("axmap_next_free broken: got %llu\n", (unsigned long long) ff); return 1; } + printf("pass!\n"); + axmap_free(map); + return 0; +} + +static int test_multi(size_t size, unsigned int bit_off) +{ + unsigned int map_size = size; + struct axmap *map; + uint64_t val = bit_off; + int i, err; + + printf("Test multi %llu entries %u offset...", (unsigned long long) size, bit_off); + fflush(stdout); + + map = axmap_new(map_size); + while (val + 128 <= map_size) { + err = 0; + for (i = val; i < val + 128; i++) { + if (axmap_isset(map, val + i)) { + printf("bit already set\n"); + err = 1; + break; + } + } + + if (err) + break; + + err = axmap_set_nr(map, val, 128); + if (err != 128) { + printf("only set %u bits\n", err); + break; + } + + err = 0; + for (i = 0; i < 128; i++) { + if (!axmap_isset(map, val + i)) { + printf("bit not set: %llu\n", (unsigned long long) val + i); + err = 1; + break; + } + } + + val += 128; + if (err) + break; + } + + if (!err) + printf("pass!\n"); + + axmap_free(map); + return err; +} + +int main(int argc, char *argv[]) +{ + size_t size = (1UL << 23) - 200; + int seed = 1; + + if (argc > 1) { + size = strtoul(argv[1], NULL, 10); + if (argc > 2) + seed = strtoul(argv[2], NULL, 10); + } + + if (test_regular(size, seed)) + return 1; + if (test_multi(size, 0)) + return 2; + if (test_multi(size, 17)) + return 3; + return 0; } -- To unsubscribe from this list: send the line "unsubscribe fio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html