@@ -687,30 +687,40 @@ static umf_result_t file_open_ipc_handle(void *provider, void *providerIpcData,
687
687
umf_result_t ret = UMF_RESULT_SUCCESS ;
688
688
int fd ;
689
689
690
+ size_t offset_aligned = file_ipc_data -> offset_fd ;
691
+ size_t size_aligned = file_ipc_data -> size ;
692
+
693
+ if (file_provider -> is_fsdax ) {
694
+ // It is just a workaround for case when
695
+ // file_alloc() was called with the size argument
696
+ // that is not a multiplier of FSDAX_PAGE_SIZE_2MB.
697
+ utils_align_ptr_down_size_up ((void * * )& offset_aligned , & size_aligned ,
698
+ FSDAX_PAGE_SIZE_2MB );
699
+ }
700
+
690
701
fd = utils_file_open (file_ipc_data -> path );
691
702
if (fd == -1 ) {
692
703
LOG_PERR ("opening the file to be mapped (%s) failed" ,
693
704
file_ipc_data -> path );
694
705
return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
695
706
}
696
707
697
- char * addr = utils_mmap_file (
698
- NULL , file_ipc_data -> size , file_ipc_data -> protection ,
699
- file_ipc_data -> visibility , fd , file_ipc_data -> offset_fd );
708
+ char * addr = utils_mmap_file (NULL , size_aligned , file_ipc_data -> protection ,
709
+ file_ipc_data -> visibility , fd , offset_aligned );
700
710
(void )utils_close_fd (fd );
701
711
if (addr == NULL ) {
702
712
file_store_last_native_error (UMF_FILE_RESULT_ERROR_ALLOC_FAILED , errno );
703
713
LOG_PERR ("file mapping failed (path: %s, size: %zu, protection: %i, "
704
714
"fd: %i, offset: %zu)" ,
705
- file_ipc_data -> path , file_ipc_data -> size ,
706
- file_ipc_data -> protection , fd , file_ipc_data -> offset_fd );
715
+ file_ipc_data -> path , size_aligned , file_ipc_data -> protection ,
716
+ fd , offset_aligned );
707
717
return UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC ;
708
718
}
709
719
710
720
LOG_DEBUG ("file mapped (path: %s, size: %zu, protection: %i, fd: %i, "
711
721
"offset: %zu) at address %p" ,
712
- file_ipc_data -> path , file_ipc_data -> size ,
713
- file_ipc_data -> protection , fd , file_ipc_data -> offset_fd , addr );
722
+ file_ipc_data -> path , size_aligned , file_ipc_data -> protection , fd ,
723
+ offset_aligned , addr );
714
724
715
725
* ptr = addr ;
716
726
@@ -730,6 +740,13 @@ static umf_result_t file_close_ipc_handle(void *provider, void *ptr,
730
740
return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
731
741
}
732
742
743
+ if (file_provider -> is_fsdax ) {
744
+ // It is just a workaround for case when
745
+ // file_alloc() was called with the size argument
746
+ // that is not a multiplier of FSDAX_PAGE_SIZE_2MB.
747
+ utils_align_ptr_down_size_up (& ptr , & size , FSDAX_PAGE_SIZE_2MB );
748
+ }
749
+
733
750
errno = 0 ;
734
751
int ret = utils_munmap (ptr , size );
735
752
// ignore error when size == 0
0 commit comments