@@ -686,30 +686,41 @@ static umf_result_t file_open_ipc_handle(void *provider, void *providerIpcData,
686686 umf_result_t ret = UMF_RESULT_SUCCESS ;
687687 int fd ;
688688
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+
689700 fd = utils_file_open (file_ipc_data -> path );
690701 if (fd == -1 ) {
691702 LOG_PERR ("opening the file to be mapped (%s) failed" ,
692703 file_ipc_data -> path );
693704 return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
694705 }
695706
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 );
699710 (void )utils_close_fd (fd );
700711 if (addr == NULL ) {
701712 file_store_last_native_error (UMF_FILE_RESULT_ERROR_ALLOC_FAILED , errno );
702713 LOG_PERR ("file mapping failed (path: %s, size: %zu, protection: %i, "
703714 "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 );
706717 return UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC ;
707718 }
708719
709720 LOG_DEBUG ("file mapped (path: %s, size: %zu, protection: %i, fd: %i, "
710721 "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 );
713724
714725 * ptr = addr ;
715726
@@ -728,6 +739,13 @@ static umf_result_t file_close_ipc_handle(void *provider, void *ptr,
728739 return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
729740 }
730741
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+
731749 errno = 0 ;
732750 int ret = utils_munmap (ptr , size );
733751 // ignore error when size == 0
0 commit comments