Simplified distributed block storage with strong consistency, like in Ceph
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

24 lines
513 B

  1. // Copyright (c) Vitaliy Filippov, 2019+
  2. // License: VNPL-1.0 (see README.md for details)
  3. #pragma once
  4. #include <stdint.h>
  5. // Hierarchical bitmap allocator
  6. class allocator
  7. {
  8. uint64_t size;
  9. uint64_t free;
  10. uint64_t last_one_mask;
  11. uint64_t *mask;
  12. public:
  13. allocator(uint64_t blocks);
  14. ~allocator();
  15. void set(uint64_t addr, bool value);
  16. uint64_t find_free();
  17. uint64_t get_free_count();
  18. };
  19. void bitmap_set(void *bitmap, uint64_t start, uint64_t len, uint64_t bitmap_granularity);