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 */
50 /* for a regular file */
53 bool isrelfile; /* is it a relation data file? */
55 datapagemap_t pagemap;
60 struct file_entry_t *next;
63 typedef struct file_entry_t file_entry_t;
68 * New entries are accumulated to a linked list, in process_remote_file
69 * and process_local_file.
76 * After processing all the remote files, the entries in the linked list
77 * are moved to this array. After processing local files, too, all the
78 * local entries are added to the array by filemap_finalize, and sorted
79 * in the final order. After filemap_finalize, all the entries are in
80 * the array, and the linked list is empty.
86 * Summary information. total_size is the total size of the source cluster,
87 * and fetch_size is the number of bytes that needs to be copied.
93 typedef struct filemap_t filemap_t;
95 extern filemap_t * filemap;
97 extern filemap_t *filemap_create(void);
99 extern void calculate_totals(void);
100 extern void print_filemap(void);
102 /* Functions for populating the filemap */
103 extern void process_remote_file(const char *path, file_type_t type, size_t newsize, const char *link_target);
104 extern void process_local_file(const char *path, file_type_t type, size_t newsize, const char *link_target);
105 extern void process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno);
106 extern void filemap_finalize(void);
108 #endif /* FILEMAP_H */