@ -51,14 +51,14 @@ filemap_create(void)
}
/*
* Callback for processing remot e file list .
* Callback for processing sourc e file list .
*
* This is called once for every file in the source server . We decide what
* action needs to be taken for the file , depending on whether the file
* exists in the target and whether the size matches .
*/
void
process_remot e_file ( const char * path , file_type_t type , size_t newsize ,
process_sourc e_file ( const char * path , file_type_t type , size_t newsize ,
const char * link_target )
{
bool exists ;
@ -97,7 +97,7 @@ process_remote_file(const char *path, file_type_t type, size_t newsize,
snprintf ( localpath , sizeof ( localpath ) , " %s/%s " , datadir_target , path ) ;
/* Does the corresponding local file exist? */
/* Does the corresponding file exist in the target data dir ? */
if ( lstat ( localpath , & statbuf ) < 0 )
{
if ( errno ! = ENOENT )
@ -185,18 +185,19 @@ process_remote_file(const char *path, file_type_t type, size_t newsize,
*
* If it ' s smaller in the target , it means that it has been
* truncated in the target , or enlarged in the source , or
* both . If it was truncated locally , we need to copy the
* missing tail from the remot e system . If it was enlarged in
* the remot e system , there will be WAL records in the remot e
* both . If it was truncated in the target , we need to copy the
* missing tail from the sourc e system . If it was enlarged in
* the sourc e system , there will be WAL records in the sourc e
* system for the new blocks , so we wouldn ' t need to copy them
* here . But we don ' t know which scenario we ' re dealing with ,
* and there ' s no harm in copying the missing blocks now , so
* do it now .
*
* If it ' s the same size , do nothing here . Any locally
* modified blocks will be copied based on parsing the local
* WAL , and any remotely modified blocks will be updated after
* rewinding , when the remote WAL is replayed .
* If it ' s the same size , do nothing here . Any blocks modified
* in the target will be copied based on parsing the target
* system ' s WAL , and any blocks modified in the source will be
* updated after rewinding , when the source system ' s WAL is
* replayed .
*/
oldsize = statbuf . st_size ;
if ( oldsize < newsize )
@ -233,14 +234,15 @@ process_remote_file(const char *path, file_type_t type, size_t newsize,
}
/*
* Callback for processing local file list .
* Callback for processing target file list .
*
* All remote files must be already processed before calling this . This only
* marks local files that didn ' t exist in the remote system for deletion .
* All source files must be already processed before calling this . This only
* marks target data directory ' s files that didn ' t exist in the source for
* deletion .
*/
void
process_local _file ( const char * path , file_type_t type , size_t oldsize ,
const char * link_target )
process_target _file ( const char * path , file_type_t type , size_t oldsize ,
const char * link_target )
{
bool exists ;
char localpath [ MAXPGPATH ] ;
@ -266,7 +268,7 @@ process_local_file(const char *path, file_type_t type, size_t oldsize,
if ( map - > nlist = = 0 )
{
/* should not happen */
pg_fatal ( " remot e file list is empty\n " ) ;
pg_fatal ( " sourc e file list is empty\n " ) ;
}
filemap_list_to_array ( map ) ;
@ -288,7 +290,7 @@ process_local_file(const char *path, file_type_t type, size_t oldsize,
exists = ( bsearch ( & key_ptr , map - > array , map - > narray , sizeof ( file_entry_t * ) ,
path_cmp ) ! = NULL ) ;
/* Remove any file or folder that doesn't exist in the remot e system. */
/* Remove any file or folder that doesn't exist in the sourc e system. */
if ( ! exists )
{
entry = pg_malloc ( sizeof ( file_entry_t ) ) ;
@ -313,16 +315,16 @@ process_local_file(const char *path, file_type_t type, size_t oldsize,
else
{
/*
* We already handled all files that exist in the remot e system in
* process_remot e_file ( ) .
* We already handled all files that exist in the sourc e system in
* process_sourc e_file ( ) .
*/
}
}
/*
* This callback gets called while we read the old WAL , for every block that
* have changed in the local system . It makes note of all the changed blocks
* in the pagemap of the file .
* This callback gets called while we read the WAL in the target , for every
* block that have changed in the target system . It makes note of all the
* changed blocks in the pagemap of the file .
*/
void
process_block_change ( ForkNumber forknum , RelFileNode rnode , BlockNumber blkno )
@ -388,8 +390,8 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
{
/*
* If we don ' t have any record of this file in the file map , it means
* that it ' s a relation that doesn ' t exist in the remot e system , and
* it was subsequently removed in the local system , too . We can safely
* that it ' s a relation that doesn ' t exist in the sourc e system , and
* it was subsequently removed in the target system , too . We can safely
* ignore it .
*/
}