1 /*-------------------------------------------------------------------------
5 * Copyright (c) 2013-2015, PostgreSQL Global Development Group
6 *-------------------------------------------------------------------------
11 #include "storage/relfilenode.h"
12 #include "storage/block.h"
14 #include "datapagemap.h"
17 * For every file found in the local or remote system, we have a file entry
18 * which says what we are going to do with the file. For relation files,
19 * there is also a page map, marking pages in the file that were changed
22 * The enum values are sorted in the order we want actions to be processed.
26 FILE_ACTION_CREATE, /* create local directory or symbolic link */
27 FILE_ACTION_COPY, /* copy whole file, overwriting if exists */
28 FILE_ACTION_COPY_TAIL, /* copy tail from 'oldsize' to 'newsize' */
29 FILE_ACTION_NONE, /* no action (we might still copy modified blocks
30 * based on the parsed WAL) */
31 FILE_ACTION_TRUNCATE, /* truncate local file to 'newsize' bytes */
32 FILE_ACTION_REMOVE /* remove local file / directory / symlink */
42 typedef struct file_entry_t
49 /* for a regular file */
52 bool isrelfile; /* is it a relation data file? */
54 datapagemap_t pagemap;
59 struct file_entry_t *next;
62 typedef struct filemap_t
65 * New entries are accumulated to a linked list, in process_remote_file
66 * and process_local_file.
70 int nlist; /* number of entries currently in list */
73 * After processing all the remote files, the entries in the linked list
74 * are moved to this array. After processing local files, too, all the
75 * local entries are added to the array by filemap_finalize, and sorted
76 * in the final order. After filemap_finalize, all the entries are in
77 * the array, and the linked list is empty.
80 int narray; /* current length of array */
83 * Summary information. total_size is the total size of the source cluster,
84 * and fetch_size is the number of bytes that needs to be copied.
90 extern filemap_t *filemap;
92 extern void filemap_create(void);
93 extern void calculate_totals(void);
94 extern void print_filemap(void);
96 /* Functions for populating the filemap */
97 extern void process_remote_file(const char *path, file_type_t type, size_t newsize, const char *link_target);
98 extern void process_local_file(const char *path, file_type_t type, size_t newsize, const char *link_target);
99 extern void process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno);
100 extern void filemap_finalize(void);
102 #endif /* FILEMAP_H */