@@ -654,7 +654,7 @@ pg_switch_wal(void)
654654
655655/*
656656 * Check if the instance supports ptrack
657- * TODOImplement check of ptrack_version() instead of existing one
657+ * TODOMaybe we should rather check ptrack_version()?
658658 */
659659static bool
660660pg_ptrack_support (void )
@@ -959,7 +959,6 @@ pg_stop_backup(pgBackup *backup)
959959fwrite (PQgetvalue (res ,0 ,1 ),1 ,strlen (PQgetvalue (res ,0 ,1 )),fp );
960960fclose (fp );
961961
962- /* TODO What for do we save the file into backup_list? */
963962/*
964963 * It's vital to check if backup_files_list is initialized,
965964 * because we could get here because the backup was interrupted
@@ -1213,7 +1212,6 @@ backup_compressed_file_partially(pgFile *file, void *arg, size_t *skip_size)
12131212 * verify checksum and copy.
12141213 * In incremental backup mode, copy only files or datafiles' pages changed after
12151214 * previous backup.
1216- * TODO review
12171215 */
12181216static void
12191217backup_files (void * arg )
@@ -1268,31 +1266,11 @@ backup_files(void *arg)
12681266
12691267if (S_ISREG (buf .st_mode ))
12701268{
1271- /* skip files which have not been modified since last backup */
1272- /* TODO Implement: compare oldfile and newfile checksum. Now it's just a stub */
1273- if (arguments -> prev_backup_filelist )
1274- {
1275- pgFile * prev_file = NULL ;
1276- pgFile * * p = (pgFile * * )parray_bsearch (arguments -> prev_backup_filelist ,
1277- file ,pgFileComparePath );
1278- if (p )
1279- prev_file = * p ;
1280-
1281- if (prev_file && false)
1282- {
1283- file -> write_size = BYTES_INVALID ;
1284- elog (LOG ,"File \"%s\" has not changed since previous backup" ,
1285- file -> path );
1286- continue ;
1287- }
1288- }
1289-
12901269/* copy the file into backup */
12911270if (file -> is_datafile )
12921271{
12931272if (is_compressed_data_file (file ))
12941273{
1295- /* TODO review */
12961274size_t skip_size = 0 ;
12971275if (backup_compressed_file_partially (file ,arguments ,& skip_size ))
12981276{
@@ -1345,7 +1323,6 @@ backup_files(void *arg)
13451323
13461324/*
13471325 * Append files to the backup list array.
1348- * TODO review
13491326 */
13501327static void
13511328add_pgdata_files (parray * files ,const char * root )
@@ -1370,7 +1347,7 @@ add_pgdata_files(parray *files, const char *root)
13701347/* data files are under "base", "global", or "pg_tblspc" */
13711348relative = GetRelativePath (file -> path ,root );
13721349if (!path_is_prefix_of_path ("base" ,relative )&&
1373- /* !path_is_prefix_of_path("global", relative) &&*/ //TODO What's wrong with this line?
1350+ !path_is_prefix_of_path ("global" ,relative )&&
13741351!path_is_prefix_of_path (PG_TBLSPC_DIR ,relative ))
13751352continue ;
13761353
@@ -1600,7 +1577,10 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
16001577pg_free (rel_path );
16011578}
16021579
1603- /* TODO review it */
1580+ /*
1581+ * Given a list of files in the instance to backup, build a pagemap for each
1582+ * data file that has ptrack. Result is saved in the pagemap field of pgFile.
1583+ */
16041584static void
16051585make_pagemap_from_ptrack (parray * files )
16061586{
@@ -1622,6 +1602,8 @@ make_pagemap_from_ptrack(parray *files)
16221602size_t ptrack_nonparsed_size = 0 ;
16231603size_t start_addr ;
16241604
1605+ /* Compute db_oid and rel_oid of the relation from the path */
1606+
16251607tablespace = strstr (p -> ptrack_path ,PG_TBLSPC_DIR );
16261608
16271609if (tablespace )
@@ -1647,19 +1629,25 @@ make_pagemap_from_ptrack(parray *files)
16471629p -> path );
16481630
16491631sscanf (p -> path + sep_iter + 1 ,"%u/%u" ,& db_oid ,& rel_oid );
1650-
1632+
1633+ /* get ptrack map for all segments of the relation in a raw format */
16511634ptrack_nonparsed = pg_ptrack_get_and_clear (tablespace_oid ,db_oid ,
16521635rel_oid ,& ptrack_nonparsed_size );
16531636
1654- /* TODO What is 8? */
1655- start_addr = (RELSEG_SIZE /8 )* p -> segno ;
1656- if (start_addr + RELSEG_SIZE /8 > ptrack_nonparsed_size )
1637+ /*
1638+ * FIXME When do we cut VARHDR from ptrack_nonparsed?
1639+ * Compute the beginning of the ptrack map related to this segment
1640+ */
1641+ start_addr = (RELSEG_SIZE /HEAPBLOCKS_PER_BYTE )* p -> segno ;
1642+
1643+ if (start_addr + RELSEG_SIZE /HEAPBLOCKS_PER_BYTE > ptrack_nonparsed_size )
16571644p -> pagemap .bitmapsize = ptrack_nonparsed_size - start_addr ;
16581645else
1659- p -> pagemap .bitmapsize = RELSEG_SIZE /8 ;
1646+ p -> pagemap .bitmapsize = RELSEG_SIZE /HEAPBLOCKS_PER_BYTE ;
16601647
16611648p -> pagemap .bitmap = pg_malloc (p -> pagemap .bitmapsize );
16621649memcpy (p -> pagemap .bitmap ,ptrack_nonparsed + start_addr ,p -> pagemap .bitmapsize );
1650+
16631651pg_free (ptrack_nonparsed );
16641652}
16651653}
@@ -1815,7 +1803,7 @@ StreamLog(void *arg)
18151803 * cfs_mmap() and cfs_munmap() function definitions mirror ones
18161804 * from cfs.h, but doesn't use atomic variables, since they are
18171805 * not allowed in frontend code.
1818- * TODO Is it so?
1806+ *
18191807 * Since we cannot take atomic lock on files compressed by CFS,
18201808 * it should care about not changing files while backup is running.
18211809 */