@@ -485,6 +485,8 @@ static umf_result_t file_alloc_cb(void *provider, size_t size, size_t alignment,
485
485
486
486
file_memory_provider_t * file_provider = (file_memory_provider_t * )provider ;
487
487
488
+ * resultPtr = NULL ;
489
+
488
490
// alignment must be a power of two and a multiple or a divider of the page size
489
491
if (alignment && ((alignment & (alignment - 1 )) ||
490
492
((alignment % file_provider -> page_size ) &&
@@ -517,8 +519,15 @@ static umf_result_t file_alloc_cb(void *provider, size_t size, size_t alignment,
517
519
LOG_ERR ("inserting a value to the file descriptor offset map failed "
518
520
"(addr=%p, offset=%zu)" ,
519
521
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 ;
520
525
}
521
526
527
+ LOG_DEBUG ("inserted a value to the file descriptor offset map (addr=%p, "
528
+ "offset=%zu)" ,
529
+ addr , alloc_offset_fd );
530
+
522
531
* resultPtr = addr ;
523
532
524
533
return UMF_RESULT_SUCCESS ;
@@ -623,23 +632,31 @@ static umf_result_t file_allocation_split_cb(void *provider, void *ptr,
623
632
624
633
void * value = critnib_get (file_provider -> fd_offset_map , (uintptr_t )ptr );
625
634
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)" ,
628
637
ptr );
629
638
return UMF_RESULT_ERROR_UNKNOWN ;
630
639
}
631
640
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
+
632
645
uintptr_t new_key = (uintptr_t )ptr + firstSize ;
633
646
void * new_value = (void * )((uintptr_t )value + firstSize );
634
647
int ret = critnib_insert (file_provider -> fd_offset_map , new_key , new_value ,
635
648
0 /* update */ );
636
649
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)" ,
639
652
(void * )new_key , (size_t )new_value - 1 );
640
653
return UMF_RESULT_ERROR_UNKNOWN ;
641
654
}
642
655
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
+
643
660
return UMF_RESULT_SUCCESS ;
644
661
}
645
662
@@ -662,12 +679,16 @@ static umf_result_t file_allocation_merge_cb(void *provider, void *lowPtr,
662
679
void * value =
663
680
critnib_remove (file_provider -> fd_offset_map , (uintptr_t )highPtr );
664
681
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)" ,
667
684
highPtr );
668
685
return UMF_RESULT_ERROR_UNKNOWN ;
669
686
}
670
687
688
+ LOG_DEBUG ("removed a value from the file descriptor offset map (addr=%p) - "
689
+ "merged with %p" ,
690
+ highPtr , lowPtr );
691
+
671
692
return UMF_RESULT_SUCCESS ;
672
693
}
673
694
@@ -701,9 +722,7 @@ static umf_result_t file_get_ipc_handle(void *provider, const void *ptr,
701
722
702
723
void * value = critnib_get (file_provider -> fd_offset_map , (uintptr_t )ptr );
703
724
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 );
707
726
return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
708
727
}
709
728
0 commit comments