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