sync.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*-------------------------------------------------------------------------
  2. *
  3. * sync.h
  4. * File synchronization management code.
  5. *
  6. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994, Regents of the University of California
  8. *
  9. * src/include/storage/sync.h
  10. *
  11. *-------------------------------------------------------------------------
  12. */
  13. #ifndef SYNC_H
  14. #define SYNC_H
  15. #include "storage/relfilenode.h"
  16. /*
  17. * Type of sync request. These are used to manage the set of pending
  18. * requests to call a sync handler's sync or unlink functions at the next
  19. * checkpoint.
  20. */
  21. typedef enum SyncRequestType
  22. {
  23. SYNC_REQUEST, /* schedule a call of sync function */
  24. SYNC_UNLINK_REQUEST, /* schedule a call of unlink function */
  25. SYNC_FORGET_REQUEST, /* forget all calls for a tag */
  26. SYNC_FILTER_REQUEST /* forget all calls satisfying match fn */
  27. } SyncRequestType;
  28. /*
  29. * Which set of functions to use to handle a given request. The values of
  30. * the enumerators must match the indexes of the function table in sync.c.
  31. */
  32. typedef enum SyncRequestHandler
  33. {
  34. SYNC_HANDLER_MD = 0,
  35. SYNC_HANDLER_CLOG,
  36. SYNC_HANDLER_COMMIT_TS,
  37. SYNC_HANDLER_MULTIXACT_OFFSET,
  38. SYNC_HANDLER_MULTIXACT_MEMBER,
  39. SYNC_HANDLER_NONE
  40. } SyncRequestHandler;
  41. /*
  42. * A tag identifying a file. Currently it has the members required for md.c's
  43. * usage, but sync.c has no knowledge of the internal structure, and it is
  44. * liable to change as required by future handlers.
  45. */
  46. typedef struct FileTag
  47. {
  48. int16 handler; /* SyncRequestHandler value, saving space */
  49. int16 forknum; /* ForkNumber, saving space */
  50. RelFileNode rnode;
  51. uint32 segno;
  52. } FileTag;
  53. extern void InitSync(void);
  54. extern void SyncPreCheckpoint(void);
  55. extern void SyncPostCheckpoint(void);
  56. extern void ProcessSyncRequests(void);
  57. extern void RememberSyncRequest(const FileTag *ftag, SyncRequestType type);
  58. extern bool RegisterSyncRequest(const FileTag *ftag, SyncRequestType type,
  59. bool retryOnError);
  60. #endif /* SYNC_H */