/*
- * libpmem: IO engine that uses NVML libpmem to read and write data
+ * libpmem: IO engine that uses PMDK libpmem to read and write data
*
* Copyright (C) 2017 Nippon Telegraph and Telephone Corporation.
*
#define PROCMAXLEN 2048 /* maximum expected line length in /proc files */
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
-static int Mmap_no_random;
+static bool Mmap_no_random;
static void *Mmap_hint;
static unsigned long long Mmap_align;
-static unsigned long long Pagesize = 0;
/*
* util_map_hint_align -- choose the desired mapping alignment
*/
static inline size_t util_map_hint_align(size_t len, size_t req_align)
{
- size_t align = 0;
+ size_t align = Mmap_align;
dprint(FD_IO, "DEBUG util_map_hint_align\n" );
-#ifndef WIN32
- Mmap_align = Pagesize;
-#else
- if (Mmap_align == 0) {
- SYSTEM_INFO si;
- GetSystemInfo(&si);
- Mmap_align = si.dwAllocationGranularity;
- }
-#endif
-
- align = Mmap_align;
if (req_align)
align = req_align;
dprint(FD_IO, "DEBUG util_map_hint_unused\n");
assert(align > 0);
- /* XXX - replace sysconf() with util_get_sys_xxx() */
- Pagesize = (unsigned long) sysconf(_SC_PAGESIZE);
-
if (raddr == NULL)
- raddr += Pagesize;
+ raddr += page_size;
raddr = (char *)roundup((uintptr_t)raddr, align);
dprint(FD_IO, "Invalid PMEM_MMAP_HINT\n");
} else {
Mmap_hint = (void *)val;
- Mmap_no_random = 1;
+ Mmap_no_random = true;
dprint(FD_IO, "PMEM_MMAP_HINT set to %p\n", Mmap_hint);
}
}
/*
* It fits within existing mapping, use it
*/
- dprint(FD_IO," io_u->offset %lld : fdd->libpmem_off %ld : "
- "io_u->buflen %ld : fdd->libpmem_sz %ld\n",
- io_u->offset, fdd->libpmem_off,
- io_u->buflen, fdd->libpmem_sz);
+ dprint(FD_IO," io_u->offset %llu : fdd->libpmem_off %llu : "
+ "io_u->buflen %llu : fdd->libpmem_sz %llu\n",
+ io_u->offset, (unsigned long long) fdd->libpmem_off,
+ io_u->buflen, (unsigned long long) fdd->libpmem_sz);
if (io_u->offset >= fdd->libpmem_off &&
- (io_u->offset + io_u->buflen <
+ (io_u->offset + io_u->buflen <=
fdd->libpmem_off + fdd->libpmem_sz))
goto done;
return 0;
}
-static int fio_libpmem_queue(struct thread_data *td, struct io_u *io_u)
+static enum fio_q_status fio_libpmem_queue(struct thread_data *td,
+ struct io_u *io_u)
{
fio_ro_check(td, io_u);
io_u->error = 0;
{
struct thread_options *o = &td->o;
- dprint(FD_IO,"o->rw_min_bs %d \n o->fsync_blocks %d \n o->fdatasync_blocks %d \n",
+ dprint(FD_IO,"o->rw_min_bs %llu \n o->fsync_blocks %d \n o->fdatasync_blocks %d \n",
o->rw_min_bs,o->fsync_blocks,o->fdatasync_blocks);
dprint(FD_IO, "DEBUG fio_libpmem_init\n");
static void fio_init fio_libpmem_register(void)
{
+#ifndef WIN32
+ Mmap_align = page_size;
+#else
+ if (Mmap_align == 0) {
+ SYSTEM_INFO si;
+
+ GetSystemInfo(&si);
+ Mmap_align = si.dwAllocationGranularity;
+ }
+#endif
+
register_ioengine(&ioengine);
}