PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <sys/stat.h>
#include <unistd.h>
#include "catalog/pg_tablespace_d.h"
#include "common/file_utils.h"
#include "common/hashfn_unstable.h"
#include "common/string.h"
#include "datapagemap.h"
#include "filemap.h"
#include "pg_rewind.h"
#include "lib/simplehash.h"
Go to the source code of this file.
Data Structures | |
struct | keepwal_entry |
struct | exclude_list_item |
Macros | |
#define | SH_PREFIX filehash |
#define | SH_ELEMENT_TYPE file_entry_t |
#define | SH_KEY_TYPE const char * |
#define | SH_KEY path |
#define | SH_HASH_KEY(tb, key) hash_string(key) |
#define | SH_EQUAL(tb, a, b) (strcmp(a, b) == 0) |
#define | SH_SCOPE static inline |
#define | SH_RAW_ALLOCATOR pg_malloc0 |
#define | SH_DECLARE |
#define | SH_DEFINE |
#define | FILEHASH_INITIAL_SIZE 1000 |
#define | SH_PREFIX keepwal |
#define | SH_ELEMENT_TYPE keepwal_entry |
#define | SH_KEY_TYPE const char * |
#define | SH_KEY path |
#define | SH_HASH_KEY(tb, key) hash_string(key) |
#define | SH_EQUAL(tb, a, b) (strcmp(a, b) == 0) |
#define | SH_SCOPE static inline |
#define | SH_RAW_ALLOCATOR pg_malloc0 |
#define | SH_DECLARE |
#define | SH_DEFINE |
#define | KEEPWAL_INITIAL_SIZE 1000 |
Typedefs | |
typedef struct keepwal_entry | keepwal_entry |
Functions | |
static bool | isRelDataFile (const char *path) |
static char * | datasegpath (RelFileLocator rlocator, ForkNumber forknum, BlockNumber segno) |
static file_entry_t * | insert_filehash_entry (const char *path) |
static file_entry_t * | lookup_filehash_entry (const char *path) |
static bool | keepwal_entry_exists (const char *path) |
static int | final_filemap_cmp (const void *a, const void *b) |
static bool | check_file_excluded (const char *path, bool is_source) |
void | filehash_init (void) |
void | keepwal_init (void) |
void | keepwal_add_entry (const char *path) |
void | process_source_file (const char *path, file_type_t type, size_t size, const char *link_target) |
void | process_target_file (const char *path, file_type_t type, size_t size, const char *link_target) |
void | process_target_wal_block_change (ForkNumber forknum, RelFileLocator rlocator, BlockNumber blkno) |
static const char * | action_to_str (file_action_t action) |
void | calculate_totals (filemap_t *filemap) |
void | print_filemap (filemap_t *filemap) |
static file_action_t | decide_file_action (file_entry_t *entry) |
filemap_t * | decide_file_actions (void) |
Variables | |
static filehash_hash * | filehash |
static keepwal_hash * | keepwal = NULL |
static const char *const | excludeDirContents [] |
static const struct exclude_list_item | excludeFiles [] |
#define SH_ELEMENT_TYPE file_entry_t |
#define SH_ELEMENT_TYPE keepwal_entry |
#define SH_HASH_KEY | ( | tb, | |
key | |||
) | hash_string(key) |
#define SH_HASH_KEY | ( | tb, | |
key | |||
) | hash_string(key) |
#define SH_RAW_ALLOCATOR pg_malloc0 |
#define SH_RAW_ALLOCATOR pg_malloc0 |
typedef struct keepwal_entry keepwal_entry |
|
static |
Definition at line 473 of file filemap.c.
References generate_unaccent_rules::action, FILE_ACTION_COPY, FILE_ACTION_COPY_TAIL, FILE_ACTION_CREATE, FILE_ACTION_NONE, FILE_ACTION_REMOVE, and FILE_ACTION_TRUNCATE.
Referenced by print_filemap().
void calculate_totals | ( | filemap_t * | filemap | ) |
Definition at line 499 of file filemap.c.
References file_entry_t::action, datapagemap::bitmapsize, datapagemap_iterate(), datapagemap_next(), filemap_t::entries, filemap_t::fetch_size, FILE_ACTION_COPY, FILE_ACTION_COPY_TAIL, FILE_TYPE_REGULAR, i, filemap_t::nentries, pg_free(), file_entry_t::source_size, file_entry_t::source_type, file_entry_t::target_pages_to_overwrite, file_entry_t::target_size, and filemap_t::total_size.
Referenced by main().
|
static |
Definition at line 409 of file filemap.c.
References excludeDirContents, excludeFiles, filename, last_dir_separator(), exclude_list_item::match_prefix, MAXPGPATH, exclude_list_item::name, name, pg_log_debug, PG_TEMP_FILE_PREFIX, PG_TEMP_FILES_DIR, and snprintf.
Referenced by decide_file_action().
|
static |
Definition at line 653 of file filemap.c.
References pfree(), psprintf(), and relpathperm.
Referenced by isRelDataFile(), and process_target_wal_block_change().
|
static |
Definition at line 700 of file filemap.c.
References Assert, check_file_excluded(), FILE_ACTION_COPY, FILE_ACTION_COPY_TAIL, FILE_ACTION_CREATE, FILE_ACTION_NONE, FILE_ACTION_REMOVE, FILE_ACTION_TRUNCATE, FILE_TYPE_DIRECTORY, FILE_TYPE_REGULAR, FILE_TYPE_SYMLINK, FILE_TYPE_UNDEFINED, file_entry_t::isrelfile, keepwal_entry_exists(), file_entry_t::path, pg_fatal, pg_log_debug, pg_str_endswith(), file_entry_t::source_exists, file_entry_t::source_size, file_entry_t::source_type, file_entry_t::target_exists, file_entry_t::target_size, and file_entry_t::target_type.
Referenced by decide_file_actions().
filemap_t* decide_file_actions | ( | void | ) |
Definition at line 861 of file filemap.c.
References file_entry_t::action, decide_file_action(), filemap_t::entries, filehash, final_filemap_cmp(), i, filemap_t::nentries, pg_malloc(), and qsort.
Referenced by main().
void filehash_init | ( | void | ) |
Definition at line 196 of file filemap.c.
References filehash, and FILEHASH_INITIAL_SIZE.
Referenced by main().
|
static |
Definition at line 680 of file filemap.c.
References a, b, fa(), fb(), and FILE_ACTION_REMOVE.
Referenced by decide_file_actions().
|
static |
Definition at line 203 of file filemap.c.
References file_entry_t::action, datapagemap::bitmap, datapagemap::bitmapsize, FILE_ACTION_UNDECIDED, FILE_TYPE_UNDEFINED, filehash, isRelDataFile(), file_entry_t::isrelfile, file_entry_t::path, pg_strdup(), file_entry_t::source_exists, file_entry_t::source_link_target, file_entry_t::source_size, file_entry_t::source_type, file_entry_t::target_exists, file_entry_t::target_link_target, file_entry_t::target_pages_to_overwrite, file_entry_t::target_size, and file_entry_t::target_type.
Referenced by process_source_file(), and process_target_file().
|
static |
Definition at line 570 of file filemap.c.
References datasegpath(), RelFileLocator::dbOid, InvalidOid, InvalidRelFileNumber, MAIN_FORKNUM, pfree(), RelFileLocator::relNumber, RelFileLocator::spcOid, and TABLESPACE_VERSION_DIRECTORY.
Referenced by insert_filehash_entry(), and process_source_file().
void keepwal_add_entry | ( | const char * | path | ) |
Definition at line 250 of file filemap.c.
References Assert, keepwal, keepwal_entry::path, and pg_strdup().
Referenced by findLastCheckpoint().
|
static |
void keepwal_init | ( | void | ) |
Definition at line 242 of file filemap.c.
References keepwal, and KEEPWAL_INITIAL_SIZE.
Referenced by main().
|
static |
Definition at line 233 of file filemap.c.
References filehash.
Referenced by process_target_wal_block_change().
void print_filemap | ( | filemap_t * | filemap | ) |
Definition at line 540 of file filemap.c.
References file_entry_t::action, action_to_str(), datapagemap::bitmapsize, datapagemap_print(), filemap_t::entries, fflush(), FILE_ACTION_NONE, i, filemap_t::nentries, file_entry_t::path, pg_log_debug, generate_unaccent_rules::stdout, and file_entry_t::target_pages_to_overwrite.
Referenced by main().
void process_source_file | ( | const char * | path, |
file_type_t | type, | ||
size_t | size, | ||
const char * | link_target | ||
) |
Definition at line 279 of file filemap.c.
References FILE_TYPE_DIRECTORY, FILE_TYPE_REGULAR, FILE_TYPE_SYMLINK, insert_filehash_entry(), isRelDataFile(), pg_fatal, pg_strdup(), size, file_entry_t::source_exists, file_entry_t::source_link_target, file_entry_t::source_size, file_entry_t::source_type, and type.
Referenced by main().
void process_target_file | ( | const char * | path, |
file_type_t | type, | ||
size_t | size, | ||
const char * | link_target | ||
) |
Definition at line 315 of file filemap.c.
References FILE_TYPE_DIRECTORY, FILE_TYPE_SYMLINK, insert_filehash_entry(), pg_fatal, pg_strdup(), size, file_entry_t::target_exists, file_entry_t::target_link_target, file_entry_t::target_size, file_entry_t::target_type, and type.
Referenced by main().
void process_target_wal_block_change | ( | ForkNumber | forknum, |
RelFileLocator | rlocator, | ||
BlockNumber | blkno | ||
) |
Definition at line 352 of file filemap.c.
References Assert, datapagemap_add(), datasegpath(), FILE_TYPE_REGULAR, file_entry_t::isrelfile, lookup_filehash_entry(), file_entry_t::path, pfree(), pg_fatal, file_entry_t::source_exists, file_entry_t::target_exists, file_entry_t::target_pages_to_overwrite, and file_entry_t::target_type.
Referenced by extractPageInfo().
|
static |
Definition at line 116 of file filemap.c.
Referenced by check_file_excluded().
|
static |
Definition at line 116 of file filemap.c.
Referenced by check_file_excluded().
|
static |
Definition at line 55 of file filemap.c.
Referenced by decide_file_actions(), filehash_init(), insert_filehash_entry(), and lookup_filehash_entry().
|
static |
Definition at line 88 of file filemap.c.
Referenced by keepwal_add_entry(), keepwal_entry_exists(), and keepwal_init().