| 560 | } |
| 561 | |
| 562 | void update_blocksize(const unsigned int blocksize, alloc_data_t *list_search_space, const uint64_t offset) |
| 563 | { |
| 564 | #ifndef DISABLED_FOR_FRAMAC |
| 565 | struct td_list_head *search_walker; |
| 566 | struct td_list_head *search_walker_prev = NULL; |
| 567 | log_info("blocksize=%u, offset=%u\n", blocksize, (unsigned int)(offset%blocksize)); |
| 568 | /* Align end of last range (round up) */ |
| 569 | search_walker=list_search_space->list.prev; |
| 570 | { |
| 571 | alloc_data_t *current_search_space; |
| 572 | current_search_space=td_list_entry(search_walker, alloc_data_t, list); |
| 573 | /*@ assert \valid(current_search_space); */ |
| 574 | current_search_space->end=(current_search_space->end+1-offset%blocksize+blocksize-1)/blocksize*blocksize+offset%blocksize-1; |
| 575 | } |
| 576 | /* Align start of each range */ |
| 577 | td_list_for_each_prev_safe(search_walker,search_walker_prev,&list_search_space->list) |
| 578 | { |
| 579 | alloc_data_t *current_search_space=td_list_entry(search_walker, alloc_data_t, list); |
| 580 | /*@ assert \valid_read(current_search_space); */ |
| 581 | /*@ assert current_search_space->start >= offset; */ |
| 582 | const uint64_t aligned_start=(current_search_space->start-offset%blocksize+blocksize-1)/blocksize*blocksize+offset%blocksize; |
| 583 | if(current_search_space->start!=aligned_start) |
| 584 | { |
| 585 | alloc_data_t *prev_search_space=td_list_entry(search_walker_prev, alloc_data_t, list); |
| 586 | /*@ assert \valid_read(prev_search_space); */ |
| 587 | if(prev_search_space->end + 1 == current_search_space->start) |
| 588 | { |
| 589 | /* merge with previous block */ |
| 590 | prev_search_space->end = current_search_space->end; |
| 591 | td_list_del(search_walker); |
| 592 | free(current_search_space); |
| 593 | } |
| 594 | else |
| 595 | { |
| 596 | current_search_space->start=aligned_start; |
| 597 | current_search_space->file_stat=NULL; |
| 598 | if(current_search_space->start>=current_search_space->end) |
| 599 | { |
| 600 | /* block too small - delete it */ |
| 601 | td_list_del(search_walker); |
| 602 | free(current_search_space); |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | } |
| 607 | /* Align end of each range (truncate) */ |
| 608 | td_list_for_each_prev_safe(search_walker, search_walker_prev, &list_search_space->list) |
| 609 | { |
| 610 | alloc_data_t *current_search_space=td_list_entry(search_walker, alloc_data_t, list); |
| 611 | /*@ assert \valid_read(current_search_space); */ |
| 612 | current_search_space->end=(current_search_space->end+1-offset%blocksize)/blocksize*blocksize+offset%blocksize-1; |
| 613 | if(current_search_space->start>=current_search_space->end) |
| 614 | { |
| 615 | /* block too small - delete it */ |
| 616 | td_list_del(search_walker); |
| 617 | free(current_search_space); |
| 618 | } |
| 619 | } |
no test coverage detected