multitape_recover.c 1007 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "platform.h"
  2. #include <stdint.h>
  3. #include "multitape_internal.h"
  4. #include "storage.h"
  5. #include "multitape.h"
  6. /**
  7. * recovertape(machinenum, cachedir, whichkey, storage_modified):
  8. * Complete any pending checkpoint or commit, including a checkpoint in a
  9. * write transaction being performed by a different machine (if any). If
  10. * ${whichkey} is zero, use the write key; otherwise, use the delete key.
  11. * If the data on the server has been modified, set ${*storage_modified} to 1.
  12. */
  13. int
  14. recovertape(uint64_t machinenum, const char * cachedir, int whichkey,
  15. int * storage_modified)
  16. {
  17. uint8_t key = (whichkey == 0) ? 0 : 1;
  18. /* Complete any pending checkpoints or commits locally. */
  19. if (multitape_cleanstate(cachedir, machinenum, key, storage_modified))
  20. goto err0;
  21. /* Complete any non-local pending checkpoint. */
  22. if (storage_transaction_commitfromcheckpoint(machinenum, key,
  23. storage_modified))
  24. goto err0;
  25. /* Success! */
  26. return (0);
  27. err0:
  28. /* Failure! */
  29. return (-1);
  30. }