Skip to content

Commit ea32b67

Browse files
committed
[PBCKP-146] - fio_get_crc32 - add "missing_ok" parameter
1 parent fcc17ee commit ea32b67

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

src/archive.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
512512
pg_crc32 crc32_src;
513513
pg_crc32 crc32_dst;
514514

515-
crc32_src = fio_get_crc32(from_fullpath, FIO_DB_HOST, false);
516-
crc32_dst = fio_get_crc32(to_fullpath, FIO_BACKUP_HOST, false);
515+
crc32_src = fio_get_crc32(from_fullpath, FIO_DB_HOST, false, false);
516+
crc32_dst = fio_get_crc32(to_fullpath, FIO_BACKUP_HOST, false, false);
517517

518518
if (crc32_src == crc32_dst)
519519
{
@@ -761,8 +761,8 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
761761
pg_crc32 crc32_dst;
762762

763763
/* TODO: what if one of them goes missing? */
764-
crc32_src = fio_get_crc32(from_fullpath, FIO_DB_HOST, false);
765-
crc32_dst = fio_get_crc32(to_fullpath_gz, FIO_BACKUP_HOST, true);
764+
crc32_src = fio_get_crc32(from_fullpath, FIO_DB_HOST, false, false);
765+
crc32_dst = fio_get_crc32(to_fullpath_gz, FIO_BACKUP_HOST, true, false);
766766

767767
if (crc32_src == crc32_dst)
768768
{

src/data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ backup_non_data_file(pgFile *file, pgFile *prev_file,
802802
file->mtime <= parent_backup_time))
803803
{
804804

805-
file->crc = fio_get_crc32(from_fullpath, FIO_DB_HOST, false);
805+
file->crc = fio_get_crc32(from_fullpath, FIO_DB_HOST, false, true);
806806

807807
/* ...and checksum is the same... */
808808
if (EQ_TRADITIONAL_CRC32(file->crc, prev_file->crc))
@@ -1327,7 +1327,7 @@ restore_non_data_file(parray *parent_chain, pgBackup *dest_backup,
13271327
if (already_exists)
13281328
{
13291329
/* compare checksums of already existing file and backup file */
1330-
pg_crc32 file_crc = fio_get_crc32(to_fullpath, FIO_DB_HOST, false);
1330+
pg_crc32 file_crc = fio_get_crc32(to_fullpath, FIO_DB_HOST, false, false);
13311331

13321332
if (file_crc == tmp_file->crc)
13331333
{

src/utils/file.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,8 @@ fio_sync(char const* path, fio_location location)
13571357

13581358
/* Get crc32 of file */
13591359
pg_crc32
1360-
fio_get_crc32(const char *file_path, fio_location location, bool decompress)
1360+
fio_get_crc32(const char *file_path, fio_location location,
1361+
bool decompress, bool missing_ok)
13611362
{
13621363
if (fio_is_remote(location))
13631364
{
@@ -1371,6 +1372,8 @@ fio_get_crc32(const char *file_path, fio_location location, bool decompress)
13711372

13721373
if (decompress)
13731374
hdr.arg = 1;
1375+
if (missing_ok)
1376+
hdr.arg |= 2;
13741377

13751378
IO_CHECK(fio_write_all(fio_stdout, &hdr, sizeof(hdr)), sizeof(hdr));
13761379
IO_CHECK(fio_write_all(fio_stdout, file_path, path_len), path_len);
@@ -1381,9 +1384,9 @@ fio_get_crc32(const char *file_path, fio_location location, bool decompress)
13811384
else
13821385
{
13831386
if (decompress)
1384-
return pgFileGetCRCgz(file_path, true, true);
1387+
return pgFileGetCRCgz(file_path, true, missing_ok);
13851388
else
1386-
return pgFileGetCRC(file_path, true, true);
1389+
return pgFileGetCRC(file_path, true, missing_ok);
13871390
}
13881391
}
13891392

@@ -3381,9 +3384,9 @@ fio_communicate(int in, int out)
33813384
case FIO_GET_CRC32:
33823385
/* calculate crc32 for a file */
33833386
if (hdr.arg == 1)
3384-
crc = pgFileGetCRCgz(buf, true, true);
3387+
crc = pgFileGetCRCgz(buf, true, (hdr.arg & 2) != 0);
33853388
else
3386-
crc = pgFileGetCRC(buf, true, true);
3389+
crc = pgFileGetCRC(buf, true, (hdr.arg & 2) != 0);
33873390
IO_CHECK(fio_write_all(out, &crc, sizeof(crc)), sizeof(crc));
33883391
break;
33893392
case FIO_GET_CHECKSUM_MAP:

src/utils/file.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ extern int fio_truncate(int fd, off_t size);
120120
extern int fio_close(int fd);
121121
extern void fio_disconnect(void);
122122
extern int fio_sync(char const* path, fio_location location);
123-
extern pg_crc32 fio_get_crc32(const char *file_path, fio_location location, bool decompress);
123+
extern pg_crc32 fio_get_crc32(const char *file_path, fio_location location,
124+
bool decompress, bool missing_ok);
124125

125126
extern int fio_rename(char const* old_path, char const* new_path, fio_location location);
126127
extern int fio_symlink(char const* target, char const* link_path, bool overwrite, fio_location location);

0 commit comments

Comments
 (0)