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