| 561 | } |
| 562 | |
| 563 | vp_addr_t ZenFileSystem::malloc() { |
| 564 | for (auto& [f, s] : blob_) { |
| 565 | vp_addr_t ret = -1; |
| 566 | _findFreeAddrInBlob(f, &ret); |
| 567 | if (ret != -1) { return ret; } |
| 568 | } |
| 569 | |
| 570 | // 2. Create a new blob |
| 571 | if (blob_.size() >= 1) { |
| 572 | switch (options_.mmap_type) { |
| 573 | case ZenFSBlobMMapType::kFile: { |
| 574 | _createBlobOnDisk(); |
| 575 | break; |
| 576 | } |
| 577 | case ZenFSBlobMMapType::kAnonymous: { |
| 578 | _createBlobOnAnonymousFile(); |
| 579 | break; |
| 580 | } |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | // 3. Find again !!! |
| 585 | for (auto& [f, s] : blob_) { |
| 586 | vp_addr_t ret = -1; |
| 587 | _findFreeAddrInBlob(f, &ret); |
| 588 | if (ret != -1) { return ret; } |
| 589 | } |
| 590 | |
| 591 | MLLM_ERROR_EXIT(ExitCode::kCoreError, "No more blob or some inner error in ZenFS"); |
| 592 | return -1; |
| 593 | } |
| 594 | |
| 595 | void ZenFileSystem::free(vp_addr_t addr) { |
| 596 | // Extract blob address from the virtual address |