X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=memory.c;h=23a0d94b73e3d353b61044fe85149dfda4e59f55;hb=f6facd21c027939f6ec3d376d294547c1db40e2d;hp=76da8a86269e859889366c283281815e9ffac1dc;hpb=4a995ddae8b12d20efc2367ad4e1c9b159f96eed;p=fio.git diff --git a/memory.c b/memory.c index 76da8a86..23a0d94b 100644 --- a/memory.c +++ b/memory.c @@ -63,6 +63,7 @@ int fio_pin_memory(struct thread_data *td) static int alloc_mem_shm(struct thread_data *td, unsigned int total_mem) { +#ifndef CONFIG_NO_SHM int flags = IPC_CREAT | S_IRUSR | S_IWUSR; if (td->o.mem_type == MEM_SHMHUGE) { @@ -104,15 +105,21 @@ static int alloc_mem_shm(struct thread_data *td, unsigned int total_mem) } return 0; +#else + log_err("fio: shm not supported\n"); + return 1; +#endif } static void free_mem_shm(struct thread_data *td) { +#ifndef CONFIG_NO_SHM struct shmid_ds sbuf; dprint(FD_MEM, "shmdt/ctl %d %p\n", td->shm_id, td->orig_buffer); shmdt(td->orig_buffer); shmctl(td->shm_id, IPC_RMID, &sbuf); +#endif } static int alloc_mem_mmap(struct thread_data *td, size_t total_mem) @@ -158,7 +165,7 @@ 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 != 1) { + if (td->mmapfd != 1 && td->mmapfd != -1) { close(td->mmapfd); if (td->o.mmapfile) unlink(td->o.mmapfile);