Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5adeae5

Browse files
committed
clarify usage of backup_content.control key 'is_datafile', add key 'is_cfs'
1 parent26b8051 commit5adeae5

File tree

7 files changed

+43
-49
lines changed

7 files changed

+43
-49
lines changed

‎backup.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ backup_files(void *arg)
13681368
/* copy the file into backup */
13691369
if (file->is_datafile)
13701370
{
1371-
if (is_compressed_data_file(file))
1371+
if (file->is_cfs)
13721372
{
13731373
size_tskip_size=0;
13741374
if (backup_compressed_file_partially(file,arguments,&skip_size))
@@ -1378,19 +1378,15 @@ backup_files(void *arg)
13781378
arguments->to_root,
13791379
file,skip_size))
13801380
{
1381-
/* record as skipped file in file_xxx.txt */
13821381
file->write_size=BYTES_INVALID;
1383-
elog(LOG,"skip");
13841382
continue;
13851383
}
13861384
}
13871385
elseif (!copy_file(arguments->from_root,
13881386
arguments->to_root,
13891387
file))
13901388
{
1391-
/* record as skipped file in file_xxx.txt */
13921389
file->write_size=BYTES_INVALID;
1393-
elog(LOG,"skip");
13941390
continue;
13951391
}
13961392
}

‎data.c

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,6 @@ backup_data_file(const char *from_root, const char *to_root,
359359

360360
FIN_CRC32C(file->crc);
361361

362-
/* Treat empty file as not-datafile. */
363-
if (file->read_size==0)
364-
file->is_datafile= false;
365-
366362
/*
367363
* If we have pagemap then file can't be a zero size.
368364
* Otherwise, we will clear the last file.
@@ -482,13 +478,10 @@ restore_compressed_file(const char *from_root,
482478
constchar*to_root,
483479
pgFile*file)
484480
{
485-
if (file->is_partial_copy==0)
481+
if (!file->is_partial_copy)
486482
copy_file(from_root,to_root,file);
487-
elseif (file->is_partial_copy==1)
488-
restore_file_partly(from_root,to_root,file);
489483
else
490-
elog(ERROR,"restore_compressed_file(). Unknown is_partial_copy value %d",
491-
file->is_partial_copy);
484+
restore_file_partly(from_root,to_root,file);
492485
}
493486

494487
/*
@@ -625,19 +618,9 @@ restore_data_file(const char *from_root,
625618
fclose(out);
626619
}
627620

628-
/* If someone's want to use this function before correct
629-
* generation values is set, he can look up for corresponding
630-
* .cfm file in the file_list
631-
*/
632-
bool
633-
is_compressed_data_file(pgFile*file)
634-
{
635-
return (file->generation!=-1);
636-
}
637-
638621
/*
639622
* Add check that file is not bigger than RELSEG_SIZE.
640-
* WARNINGcompressed file can be exceed this limit.
623+
* WARNINGcfs_compressed file can be exceed this limit.
641624
* Add compression.
642625
*/
643626
bool
@@ -696,6 +679,8 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
696679
/* copy content and calc CRC */
697680
for (;;)
698681
{
682+
read_len=0;
683+
699684
if ((read_len=fread(buf,1,sizeof(buf),in))!=sizeof(buf))
700685
break;
701686

@@ -711,8 +696,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
711696
/* update CRC */
712697
COMP_CRC32C(crc,buf,read_len);
713698

714-
file->write_size+=sizeof(buf);
715-
file->read_size+=sizeof(buf);
699+
file->read_size+=read_len;
716700
}
717701

718702
errno_tmp=errno;
@@ -739,10 +723,10 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
739723
/* update CRC */
740724
COMP_CRC32C(crc,buf,read_len);
741725

742-
file->write_size+=read_len;
743726
file->read_size+=read_len;
744727
}
745728

729+
file->write_size=file->read_size;
746730
/* finish CRC calculation and store into pgFile */
747731
FIN_CRC32C(crc);
748732
file->crc=crc;
@@ -980,9 +964,7 @@ copy_file_partly(const char *from_root, const char *to_root,
980964
}
981965

982966
/* add meta information needed for recovery */
983-
file->is_partial_copy=1;
984-
985-
//elog(LOG, "copy_file_partly(). %s file->write_size %lu", to_path, file->write_size);
967+
file->is_partial_copy= true;
986968

987969
fclose(in);
988970
fclose(out);

‎dir.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ pgFileInit(const char *path)
154154
file->segno=0;
155155
file->path=pgut_malloc(strlen(path)+1);
156156
strcpy(file->path,path);/* enough buffer size guaranteed */
157-
file->generation=-1;
158-
file->is_partial_copy=0;
157+
file->is_cfs= false;
158+
file->generation=0;
159+
file->is_partial_copy= false;
159160
file->compress_alg=NOT_DEFINED_COMPRESS;
160161
returnfile;
161162
}
@@ -683,8 +684,10 @@ print_file_list(FILE *out, const parray *files, const char *root)
683684
fprintf(out,",\"linked\":\"%s\"",file->linked);
684685

