X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=memory.c;h=8c06d94d85e7a48ecfb5d8681a8780658f567f6c;hp=9e751bedcc70b2bb8b9e2bf9a74228a3478a9630;hb=8284355265bbedacf86f43067ec456c2d91eeb4a;hpb=9a3f110001f68968def40797bed5632c2406cdfa diff --git a/memory.c b/memory.c index 9e751bed..8c06d94d 100644 --- a/memory.c +++ b/memory.c @@ -125,13 +125,13 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem) unsigned long mask = td->o.hugepage_size - 1; /* TODO: make sure the file is a real hugetlbfs file */ - if (!td->mmapfile) + if (!td->o.mmapfile) flags |= MAP_HUGETLB; total_mem = (total_mem + mask) & ~mask; } - if (td->mmapfile) { - td->mmapfd = open(td->mmapfile, O_RDWR|O_CREAT, 0644); + if (td->o.mmapfile) { + td->mmapfd = open(td->o.mmapfile, O_RDWR|O_CREAT, 0644); if (td->mmapfd < 0) { td_verror(td, errno, "open mmap file"); @@ -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->mmapfile); + if (td->o.mmapfile) + unlink(td->o.mmapfile); } return 1; @@ -174,10 +175,10 @@ static void free_mem_mmap(struct thread_data *td, size_t total_mem) dprint(FD_MEM, "munmap %llu %p\n", (unsigned long long) total_mem, td->orig_buffer); munmap(td->orig_buffer, td->orig_buffer_size); - if (td->mmapfile) { + if (td->o.mmapfile) { close(td->mmapfd); - unlink(td->mmapfile); - free(td->mmapfile); + unlink(td->o.mmapfile); + free(td->o.mmapfile); } } @@ -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)