1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2026-06-21 01:34:15 +02:00

[PBCKP-345] more consistent use of int64_t for file sizes

This commit is contained in:
Yura Sokolov
2022-11-17 01:45:21 +03:00
parent e9055001ac
commit 0e24b62a73
10 changed files with 32 additions and 26 deletions
+1 -1
View File
@@ -390,7 +390,7 @@ push_file_internal(const char *wal_file_name, const char *pg_xlog_dir,
/* partial handling */
pio_stat_t st;
int partial_try_count = 0;
ssize_t partial_file_size = 0;
int64_t partial_file_size = 0;
bool partial_is_stale = true;
size_t len;
err_i err = $noerr();
+3 -3
View File
@@ -439,7 +439,7 @@ catchup_thread_runner(void *arg)
if (file->write_size == BYTES_INVALID)
{
elog(LOG, "Skipping the unchanged file: \"%s\", read %zu bytes", from_fullpath, file->read_size);
elog(LOG, "Skipping the unchanged file: \"%s\", read %lld bytes", from_fullpath, (long long)file->read_size);
continue;
}
@@ -630,8 +630,8 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
/* for fancy reporting */
time_t start_time, end_time;
ssize_t transfered_datafiles_bytes = 0;
ssize_t transfered_walfiles_bytes = 0;
int64_t transfered_datafiles_bytes = 0;
int64_t transfered_walfiles_bytes = 0;
char pretty_source_bytes[20];
err_i err = $noerr();
+12 -7
View File
@@ -507,7 +507,8 @@ backup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpat
* NOTE This is a normal situation, if the file size has changed
* since the moment we computed it.
*/
file->n_blocks = file->size/BLCKSZ;
file->n_blocks = (typeof(file->n_blocks))(file->size/BLCKSZ);
Assert((int64_t)file->n_blocks * BLCKSZ == file->size);
/*
* Skip unchanged file only if it exists in previous backup.
@@ -611,12 +612,15 @@ backup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpat
elog(ERROR, "Cannot read file \"%s\"", from_fullpath);
}
file->read_size = rc * BLCKSZ;
file->read_size = (int64_t)rc * BLCKSZ;
/* refresh n_blocks for FULL and DELTA */
if (backup_mode == BACKUP_MODE_FULL ||
backup_mode == BACKUP_MODE_DIFF_DELTA)
file->n_blocks = file->read_size / BLCKSZ;
{
file->n_blocks = (typeof(file->n_blocks))(file->read_size / BLCKSZ);
Assert((int64_t)file->n_blocks * BLCKSZ == file->read_size);
}
/* Determine that file didn`t changed in case of incremental backup */
if (backup_mode != BACKUP_MODE_FULL &&
@@ -650,7 +654,7 @@ cleanup:
void
catchup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpath,
XLogRecPtr sync_lsn, BackupMode backup_mode,
uint32 checksum_version, size_t prev_size)
uint32 checksum_version, int64_t prev_size)
{
int rc;
bool use_pagemap;
@@ -760,7 +764,7 @@ catchup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpa
elog(ERROR, "Cannot read file \"%s\"", from_fullpath);
}
file->read_size = rc * BLCKSZ;
file->read_size = (int64_t)rc * BLCKSZ;
/* Determine that file didn`t changed in case of incremental catchup */
if (backup_mode != BACKUP_MODE_FULL &&
@@ -1595,7 +1599,8 @@ check_data_file(ConnectionArgs *arguments, pgFile *file,
* NOTE This is a normal situation, if the file size has changed
* since the moment we computed it.
*/
nblocks = file->size/BLCKSZ;
nblocks = (typeof(nblocks))(file->size/BLCKSZ);
Assert((int64_t)nblocks * BLCKSZ == file->size);
for (blknum = 0; blknum < nblocks; blknum++)
{
@@ -2275,7 +2280,7 @@ copy_pages(const char *to_fullpath, const char *from_fullpath,
elog(ERROR, "Cannot seek to end of file position in destination file \"%s\": %s",
to_fullpath, strerror(errno));
{
long pos = ftell(out);
int64_t pos = ftell(out);
if (pos < 0)
elog(ERROR, "Cannot get position in destination file \"%s\": %s",
+3 -3
View File
@@ -794,8 +794,8 @@ delete_walfiles_in_tli(InstanceState *instanceState, XLogRecPtr keep_lsn, timeli
char first_to_del_str[MAXFNAMELEN];
char oldest_to_keep_str[MAXFNAMELEN];
int i;
size_t wal_size_logical = 0;
size_t wal_size_actual = 0;
int64_t wal_size_logical = 0;
int64_t wal_size_actual = 0;
char wal_pretty_size[20];
bool purge_all = false;
@@ -837,7 +837,7 @@ delete_walfiles_in_tli(InstanceState *instanceState, XLogRecPtr keep_lsn, timeli
/* sanity */
if (OldestToKeepSegNo > FirstToDeleteSegNo)
{
wal_size_logical = (OldestToKeepSegNo - FirstToDeleteSegNo) * xlog_seg_size;
wal_size_logical = (int64_t)(OldestToKeepSegNo - FirstToDeleteSegNo) * xlog_seg_size;
/* In case of 'purge all' scenario OldestToKeepSegNo will be deleted too */
if (purge_all)
+1 -1
View File
@@ -54,7 +54,7 @@ slurpFile(fio_location location, const char *datadir, const char *path, size_t *
ft_logerr(FT_FATAL, $errmsg(err), "slurpFile");
}
if (statbuf.pst_size > SIZE_MAX)
if (statbuf.pst_size > SSIZE_MAX)
ft_log(FT_FATAL, "file \"%s\" is too large: %lld",
fullpath, (long long)statbuf.pst_size);
+5 -5
View File
@@ -214,14 +214,14 @@ typedef struct pgFile
pio_file_kind_e kind; /* kind of file */
uint32_t mode; /* protection (permission) */
uint64_t size; /* size of the file */
int64_t size; /* size of the file */
uint64_t read_size; /* size of the portion read (if only some pages are
int64_t read_size; /* size of the portion read (if only some pages are
backed up, it's different from size) */
int64_t write_size; /* size of the backed-up file. BYTES_INVALID means
that the file existed but was not backed up
because not modified since last backup. */
uint64_t uncompressed_size; /* size of the backed-up file before compression
int64_t uncompressed_size; /* size of the backed-up file before compression
* and adding block headers.
*/
time_t mtime; /* file st_mtime attribute, can be used only
@@ -593,7 +593,7 @@ struct timelineInfo {
XLogSegNo end_segno; /* last present segment in this timeline */
size_t n_xlog_files; /* number of segments (only really existing)
* does not include lost segments */
size_t size; /* space on disk taken by regular WAL files */
int64_t size; /* space on disk taken by regular WAL files */
parray *backups; /* array of pgBackup sturctures with info
* about backups belonging to this timeline */
parray *xlog_filelist; /* array of ordinary WAL segments, '.partial'
@@ -1055,7 +1055,7 @@ extern bool check_data_file(ConnectionArgs *arguments, pgFile *file,
extern void catchup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpath,
XLogRecPtr sync_lsn, BackupMode backup_mode,
uint32 checksum_version, size_t prev_size);
uint32 checksum_version, int64_t prev_size);
extern void backup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpath,
XLogRecPtr prev_backup_start_lsn, BackupMode backup_mode,
CompressAlg calg, int clevel, uint32 checksum_version,
+1 -1
View File
@@ -1089,7 +1089,7 @@ show_archive_json(const char *instance_name, uint32 xlog_seg_size,
appendPQExpBuffer(buf, "%zu", tlinfo->n_xlog_files);
json_add_key(buf, "size", json_level);
appendPQExpBuffer(buf, "%zu", tlinfo->size);
appendPQExpBuffer(buf, "%lld", (long long)tlinfo->size);
json_add_key(buf, "zratio", json_level);
+3 -3
View File
@@ -403,9 +403,9 @@ copy_pgcontrol_file(fio_location from_location, const char *from_fullpath,
digestControlFile(&ControlFile, buffer, size);
file->crc = ControlFile.crc;
file->read_size = size;
file->write_size = size;
file->uncompressed_size = size;
file->read_size = (int64_t)size;
file->write_size = (int64_t)size;
file->uncompressed_size = (int64_t)size;
writeControlFile(to_location, to_fullpath, &ControlFile);
+2 -1
View File
@@ -53,7 +53,7 @@ typedef struct
{
pio_file_kind_e kind;
mode_t mode;
size_t size;
int64_t size;
time_t mtime;
bool is_datafile;
Oid tblspcOid;
@@ -1914,6 +1914,7 @@ fio_send_pages(const char *to_fullpath, const char *from_fullpath, pgFile *file,
}
req.arg.nblocks = file->size/BLCKSZ;
Assert((int64_t)req.arg.nblocks * BLCKSZ == file->size);
req.arg.segmentno = file->segno * RELSEG_SIZE;
req.arg.horizonLsn = horizonLsn;
req.arg.checksumVersion = checksum_version;
+1 -1
View File
@@ -105,7 +105,7 @@ typedef enum pio_file_kind {
} pio_file_kind_e;
typedef struct pio_stat {
uint64_t pst_size;
int64_t pst_size;
int64_t pst_mtime;
uint32_t pst_mode;
pio_file_kind_e pst_kind;