#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-#ifndef FIO_NO_HAVE_SHM_H
-#include <sys/shm.h>
-#endif
#include <sys/mman.h>
#include "fio.h"
+#ifndef FIO_NO_HAVE_SHM_H
+#include <sys/shm.h>
+#endif
void fio_unpin_memory(struct thread_data *td)
{
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;
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)
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)