685686
#ifdefPGPRO_EE
686-
fprintf(out,",\"CFS_generation\":\""UINT64_FORMAT"\",\"is_partial_copy\":\"%d\"",
687-
file->generation,file->is_partial_copy);
687+
if (file->is_cfs)
688+
fprintf(out,",\"is_cfs\":\"%u\" ,\"CFS_generation\":\""UINT64_FORMAT"\","
689+
"\"is_partial_copy\":\"%u\"",
690+
file->is_cfs?1:0,file->generation,file->is_partial_copy?1:0);
688691
#endif
689692
fprintf(out,"}\n");
690693
}
@@ -855,7 +858,8 @@ dir_read_file_list(const char *root, const char *file_txt)
855858
segno;
856859
#ifdefPGPRO_EE
857860
uint64generation,
858-
is_partial_copy;
861+
is_partial_copy,
862+
is_cfs;
859863
#endif
860864
pgFile*file;
861865

@@ -871,8 +875,9 @@ dir_read_file_list(const char *root, const char *file_txt)
871875
get_control_value(buf,"compress_alg",compress_alg_string,NULL, false);
872876

873877
#ifdefPGPRO_EE
874-
get_control_value(buf,"CFS_generation",NULL,&generation, true);
875-
get_control_value(buf,"is_partial_copy",NULL,&is_partial_copy, true);
878+
get_control_value(buf,"is_cfs",NULL,&is_cfs, false);
879+
get_control_value(buf,"CFS_generation",NULL,&generation, false);
880+
get_control_value(buf,"is_partial_copy",NULL,&is_partial_copy, false);
876881
#endif
877882
if (root)
878883
join_path_components(filepath,root,path);
@@ -890,8 +895,9 @@ dir_read_file_list(const char *root, const char *file_txt)
890895
file->linked=pgut_strdup(linked);
891896
file->segno= (int)segno;
892897
#ifdefPGPRO_EE
898+
file->is_cfs=is_cfs ? true : false;
893899
file->generation=generation;
894-
file->is_partial_copy=(int)is_partial_copy;
900+
file->is_partial_copy=is_partial_copy ? true : false;
895901
#endif
896902

897903
parray_append(files,file);

‎pg_probackup.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ typedef struct pgFile
8686
char*path;/* path of the file */
8787
char*ptrack_path;/* path of the ptrack fork of the relation */
8888
intsegno;/* Segment number for ptrack */
89-
uint64generation;/* Generation of the compressed file. Set to '-1'
90-
* for non-compressed files. If generation has changed,
91-
* we cannot backup compressed file partially. */
92-
intis_partial_copy;/* for compressed files. Set to '1' if backed up
93-
* via copy_file_partly() */
89+
boolis_cfs;/* Flag to distinguish files compressed by CFS*/
90+
uint64generation;/* Generation of the compressed file.If generation
91+
* has changed, we cannot backup compressed file
92+
* partially. Has no sense if (is_cfs == false). */
93+
boolis_partial_copy;/* If the file was backed up via copy_file_partly().
94+
* Only applies to is_cfs files. */
9495
CompressAlgcompress_alg;/* compression algorithm applied to the file */
9596
volatileuint32lock;/* lock for synchronization of parallel threads */
9697
datapagemap_tpagemap;/* bitmap of pages updated since previous backup */
@@ -419,7 +420,6 @@ extern void restore_data_file(const char *from_root, const char *to_root,
419420
pgFile*file,pgBackup*backup);
420421
externvoidrestore_compressed_file(constchar*from_root,
421422
constchar*to_root,pgFile*file);
422-
externboolis_compressed_data_file(pgFile*file);
423423
externboolbackup_compressed_file_partially(pgFile*file,
424424
void*arg,
425425
size_t*skip_size);

‎restore.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,15 @@ restore_files(void *arg)
673673
continue;
674674
}
675675

676-
/* restore file */
676+
/*
677+
* restore the file.
678+
* We treat datafiles separately, cause they were backed up block by
679+
* block and have BackupPageHeader meta information, so we cannot just
680+
* copy the file from backup.
681+
*/
677682
if (file->is_datafile)
678683
{
679-
if (is_compressed_data_file(file))
684+
if (file->is_cfs)
680685
restore_compressed_file(from_root,pgdata,file);
681686
else
682687
restore_data_file(from_root,pgdata,file,arguments->backup);

‎show.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ show_backup_list(FILE *out, parray *backup_list)
256256
/* Get parent timeline before printing */
257257
parent_tli=get_parent_tli(backup->tli);
258258
backup_id=base36enc(backup->start_time);
259+
elog(INFO,"%s : %ld",backup_id,backup->data_bytes);
259260

260261
fprintf(out," %-11s %-6s %-19s %-6s %-7s %3d / %-3d %5s %6s %2X/%-8X %2X/%-8X %-8s\n",
261262
instance_name,backup_id,

‎validate.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,12 @@ pgBackupValidateFiles(void *arg)
135135
*/
136136
if (file->write_size==BYTES_INVALID)
137137
continue;
138-
/* We don't compute checksums for compressed data, so skip them */
139-
if (file->generation!=-1)
138+
139+
/*
140+
* Currently we don't compute checksums for
141+
* cfs_compressed data files, so skip them.
142+
*/
143+
if (file->is_cfs)
140144
continue;
141145

142146
/* print progress */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp