Add support for O_ATOMIC
[fio.git] / memory.c
index 9e751bedcc70b2bb8b9e2bf9a74228a3478a9630..b208320c5d88cc619f7167626e3b7502ded07799 100644 (file)
--- 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");
@@ -160,7 +160,7 @@ static int alloc_mem_mmap(struct thread_data *td, size_t total_mem)
                td->orig_buffer = NULL;
                if (td->mmapfd) {
                        close(td->mmapfd);
-                       unlink(td->mmapfile);
+                       unlink(td->o.mmapfile);
                }
 
                return 1;
@@ -174,10 +174,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 +209,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 +240,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)