PostgreSQL Source Code  git master
sync.h
Go to the documentation of this file.
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 
16 #include "storage/relfilenode.h"
17 
18 /*
19  * Type of sync request. These are used to manage the set of pending
20  * requests to call a sync handler's sync or unlink functions at the next
21  * checkpoint.
22  */
23 typedef enum SyncRequestType
24 {
25  SYNC_REQUEST, /* schedule a call of sync function */
26  SYNC_UNLINK_REQUEST, /* schedule a call of unlink function */
27  SYNC_FORGET_REQUEST, /* forget all calls for a tag */
28  SYNC_FILTER_REQUEST /* forget all calls satisfying match fn */
30 
31 /*
32  * Which set of functions to use to handle a given request. The values of
33  * the enumerators must match the indexes of the function table in sync.c.
34  */
35 typedef enum SyncRequestHandler
36 {
44 
45 /*
46  * A tag identifying a file. Currently it has the members required for md.c's
47  * usage, but sync.c has no knowledge of the internal structure, and it is
48  * liable to change as required by future handlers.
49  */
50 typedef struct FileTag
51 {
52  int16 handler; /* SyncRequestHandler value, saving space */
53  int16 forknum; /* ForkNumber, saving space */
57 
58 extern void InitSync(void);
59 extern void SyncPreCheckpoint(void);
60 extern void SyncPostCheckpoint(void);
61 extern void ProcessSyncRequests(void);
62 extern void RememberSyncRequest(const FileTag *ftag, SyncRequestType type);
63 extern bool RegisterSyncRequest(const FileTag *ftag, SyncRequestType type,
64  bool retryOnError);
65 
66 #endif /* SYNC_H */
unsigned int uint32
Definition: c.h:452
signed short int16
Definition: c.h:439
Definition: sync.h:51
int16 forknum
Definition: sync.h:53
uint32 segno
Definition: sync.h:55
RelFileNode rnode
Definition: sync.h:54
int16 handler
Definition: sync.h:52
void ProcessSyncRequests(void)
Definition: sync.c:293
void SyncPreCheckpoint(void)
Definition: sync.c:184
struct FileTag FileTag
void InitSync(void)
Definition: sync.c:131
void RememberSyncRequest(const FileTag *ftag, SyncRequestType type)
Definition: sync.c:494
SyncRequestHandler
Definition: sync.h:36
@ SYNC_HANDLER_MD
Definition: sync.h:37
@ SYNC_HANDLER_COMMIT_TS
Definition: sync.h:39
@ SYNC_HANDLER_MULTIXACT_MEMBER
Definition: sync.h:41
@ SYNC_HANDLER_CLOG
Definition: sync.h:38
@ SYNC_HANDLER_NONE
Definition: sync.h:42
@ SYNC_HANDLER_MULTIXACT_OFFSET
Definition: sync.h:40
SyncRequestType
Definition: sync.h:24
@ SYNC_FILTER_REQUEST
Definition: sync.h:28
@ SYNC_FORGET_REQUEST
Definition: sync.h:27
@ SYNC_UNLINK_REQUEST
Definition: sync.h:26
@ SYNC_REQUEST
Definition: sync.h:25
void SyncPostCheckpoint(void)
Definition: sync.c:209
bool RegisterSyncRequest(const FileTag *ftag, SyncRequestType type, bool retryOnError)
Definition: sync.c:587