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.
 
 
 
 
 
 

58 lines
1.6 KiB

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