Skip to content

Commit 10a6d68

Browse files
committed
Fix open
1 parent e0a006f commit 10a6d68

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/provider/provider_devdax_memory.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -448,25 +448,22 @@ static umf_result_t devdax_open_ipc_handle(void *provider,
448448
unsigned map_sync_flag = 0;
449449
utils_translate_mem_visibility_flag(UMF_MEM_MAP_SYNC, &map_sync_flag);
450450

451-
size_t length_aligned = ALIGN_UP(devdax_ipc_data->length, DEVDAX_PAGE_SIZE_2MB);
451+
size_t offset_aligned = devdax_ipc_data->offset;
452+
size_t length_aligned = devdax_ipc_data->length;
453+
utils_align_ptr_down_size_up((void **)&offset_aligned, &length_aligned, DEVDAX_PAGE_SIZE_2MB);
452454

453455
// mmap /dev/dax with the MAP_SYNC xor MAP_SHARED flag (if MAP_SYNC fails)
454456
char *addr = utils_mmap_file(NULL, length_aligned,
455457
devdax_ipc_data->protection, map_sync_flag, fd,
456-
devdax_ipc_data->offset);
458+
offset_aligned);
457459
if (addr == NULL) {
458460
devdax_store_last_native_error(UMF_DEVDAX_RESULT_ERROR_ALLOC_FAILED,
459461
errno);
460462

461-
if (IS_NOT_ALIGNED(devdax_ipc_data->offset, DEVDAX_PAGE_SIZE_2MB)) {
462-
LOG_WARN("offset (%zu) is not aligned to the page size (%zu)",
463-
devdax_ipc_data->offset, DEVDAX_PAGE_SIZE_2MB);
464-
}
465-
466463
LOG_PERR("devdax mapping failed (path: %s, size: %zu, protection: %i, "
467464
"fd: %i, offset: %zu)",
468465
devdax_ipc_data->path, length_aligned,
469-
devdax_ipc_data->protection, fd, devdax_ipc_data->offset);
466+
devdax_ipc_data->protection, fd, offset_aligned);
470467

471468
*ptr = NULL;
472469
(void)utils_close_fd(fd);
@@ -477,7 +474,7 @@ static umf_result_t devdax_open_ipc_handle(void *provider,
477474
LOG_DEBUG("devdax mapped (path: %s, size: %zu, protection: %i, fd: %i, "
478475
"offset: %zu) to address %p",
479476
devdax_ipc_data->path, length_aligned,
480-
devdax_ipc_data->protection, fd, devdax_ipc_data->offset, addr);
477+
devdax_ipc_data->protection, fd, offset_aligned, addr);
481478

482479
*ptr = addr;
483480

0 commit comments

Comments
 (0)