@@ -654,7 +654,7 @@ pg_switch_wal(void)
654
654
655
655
/*
656
656
* Check if the instance supports ptrack
657
- * TODOImplement check of ptrack_version() instead of existing one
657
+ * TODOMaybe we should rather check ptrack_version()?
658
658
*/
659
659
static bool
660
660
pg_ptrack_support (void )
@@ -959,7 +959,6 @@ pg_stop_backup(pgBackup *backup)
959
959
fwrite (PQgetvalue (res ,0 ,1 ),1 ,strlen (PQgetvalue (res ,0 ,1 )),fp );
960
960
fclose (fp );
961
961
962
- /* TODO What for do we save the file into backup_list? */
963
962
/*
964
963
* It's vital to check if backup_files_list is initialized,
965
964
* 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)
1213
1212
* verify checksum and copy.
1214
1213
* In incremental backup mode, copy only files or datafiles' pages changed after
1215
1214
* previous backup.
1216
- * TODO review
1217
1215
*/
1218
1216
static void
1219
1217
backup_files (void * arg )
@@ -1268,31 +1266,11 @@ backup_files(void *arg)
1268
1266
1269
1267
if (S_ISREG (buf .st_mode ))
1270
1268
{
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
-
1290
1269
/* copy the file into backup */
1291
1270
if (file -> is_datafile )
1292
1271
{
1293
1272
if (is_compressed_data_file (file ))
1294
1273
{
1295
- /* TODO review */
1296
1274
size_t skip_size = 0 ;
1297
1275
if (backup_compressed_file_partially (file ,arguments ,& skip_size ))
1298
1276
{
@@ -1345,7 +1323,6 @@ backup_files(void *arg)
1345
1323
1346
1324
/*
1347
1325
* Append files to the backup list array.
1348
- * TODO review
1349
1326
*/
1350
1327
static void
1351
1328
add_pgdata_files (parray * files ,const char * root )
@@ -1370,7 +1347,7 @@ add_pgdata_files(parray *files, const char *root)
1370
1347
/* data files are under "base", "global", or "pg_tblspc" */
1371
1348
relative = GetRelativePath (file -> path ,root );
1372
1349
if (!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 )&&
1374
1351
!path_is_prefix_of_path (PG_TBLSPC_DIR ,relative ))
1375
1352
continue ;
1376
1353
@@ -1600,7 +1577,10 @@ process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
1600
1577
pg_free (rel_path );
1601
1578
}
1602
1579
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
+ */
1604
1584
static void
1605
1585
make_pagemap_from_ptrack (parray * files )
1606
1586
{
@@ -1622,6 +1602,8 @@ make_pagemap_from_ptrack(parray *files)
1622
1602
size_t ptrack_nonparsed_size = 0 ;
1623
1603
size_t start_addr ;
1624
1604
1605
+ /* Compute db_oid and rel_oid of the relation from the path */
1606
+
1625
1607
tablespace = strstr (p -> ptrack_path ,PG_TBLSPC_DIR );
1626
1608
1627
1609
if (tablespace )
@@ -1647,19 +1629,25 @@ make_pagemap_from_ptrack(parray *files)
1647
1629
p -> path );
1648
1630
1649
1631
sscanf (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 */
1651
1634
ptrack_nonparsed = pg_ptrack_get_and_clear (tablespace_oid ,db_oid ,
1652
1635
rel_oid ,& ptrack_nonparsed_size );
1653
1636
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 )
1657
1644
p -> pagemap .bitmapsize = ptrack_nonparsed_size - start_addr ;
1658
1645
else
1659
- p -> pagemap .bitmapsize = RELSEG_SIZE /8 ;
1646
+ p -> pagemap .bitmapsize = RELSEG_SIZE /HEAPBLOCKS_PER_BYTE ;
1660
1647
1661
1648
p -> pagemap .bitmap = pg_malloc (p -> pagemap .bitmapsize );
1662
1649
memcpy (p -> pagemap .bitmap ,ptrack_nonparsed + start_addr ,p -> pagemap .bitmapsize );
1650
+
1663
1651
pg_free (ptrack_nonparsed );
1664
1652
}
1665
1653
}
@@ -1815,7 +1803,7 @@ StreamLog(void *arg)
1815
1803
* cfs_mmap() and cfs_munmap() function definitions mirror ones
1816
1804
* from cfs.h, but doesn't use atomic variables, since they are
1817
1805
* not allowed in frontend code.
1818
- * TODO Is it so?
1806
+ *
1819
1807
* Since we cannot take atomic lock on files compressed by CFS,
1820
1808
* it should care about not changing files while backup is running.
1821
1809
*/