The following changes since commit e18941aab394d4a68df10379fec7184b52f95b3f: Fio 1.50.1 (2011-01-26 21:44:29 +0100) are available in the git repository at: git://git.kernel.dk/fio.git master Jens Axboe (5): solaris: OpenSolaris already has the madvise advice defined Revert "Unify makefiles" Kill flist_sort from Makefiles Fix end-of-job slowdown for random IO with a random map Fio 1.50.2 Makefile | 53 +++++++++----------------------------------- Makefile.FreeBSD | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.NetBSD | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.Windows | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.aix | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.mac | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.solaris | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ README | 15 +++++++++--- arch/arch-x86_64.h | 4 +- file.h | 6 +++- filesetup.c | 2 +- fio.h | 2 +- init.c | 2 +- io_u.c | 45 +++++++++++++++++++++++++------------ lib/ffz.h | 10 ++++++- os/os-solaris.h | 4 ++- 16 files changed, 431 insertions(+), 71 deletions(-) create mode 100644 Makefile.FreeBSD create mode 100644 Makefile.NetBSD create mode 100644 Makefile.Windows create mode 100644 Makefile.aix create mode 100644 Makefile.mac create mode 100644 Makefile.solaris --- Diff of recent changes: diff --git a/Makefile b/Makefile index df58489..088ecbb 100644 --- a/Makefile +++ b/Makefile @@ -3,51 +3,20 @@ DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ $(DEBUGFLAGS) OPTFLAGS= -O2 -fno-omit-frame-pointer -g $(EXTFLAGS) -CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) -LIBS = -lm +CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) -rdynamic +LIBS = -lpthread -lm -ldl -lrt -laio PROGS = fio SCRIPTS = fio_generate_plots -UNAME := $(shell uname) - + 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 \ - lib/num2str.c $(wildcard crc/*.c) engines/cpu.c \ - engines/mmap.c engines/sync.c engines/null.c engines/net.c - -ifeq ($(UNAME), Linux) - SOURCE += diskutil.c fifo.c blktrace.c helpers.c cgroup.c trim.c \ - engines/libaio.c engines/posixaio.c engines/sg.c \ - engines/splice.c engines/syslet-rw.c engines/guasi.c \ - engines/binject.c profiles/tiobench.c - LIBS += -lpthread -ldl -lrt -laio - CFLAGS += -rdynamic -else ifeq ($(UNAME), SunOS) - SOURCE += fifo.c lib/strsep.c helpers.c solaris.c engines/posixaio.c \ - engines/solarisaio.c - LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket - CPPFLAGS += -D__EXTENSIONS__ -else ifeq ($(UNAME), FreeBSD) - SOURCE += helpers.c engines/posixaio.c - LIBS += -lpthread -lrt - CFLAGS += -rdynamic -else ifeq ($(UNAME), NetBSD) - SOURCE += helpers.c engines/posixaio.c - LIBS += -lpthread -lrt - CFLAGS += -rdynamic -else ifeq ($(UNAME), AIX) - SOURCE += fifo.c helpers.c lib/getopt_long.c engines/posixaio.c - LIBS += -lpthread -ldl -lrt - CFLAGS += -rdynamic - CPPFLAGS += -D_LARGE_FILES -D__ppc__ -else ifeq ($(UNAME), Darwin) - SOURCE += helpers.c engines/posixaio.c - LIBS += -lpthread -ldl -else ifneq (,$(findstring CYGWIN,$(UNAME))) - SOURCE += engines/windowsaio.c - LIBS += -lpthread -lrt -endif - + eta.c verify.c memory.c io_u.c parse.c mutex.c options.c rbtree.c \ + diskutil.c fifo.c blktrace.c smalloc.c filehash.c helpers.c \ + cgroup.c profile.c debug.c trim.c lib/rand.c \ + lib/num2str.c $(wildcard crc/*.c) engines/cpu.c engines/libaio.c \ + engines/mmap.c engines/posixaio.c engines/sg.c engines/splice.c \ + engines/sync.c engines/null.c engines/net.c engines/syslet-rw.c \ + engines/guasi.c engines/binject.c profiles/tiobench.c + OBJS = $(SOURCE:.c=.o) ifneq ($(findstring $(MAKEFLAGS),s),s) diff --git a/Makefile.FreeBSD b/Makefile.FreeBSD new file mode 100644 index 0000000..b3014e3 --- /dev/null +++ b/Makefile.FreeBSD @@ -0,0 +1,60 @@ +CC = gcc +DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG +CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ + $(DEBUGFLAGS) +OPTFLAGS= -O2 -fno-omit-frame-pointer -g $(EXTFLAGS) +CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) -rdynamic +LIBS = -lpthread -lm -lrt +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 helpers.c profile.c debug.c lib/rand.c \ + lib/num2str.c $(wildcard crc/*.c) engines/cpu.c \ + engines/mmap.c engines/posixaio.c engines/sync.c engines/null.c \ + engines/net.c + +OBJS = $(SOURCE:.c=.o) + +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V + QUIET_CC = @echo ' ' CC $@; + QUIET_DEP = @echo ' ' DEP $@; +endif +endif + +INSTALL = install +prefix = /usr/local +bindir = $(prefix)/bin +mandir = $(prefix)/man + +.c.o: + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $< + +fio: $(OBJS) + $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $(LIBS) $(OBJS) + +depend: + $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend + +$(PROGS): depend + +all: depend $(PROGS) $(SCRIPTS) + +clean: + -rm -f .depend cscope.out $(OBJS) $(PROGS) core.* core + +cscope: + @cscope -b + +install: $(PROGS) $(SCRIPTS) + $(INSTALL) -m755 -d $(DESTDIR)$(bindir) + $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir) + $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1 + +ifneq ($(wildcard .depend),) +include .depend +endif diff --git a/Makefile.NetBSD b/Makefile.NetBSD new file mode 100644 index 0000000..2edf130 --- /dev/null +++ b/Makefile.NetBSD @@ -0,0 +1,59 @@ +CC = gcc +DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG +CPPFLAGS= -D_GNU_SOURCE $(DEBUGFLAGS) +OPTFLAGS= -O2 -fno-omit-frame-pointer -g $(EXTFLAGS) +CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) -rdynamic +LIBS = -lpthread -lm -lrt +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 helpers.c profile.c debug.c lib/rand.c \ + lib/num2str.c $(wildcard crc/*.c) engines/cpu.c \ + engines/mmap.c engines/posixaio.c engines/sync.c engines/null.c \ + engines/net.c + +OBJS = $(SOURCE:.c=.o) + +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V + QUIET_CC = @echo ' ' CC $@; + QUIET_DEP = @echo ' ' DEP $@; +endif +endif + +INSTALL = install +prefix = /usr/local +bindir = $(prefix)/bin +mandir = $(prefix)/man + +.c.o: + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $< + +fio: $(OBJS) + $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $(LIBS) $(OBJS) + +depend: + $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend + +$(PROGS): depend + +all: depend $(PROGS) $(SCRIPTS) + +clean: + -rm -f .depend cscope.out $(OBJS) $(PROGS) core.* core + +cscope: + @cscope -b + +install: $(PROGS) $(SCRIPTS) + $(INSTALL) -m755 -d $(DESTDIR)$(bindir) + $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir) + $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1 + +ifneq ($(wildcard .depend),) +include .depend +endif diff --git a/Makefile.Windows b/Makefile.Windows new file mode 100644 index 0000000..4524222 --- /dev/null +++ b/Makefile.Windows @@ -0,0 +1,61 @@ +CC = gcc +DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG +CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ + $(DEBUGFLAGS) +OPTFLAGS= -O2 -fno-omit-frame-pointer -gstabs+ $(EXTFLAGS) +CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) +LIBS = -lpthread -lm -lrt +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 \ + lib/num2str.c $(wildcard crc/*.c) engines/cpu.c \ + engines/mmap.c engines/sync.c engines/null.c engines/net.c \ + engines/net.c engines/windowsaio.c + +OBJS = $(SOURCE:.c=.o) + +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V + QUIET_CC = @echo ' ' CC $@; + QUIET_DEP = @echo ' ' DEP $@; +endif +endif + +INSTALL = install +prefix = /usr/local +bindir = $(prefix)/bin +mandir = $(prefix)/man + +.c.o: + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $< + +fio: $(OBJS) + $(QUIET_CC)windres os/windows/version.rc -O coff -o version.o + $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $(LIBS) $(OBJS) version.o + +depend: + $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend + +$(PROGS): depend + +all: depend $(PROGS) $(SCRIPTS) + +clean: + -rm -f .depend cscope.out $(OBJS) $(PROGS) version.o core.* core + +cscope: + @cscope -b + +install: $(PROGS) $(SCRIPTS) + $(INSTALL) -m755 -d $(DESTDIR)$(bindir) + $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir) + $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1 + +ifneq ($(wildcard .depend),) +include .depend +endif diff --git a/Makefile.aix b/Makefile.aix new file mode 100644 index 0000000..174ffee --- /dev/null +++ b/Makefile.aix @@ -0,0 +1,59 @@ +CC = gcc +DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG +CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ + -D_LARGE_FILES -D__ppc__ $(DEBUGFLAGS) +OPTFLAGS= -O2 -fno-omit-frame-pointer -g $(EXTFLAGS) +CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) -rdynamic +LIBS = -lpthread -lm -ldl -lrt +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 \ + fifo.c smalloc.c filehash.c helpers.c profile.c debug.c lib/rand.c \ + lib/getopt_long.c lib/num2str.c $(wildcard crc/*.c) engines/cpu.c \ + engines/mmap.c engines/posixaio.c engines/sync.c engines/null.c \ + engines/net.c profiles/tiobench.c + +OBJS = $(SOURCE:.c=.o) + +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V + QUIET_CC = @echo ' ' CC $@; + QUIET_DEP = @echo ' ' DEP $@; +endif +endif + +INSTALL = installbsd -c +prefix = /usr/local +bindir = $(prefix)/bin +mandir = $(prefix)/man + +.c.o: + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $< + +fio: $(OBJS) + $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $(LIBS) $(OBJS) + +depend: + $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend + +$(PROGS): depend + +all: depend $(PROGS) $(SCRIPTS) + +clean: + -rm -f .depend cscope.out $(OBJS) $(PROGS) core.* core + +cscope: + @cscope -b + +install: $(PROGS) $(SCRIPTS) + mkdir -p -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 + $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir) + $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1 + +ifneq ($(wildcard .depend),) +include .depend +endif diff --git a/Makefile.mac b/Makefile.mac new file mode 100644 index 0000000..77da86e --- /dev/null +++ b/Makefile.mac @@ -0,0 +1,60 @@ +CC = gcc +DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG +CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ + $(DEBUGFLAGS) +OPTFLAGS= -O2 -fno-omit-frame-pointer -g $(EXTFLAGS) +CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) -rdynamic +LIBS = -lpthread -lm -ldl +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 helpers.c profile.c debug.c lib/rand.c \ + lib/num2str.c $(wildcard crc/*.c) engines/cpu.c \ + engines/mmap.c engines/posixaio.c engines/sync.c engines/null.c \ + engines/net.c + +OBJS = $(SOURCE:.c=.o) + +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V + QUIET_CC = @echo ' ' CC $@; + QUIET_DEP = @echo ' ' DEP $@; +endif +endif + +INSTALL = install +prefix = /usr/local +bindir = $(prefix)/bin +mandir = $(prefix)/man + +.c.o: + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $< + +fio: $(OBJS) + $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $(LIBS) $(OBJS) + +depend: + $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend + +$(PROGS): depend + +all: depend $(PROGS) $(SCRIPTS) + +clean: + -rm -f .depend cscope.out $(OBJS) $(PROGS) core.* core + +cscope: + @cscope -b + +install: $(PROGS) $(SCRIPTS) + $(INSTALL) -m755 -d $(DESTDIR)$(bindir) + $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir) + $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1 + +ifneq ($(wildcard .depend),) +include .depend +endif diff --git a/Makefile.solaris b/Makefile.solaris new file mode 100644 index 0000000..267975e --- /dev/null +++ b/Makefile.solaris @@ -0,0 +1,60 @@ +CC = gcc +DEBUGFLAGS = -DFIO_INC_DEBUG +CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ + -D__EXTENSIONS__ $(DEBUGFLAGS) +OPTFLAGS= -O2 -fno-omit-frame-pointer -g $(EXTFLAGS) +CFLAGS = -std=gnu99 -Wall $(OPTFLAGS) +LIBS = -lpthread -lm -ldl -laio -lrt -lnsl -lsocket +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 \ + fifo.c smalloc.c filehash.c lib/strsep.c helpers.c solaris.c \ + profile.c debug.c lib/rand.c lib/num2str.c \ + $(wildcard crc/*.c) engines/cpu.c engines/mmap.c engines/posixaio.c \ + engines/sync.c engines/null.c engines/net.c engines/solarisaio.c + +OBJS = $(SOURCE:.c=.o) + +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V + QUIET_CC = @echo ' ' CC $@; + QUIET_DEP = @echo ' ' DEP $@; +endif +endif + +INSTALL = install +prefix = /usr/local +bindir = $(prefix)/bin +mandir = $(prefix)/man + +.c.o: + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $< + +fio: $(OBJS) + $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $(LIBS) $(OBJS) + +depend: + $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend + +$(PROGS): depend + +all: depend $(PROGS) $(SCRIPTS) + +clean: + -rm -f .depend cscope.out $(OBJS) $(PROGS) core.* core + +cscope: + @cscope -b + +install: $(PROGS) $(SCRIPTS) + $(INSTALL) -m755 -d $(DESTDIR)$(bindir) + $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir) + $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1 + +ifneq ($(wildcard .depend),) +include .depend +endif diff --git a/README b/README index cc84fed..adcced6 100644 --- a/README +++ b/README @@ -83,11 +83,18 @@ http://maillist.kernel.dk/fio-devel/ Building -------- -Just type 'make' and 'make install'. +Just type 'make' and 'make install'. If on BSD, for now you have to +specify the BSD Makefile with -f and use gmake (not make), eg: -Note that GNU make is required. On BSD it's available from devel/gmake; -on Solaris it's in the SUNWgmake package. On platforms where GNU make -isn't the default, type 'gmake' instead of 'make'. +$ gmake -f Makefile.FreeBSD && gmake -f Makefile.FreeBSD install + +Same goes for AIX: + +$ gmake -f Makefile.aix && gmake -f Makefile.aix install + +Likewise with OpenSolaris, use the Makefile.solaris to compile there. +The OpenSolaris make should work fine. This might change in the +future if I opt for an autoconf type setup. If your compile fails with an error like this: diff --git a/arch/arch-x86_64.h b/arch/arch-x86_64.h index 6dbeee0..f2dcf49 100644 --- a/arch/arch-x86_64.h +++ b/arch/arch-x86_64.h @@ -33,9 +33,9 @@ #define read_barrier() __asm__ __volatile__("lfence":::"memory") #define write_barrier() __asm__ __volatile__("sfence":::"memory") -static inline unsigned int arch_ffz(unsigned int bitmask) +static inline unsigned long arch_ffz(unsigned long bitmask) { - __asm__("bsfl %1,%0" :"=r" (bitmask) :"r" (~bitmask)); + __asm__("bsf %1,%0" :"=r" (bitmask) :"r" (~bitmask)); return bitmask; } diff --git a/file.h b/file.h index 7948a41..04c0d45 100644 --- a/file.h +++ b/file.h @@ -96,9 +96,10 @@ struct fio_file { /* * block map for random io */ - unsigned int *file_map; + unsigned long *file_map; unsigned int num_maps; unsigned int last_free_lookup; + unsigned int failed_rands; int references; enum fio_file_flags flags; @@ -158,11 +159,12 @@ extern void free_release_files(struct thread_data *); static inline void fio_file_reset(struct fio_file *f) { f->last_free_lookup = 0; + f->failed_rands = 0; f->last_pos = f->file_offset; f->last_start = -1ULL; f->file_pos = -1ULL; if (f->file_map) - memset(f->file_map, 0, f->num_maps * sizeof(int)); + memset(f->file_map, 0, f->num_maps * sizeof(unsigned long)); } #endif diff --git a/filesetup.c b/filesetup.c index d050506..0454cc4 100644 --- a/filesetup.c +++ b/filesetup.c @@ -812,7 +812,7 @@ int init_random_map(struct thread_data *td) (unsigned long long) td->o.rw_min_bs; num_maps = (blocks + BLOCKS_PER_MAP - 1) / (unsigned long long) BLOCKS_PER_MAP; - f->file_map = smalloc(num_maps * sizeof(int)); + f->file_map = smalloc(num_maps * sizeof(unsigned long)); if (f->file_map) { f->num_maps = num_maps; continue; diff --git a/fio.h b/fio.h index d2cca11..08f1733 100644 --- a/fio.h +++ b/fio.h @@ -531,7 +531,7 @@ static inline void fio_ro_check(struct thread_data *td, struct io_u *io_u) assert(!(io_u->ddir == DDIR_WRITE && !td_write(td))); } -#define BLOCKS_PER_MAP (8 * sizeof(int)) +#define BLOCKS_PER_MAP (8 * sizeof(unsigned long)) #define TO_MAP_BLOCK(f, b) (b) #define RAND_MAP_IDX(f, b) (TO_MAP_BLOCK(f, b) / BLOCKS_PER_MAP) #define RAND_MAP_BIT(f, b) (TO_MAP_BLOCK(f, b) & (BLOCKS_PER_MAP - 1)) diff --git a/init.c b/init.c index df9e2a3..e0f58cd 100644 --- a/init.c +++ b/init.c @@ -22,7 +22,7 @@ #include "lib/getopt.h" -static char fio_version_string[] = "fio 1.50.1"; +static char fio_version_string[] = "fio 1.50.2"; #define FIO_RANDSEED (0xb1899bedUL) diff --git a/io_u.c b/io_u.c index 1a45706..5a3ca74 100644 --- a/io_u.c +++ b/io_u.c @@ -30,7 +30,7 @@ static int random_map_free(struct fio_file *f, const unsigned long long block) dprint(FD_RANDOM, "free: b=%llu, idx=%u, bit=%u\n", block, idx, bit); - return (f->file_map[idx] & (1 << bit)) == 0; + return (f->file_map[idx] & (1UL << bit)) == 0; } /* @@ -50,8 +50,8 @@ static void mark_random_map(struct thread_data *td, struct io_u *io_u) busy_check = !(io_u->flags & IO_U_F_BUSY_OK); while (nr_blocks) { - unsigned int this_blocks, mask; unsigned int idx, bit; + unsigned long mask, this_blocks; /* * If we have a mixed random workload, we may @@ -75,9 +75,9 @@ static void mark_random_map(struct thread_data *td, struct io_u *io_u) do { if (this_blocks == BLOCKS_PER_MAP) - mask = -1U; + mask = -1UL; else - mask = ((1U << this_blocks) - 1) << bit; + mask = ((1UL << this_blocks) - 1) << bit; if (!(f->file_map[idx] & mask)) break; @@ -126,7 +126,7 @@ static unsigned long long last_block(struct thread_data *td, struct fio_file *f, static int get_next_free_block(struct thread_data *td, struct fio_file *f, enum fio_ddir ddir, unsigned long long *b) { - unsigned long long min_bs = td->o.rw_min_bs, lastb; + unsigned long long block, min_bs = td->o.rw_min_bs, lastb; int i; lastb = last_block(td, f, ddir); @@ -134,18 +134,19 @@ static int get_next_free_block(struct thread_data *td, struct fio_file *f, return 1; i = f->last_free_lookup; - *b = (i * BLOCKS_PER_MAP); - while ((*b) * min_bs < f->real_file_size && - (*b) * min_bs < f->io_size) { - if (f->file_map[i] != (unsigned int) -1) { - *b += ffz(f->file_map[i]); - if (*b > lastb) + block = i * BLOCKS_PER_MAP; + while (block * min_bs < f->real_file_size && + block * min_bs < f->io_size) { + if (f->file_map[i] != -1UL) { + block += ffz(f->file_map[i]); + if (block > lastb) break; f->last_free_lookup = i; + *b = block; return 0; } - *b += BLOCKS_PER_MAP; + block += BLOCKS_PER_MAP; i++; } @@ -163,6 +164,9 @@ static int get_next_rand_offset(struct thread_data *td, struct fio_file *f, if (!lastb) return 1; + if (f->failed_rands >= 200) + goto ffz; + do { r = os_random_long(&td->random_state); dprint(FD_RANDOM, "off rand %llu\n", r); @@ -172,18 +176,21 @@ static int get_next_rand_offset(struct thread_data *td, struct fio_file *f, * if we are not maintaining a random map, we are done. */ if (!file_randommap(td, f)) - return 0; + goto ret_good; /* * calculate map offset and check if it's free */ if (random_map_free(f, *b)) - return 0; + goto ret_good; dprint(FD_RANDOM, "get_next_rand_offset: offset %llu busy\n", *b); } while (--loops); + if (!f->failed_rands++) + f->last_free_lookup = 0; + /* * we get here, if we didn't suceed in looking up a block. generate * a random start offset into the filemap, and find the first free @@ -194,7 +201,7 @@ static int get_next_rand_offset(struct thread_data *td, struct fio_file *f, f->last_free_lookup = (f->num_maps - 1) * (r / (OS_RAND_MAX + 1.0)); if (!get_next_free_block(td, f, ddir, b)) - return 0; + goto ret; r = os_random_long(&td->random_state); } while (--loops); @@ -203,7 +210,15 @@ static int get_next_rand_offset(struct thread_data *td, struct fio_file *f, * that didn't work either, try exhaustive search from the start */ f->last_free_lookup = 0; +ffz: + if (!get_next_free_block(td, f, ddir, b)) + return 0; + f->last_free_lookup = 0; return get_next_free_block(td, f, ddir, b); +ret_good: + f->failed_rands = 0; +ret: + return 0; } static int get_next_rand_block(struct thread_data *td, struct fio_file *f, diff --git a/lib/ffz.h b/lib/ffz.h index e17a2e9..eef612d 100644 --- a/lib/ffz.h +++ b/lib/ffz.h @@ -1,10 +1,16 @@ #ifndef FIO_FFZ_H #define FIO_FFZ_H -static inline int __ffs(int word) +static inline int __ffs(unsigned long word) { int r = 0; +#if BITS_PER_LONG == 64 + if ((word & 0xffffffff) == 0) { + r += 32; + word >>= 32; + } +#endif if (!(word & 0xffff)) { word >>= 16; r += 16; @@ -29,7 +35,7 @@ static inline int __ffs(int word) return r; } -static inline int ffz(unsigned int bitmask) +static inline int ffz(unsigned long bitmask) { return __ffs(~bitmask); } diff --git a/os/os-solaris.h b/os/os-solaris.h index f93a04c..681d4a6 100644 --- a/os/os-solaris.h +++ b/os/os-solaris.h @@ -27,10 +27,12 @@ struct solaris_rand_seed { unsigned short r[3]; }; +#ifndef POSIX_MADV_SEQUENTIAL #define posix_madvise madvise -#define POSIX_MADV_DONTNEED MADV_DONTNEED #define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL +#define POSIX_MADV_DONTNEED MADV_DONTNEED #define POSIX_MADV_RANDOM MADV_RANDOM +#endif typedef psetid_t os_cpu_mask_t; typedef struct solaris_rand_seed os_random_state_t; -- 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