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.
 
 
 
 
 
 

55 lines
1.5 KiB

  1. // Copyright (c) Vitaliy Filippov, 2019+
  2. // License: VNPL-1.0 (see README.md for details)
  3. #pragma once
  4. class blockstore_init_meta
  5. {
  6. blockstore_impl_t *bs;
  7. int wait_state = 0, wait_count = 0;
  8. void *metadata_buffer = NULL;
  9. uint64_t metadata_read = 0;
  10. int prev = 0, prev_done = 0, done_len = 0, submitted = 0;
  11. uint64_t done_cnt = 0, done_pos = 0;
  12. uint64_t entries_loaded = 0;
  13. struct io_uring_sqe *sqe;
  14. struct ring_data_t *data;
  15. void handle_entries(void *entries, unsigned count, int block_order);
  16. void handle_event(ring_data_t *data);
  17. public:
  18. blockstore_init_meta(blockstore_impl_t *bs);
  19. int loop();
  20. };
  21. struct bs_init_journal_done
  22. {
  23. void *buf;
  24. uint64_t pos, len;
  25. };
  26. class blockstore_init_journal
  27. {
  28. blockstore_impl_t *bs;
  29. int wait_state = 0, wait_count = 0, handle_res = 0;
  30. uint64_t entries_loaded = 0;
  31. uint32_t crc32_last = 0;
  32. bool started = false;
  33. uint64_t next_free;
  34. std::vector<bs_init_journal_done> done;
  35. uint64_t journal_pos = 0;
  36. uint64_t continue_pos = 0;
  37. void *init_write_buf = NULL;
  38. uint64_t init_write_sector = 0;
  39. bool wrapped = false;
  40. void *submitted_buf;
  41. struct io_uring_sqe *sqe;
  42. struct ring_data_t *data;
  43. journal_entry_start *je_start;
  44. std::function<void(ring_data_t*)> simple_callback;
  45. int handle_journal_part(void *buf, uint64_t done_pos, uint64_t len);
  46. void handle_event(ring_data_t *data);
  47. public:
  48. blockstore_init_journal(blockstore_impl_t* bs);
  49. int loop();
  50. };