@@ -485,6 +485,8 @@ static umf_result_t file_alloc_cb(void *provider, size_t size, size_t alignment,
485485
486486 file_memory_provider_t * file_provider = (file_memory_provider_t * )provider ;
487487
488+ * resultPtr = NULL ;
489+
488490 // alignment must be a power of two and a multiple or a divider of the page size
489491 if (alignment && ((alignment & (alignment - 1 )) ||
490492 ((alignment % file_provider -> page_size ) &&
@@ -517,8 +519,15 @@ static umf_result_t file_alloc_cb(void *provider, size_t size, size_t alignment,
517519 LOG_ERR ("inserting a value to the file descriptor offset map failed "
518520 "(addr=%p, offset=%zu)" ,
519521 addr , alloc_offset_fd );
522+ // We cannot undo the file_alloc_aligned() call here,
523+ // because the file memory provider does not support the free operation.
524+ return UMF_RESULT_ERROR_UNKNOWN ;
520525 }
521526
527+ LOG_DEBUG ("inserted a value to the file descriptor offset map (addr=%p, "
528+ "offset=%zu)" ,
529+ addr , alloc_offset_fd );
530+
522531 * resultPtr = addr ;
523532
524533 return UMF_RESULT_SUCCESS ;
@@ -623,23 +632,31 @@ static umf_result_t file_allocation_split_cb(void *provider, void *ptr,
623632
624633 void * value = critnib_get (file_provider -> fd_offset_map , (uintptr_t )ptr );
625634 if (value == NULL ) {
626- LOG_ERR ("file_allocation_split(): getting a value from the file "
627- "descriptor offset map failed (addr=%p)" ,
635+ LOG_ERR ("getting a value from the file descriptor offset map failed "
636+ "(addr=%p)" ,
628637 ptr );
629638 return UMF_RESULT_ERROR_UNKNOWN ;
630639 }
631640
641+ LOG_DEBUG ("split the value from the file descriptor offset map (addr=%p) "
642+ "from size %zu to %zu + %zu" ,
643+ ptr , totalSize , firstSize , totalSize - firstSize );
644+
632645 uintptr_t new_key = (uintptr_t )ptr + firstSize ;
633646 void * new_value = (void * )((uintptr_t )value + firstSize );
634647 int ret = critnib_insert (file_provider -> fd_offset_map , new_key , new_value ,
635648 0 /* update */ );
636649 if (ret ) {
637- LOG_ERR ("file_allocation_split(): inserting a value to the file "
638- "descriptor offset map failed (addr=%p, offset=%zu)" ,
650+ LOG_ERR ("inserting a value to the file descriptor offset map failed "
651+ "(addr=%p, offset=%zu)" ,
639652 (void * )new_key , (size_t )new_value - 1 );
640653 return UMF_RESULT_ERROR_UNKNOWN ;
641654 }
642655
656+ LOG_DEBUG ("inserted a value to the file descriptor offset map (addr=%p, "
657+ "offset=%zu)" ,
658+ (void * )new_key , (size_t )new_value - 1 );
659+
643660 return UMF_RESULT_SUCCESS ;
644661}
645662
@@ -662,12 +679,16 @@ static umf_result_t file_allocation_merge_cb(void *provider, void *lowPtr,
662679 void * value =
663680 critnib_remove (file_provider -> fd_offset_map , (uintptr_t )highPtr );
664681 if (value == NULL ) {
665- LOG_ERR ("file_allocation_merge(): removing a value from the file "
666- "descriptor offset map failed (addr=%p)" ,
682+ LOG_ERR ("removing a value from the file descriptor offset map failed "
683+ "(addr=%p)" ,
667684 highPtr );
668685 return UMF_RESULT_ERROR_UNKNOWN ;
669686 }
670687
688+ LOG_DEBUG ("removed a value from the file descriptor offset map (addr=%p) - "
689+ "merged with %p" ,
690+ highPtr , lowPtr );
691+
671692 return UMF_RESULT_SUCCESS ;
672693}
673694
@@ -701,9 +722,7 @@ static umf_result_t file_get_ipc_handle(void *provider, const void *ptr,
701722
702723 void * value = critnib_get (file_provider -> fd_offset_map , (uintptr_t )ptr );
703724 if (value == NULL ) {
704- LOG_ERR ("file_get_ipc_handle(): getting a value from the IPC cache "
705- "failed (addr=%p)" ,
706- ptr );
725+ LOG_ERR ("getting a value from the IPC cache failed (addr=%p)" , ptr );
707726 return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
708727 }
709728
0 commit comments