@@ -139,21 +139,31 @@ static umf_result_t devdax_initialize(void *params, void **provider) {
139
139
goto err_free_devdax_provider ;
140
140
}
141
141
142
- unsigned map_sync_flag = 0 ;
143
- utils_translate_mem_visibility_flag (UMF_MEM_MAP_SYNC , & map_sync_flag );
142
+ bool is_dax = false;
144
143
145
- // mmap /dev/dax with the MAP_SYNC xor MAP_SHARED flag (if MAP_SYNC fails)
144
+ // mmap /dev/dax with the MAP_SYNC
146
145
devdax_provider -> base = utils_mmap_file (
147
- NULL , devdax_provider -> size , devdax_provider -> protection , map_sync_flag ,
148
- fd , 0 /* offset */ , NULL );
146
+ NULL , devdax_provider -> size , devdax_provider -> protection , 0 /* flags */ ,
147
+ fd , 0 /* offset */ , & is_dax );
149
148
utils_close_fd (fd );
150
149
if (devdax_provider -> base == NULL ) {
151
- LOG_PDEBUG ("devdax memory mapping failed (path=%s, size=%zu)" ,
150
+ LOG_PDEBUG ("mapping the devdax failed (path=%s, size=%zu)" ,
152
151
in_params -> path , devdax_provider -> size );
153
152
ret = UMF_RESULT_ERROR_UNKNOWN ;
154
153
goto err_free_devdax_provider ;
155
154
}
156
155
156
+ if (!is_dax ) {
157
+ LOG_ERR ("mapping the devdax with MAP_SYNC failed: %s" , in_params -> path );
158
+ ret = UMF_RESULT_ERROR_UNKNOWN ;
159
+
160
+ if (devdax_provider -> base ) {
161
+ utils_munmap (devdax_provider -> base , devdax_provider -> size );
162
+ }
163
+
164
+ goto err_free_devdax_provider ;
165
+ }
166
+
157
167
LOG_DEBUG ("devdax memory mapped (path=%s, size=%zu, addr=%p)" ,
158
168
in_params -> path , devdax_provider -> size , devdax_provider -> base );
159
169
@@ -433,6 +443,8 @@ static umf_result_t devdax_open_ipc_handle(void *provider,
433
443
return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
434
444
}
435
445
446
+ * ptr = NULL ;
447
+
436
448
devdax_ipc_data_t * devdax_ipc_data = (devdax_ipc_data_t * )providerIpcData ;
437
449
438
450
int fd = utils_devdax_open (devdax_ipc_data -> path );
@@ -441,9 +453,6 @@ static umf_result_t devdax_open_ipc_handle(void *provider,
441
453
return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
442
454
}
443
455
444
- unsigned map_sync_flag = 0 ;
445
- utils_translate_mem_visibility_flag (UMF_MEM_MAP_SYNC , & map_sync_flag );
446
-
447
456
// It is just a workaround for case when
448
457
// devdax_alloc() was called with the size argument
449
458
// that is not a multiplier of DEVDAX_PAGE_SIZE_2MB.
@@ -452,34 +461,42 @@ static umf_result_t devdax_open_ipc_handle(void *provider,
452
461
utils_align_ptr_down_size_up ((void * * )& offset_aligned , & length_aligned ,
453
462
DEVDAX_PAGE_SIZE_2MB );
454
463
455
- // mmap /dev/dax with the MAP_SYNC xor MAP_SHARED flag (if MAP_SYNC fails)
464
+ bool is_dax = false;
465
+
466
+ // mmap /dev/dax with the MAP_SYNC
456
467
char * addr =
457
468
utils_mmap_file (NULL , length_aligned , devdax_ipc_data -> protection ,
458
- map_sync_flag , fd , offset_aligned , NULL );
469
+ 0 /* flags */ , fd , offset_aligned , & is_dax );
470
+ (void )utils_close_fd (fd );
459
471
if (addr == NULL ) {
460
- devdax_store_last_native_error (UMF_DEVDAX_RESULT_ERROR_ALLOC_FAILED ,
461
- errno );
462
-
463
472
LOG_PERR ("devdax mapping failed (path: %s, size: %zu, protection: %i, "
464
473
"fd: %i, offset: %zu)" ,
465
474
devdax_ipc_data -> path , length_aligned ,
466
475
devdax_ipc_data -> protection , fd , offset_aligned );
467
476
468
- * ptr = NULL ;
469
- (void )utils_close_fd (fd );
470
-
477
+ devdax_store_last_native_error (UMF_DEVDAX_RESULT_ERROR_ALLOC_FAILED ,
478
+ errno );
471
479
return UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC ;
472
480
}
473
481
482
+ if (!is_dax ) {
483
+ LOG_ERR ("mapping the devdax with MAP_SYNC failed: %s" ,
484
+ devdax_ipc_data -> path );
485
+
486
+ if (addr ) {
487
+ utils_munmap (addr , length_aligned );
488
+ }
489
+
490
+ return UMF_RESULT_ERROR_UNKNOWN ;
491
+ }
492
+
474
493
LOG_DEBUG ("devdax mapped (path: %s, size: %zu, protection: %i, fd: %i, "
475
494
"offset: %zu) to address %p" ,
476
495
devdax_ipc_data -> path , length_aligned ,
477
496
devdax_ipc_data -> protection , fd , offset_aligned , addr );
478
497
479
498
* ptr = addr ;
480
499
481
- (void )utils_close_fd (fd );
482
-
483
500
return UMF_RESULT_SUCCESS ;
484
501
}
485
502
0 commit comments