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.
 
 
 
 
 
 

54 lines
1.2 KiB

  1. // Copyright (c) Vitaliy Filippov, 2019+
  2. // License: VNPL-1.0 (see README.md for details)
  3. #include "osd.h"
  4. #include <signal.h>
  5. static osd_t *osd = NULL;
  6. static bool force_stopping = false;
  7. static void handle_sigint(int sig)
  8. {
  9. if (osd && !force_stopping)
  10. {
  11. force_stopping = true;
  12. osd->force_stop(0);
  13. return;
  14. }
  15. exit(0);
  16. }
  17. int main(int narg, char *args[])
  18. {
  19. setvbuf(stdout, NULL, _IONBF, 0);
  20. setvbuf(stderr, NULL, _IONBF, 0);
  21. if (sizeof(osd_any_op_t) > OSD_PACKET_SIZE ||
  22. sizeof(osd_any_reply_t) > OSD_PACKET_SIZE)
  23. {
  24. perror("BUG: too small packet size");
  25. return 1;
  26. }
  27. blockstore_config_t config;
  28. for (int i = 1; i < narg; i++)
  29. {
  30. if (args[i][0] == '-' && args[i][1] == '-' && i < narg-1)
  31. {
  32. char *opt = args[i]+2;
  33. config[opt] = args[++i];
  34. }
  35. }
  36. signal(SIGINT, handle_sigint);
  37. signal(SIGTERM, handle_sigint);
  38. ring_loop_t *ringloop = new ring_loop_t(512);
  39. osd = new osd_t(config, ringloop);
  40. while (1)
  41. {
  42. ringloop->loop();
  43. ringloop->wait();
  44. }
  45. delete osd;
  46. delete ringloop;
  47. return 0;
  48. }