X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=memory.c;h=8c06d94d85e7a48ecfb5d8681a8780658f567f6c;hp=f1cd2d770f4cbe3597ecbc5e236b355e930fc49a;hb=24ffb6f85058a95d4647541283c94c9e27520f1b;hpb=8ea39c32d29428b17bfe9c806fc33f0c8adfe118 diff --git a/memory.c b/memory.c index f1cd2d77..8c06d94d 100644 --- a/memory.c +++ b/memory.c @@ -5,12 +5,12 @@ #include #include #include -#ifndef FIO_NO_HAVE_SHM_H -#include -#endif #include #include "fio.h" +#ifndef FIO_NO_HAVE_SHM_H +#include +#endif void fio_unpin_memory(struct thread_data *td) { @@ -158,9 +158,10 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem) if (td->orig_buffer == MAP_FAILED) { td_verror(td, errno, "mmap"); td->orig_buffer = NULL; - if (td->mmapfd) { + if (td->mmapfd != 1) { close(td->mmapfd); - unlink(td->o.mmapfile); + if (td->o.mmapfile) + unlink(td->o.mmapfile); } return 1; @@ -209,7 +210,7 @@ int allocate_io_mem(struct thread_data *td) total_mem = td->orig_buffer_size; - if (td->o.odirect || td->o.mem_align || + if (td->o.odirect || td->o.mem_align || td->o.oatomic || (td->io_ops->flags & FIO_MEMALIGN)) { total_mem += page_mask; if (td->o.mem_align && td->o.mem_align > page_size) @@ -240,7 +241,7 @@ void free_io_mem(struct thread_data *td) unsigned int total_mem; total_mem = td->orig_buffer_size; - if (td->o.odirect) + if (td->o.odirect || td->o.oatomic) total_mem += page_mask; if (td->o.mem_type == MEM_MALLOC)