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

Commit58373a5

Browse files
committed
Add comments for FIO functions
1 parent4c249ee commit58373a5

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

‎src/pg_probackup.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,12 @@ main(int argc, char *argv[])
318318
config_get_opt(argc,argv,cmd_options,instance_options);
319319

320320
if (remote_agent!=NULL&&strcmp(remote_agent,PROGRAM_VERSION)!=0)
321-
elog(ERROR,"Agent version %s doesn't match master pg_probackup version %s",
321+
{
322+
uint32agent_version=parse_program_version(remote_agent);
323+
elog(agent_version<AGENT_PROTOCOL_VERSION ?ERROR :WARNING,
324+
"Agent version %s doesn't match master pg_probackup version %s",
322325
remote_agent,PROGRAM_VERSION);
323-
326+
}
324327
pgut_init();
325328

326329
if (help_opt)

‎src/pg_probackup.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ typedef enum ShowFormat
168168
#defineBYTES_INVALID(-1)
169169
#defineBLOCKNUM_INVALID(-1)
170170
#definePROGRAM_VERSION"2.0.26"
171+
#defineAGENT_PROTOCOL_VERSION 20026
171172

172173
/*
173174
* An instance configuration. It can be stored in a configuration file or passed

‎src/utils/file.c‎

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,37 @@ static fio_binding fio_bindings[] =
2222
{&current.stop_lsn,sizeof(current.stop_lsn)}
2323
};
2424

25+
/* Convert FIO pseudo handle to index in file descriptor array */
2526
#definefio_fileno(f) (((size_t)f - 1) | FIO_PIPE_MARKER)
2627

28+
/* Use specified file descriptors as stding/stdout for FIO functions */
2729
voidfio_redirect(intin,intout)
2830
{
2931
fio_stdin=in;
3032
fio_stdout=out;
3133
}
3234

35+
/* Check if FILE handle is local or remote (created by FIO) */
3336
staticboolfio_is_remote_file(FILE*file)
3437
{
3538
return (size_t)file <=FIO_FDMAX;
3639
}
3740

41+
/* Check if file descriptor is local or remote (created by FIO) */
3842
staticboolfio_is_remote_fd(intfd)
3943
{
4044
return (fd&FIO_PIPE_MARKER)!=0;
4145
}
4246

47+
/* Check if specified location is local for current node */
4348
staticboolfio_is_remote(fio_locationlocation)
4449
{
4550
returnlocation==FIO_REMOTE_HOST
46-
|| (location==FIO_BACKUP_HOST&&remote_agent)
51+
|| (location==FIO_BACKUP_HOST&&remote_agent)/* agent is launched at Postgres side */
4752
|| (location==FIO_DB_HOST&& !remote_agent&&IsSshConnection());
4853
}
4954

55+
/* Try to read specified amount of bytes unless error or EOF are encountered */
5056
staticssize_tfio_read_all(intfd,void*buf,size_tsize)
5157
{
5258
size_toffs=0;
@@ -66,6 +72,7 @@ static ssize_t fio_read_all(int fd, void* buf, size_t size)
6672
returnoffs;
6773
}
6874

75+
/* Try to write specified amount of bytes unless error is encountered */
6976
staticssize_tfio_write_all(intfd,voidconst*buf,size_tsize)
7077
{
7178
size_toffs=0;
@@ -83,6 +90,7 @@ static ssize_t fio_write_all(int fd, void const* buf, size_t size)
8390
returnoffs;
8491
}
8592

93+
/* Open input stream. Remote file is fetched to the in-memory buffer and then accessed through Linux fmemopen */
8694
FILE*fio_open_stream(charconst*path,fio_locationlocation)
8795
{
8896
FILE*f;
@@ -116,6 +124,7 @@ FILE* fio_open_stream(char const* path, fio_location location)
116124
returnf;
117125
}
118126

127+
/* Close input stream */
119128
intfio_close_stream(FILE*f)
120129
{
121130
if (fio_stdin_buffer)
@@ -126,6 +135,7 @@ int fio_close_stream(FILE* f)
126135
returnfclose(f);
127136
}
128137

138+
/* Open directory */
129139
DIR*fio_opendir(charconst*path,fio_locationlocation)
130140
{
131141
DIR*dir;
@@ -161,6 +171,7 @@ DIR* fio_opendir(char const* path, fio_location location)
161171
returndir;
162172
}
163173

174+
/* Get next directory entry */
164175
structdirent*fio_readdir(DIR*dir)
165176
{
166177
if (fio_is_remote_file((FILE*)dir))
@@ -193,6 +204,7 @@ struct dirent* fio_readdir(DIR *dir)
193204
}
194205
}
195206

207+
/* Close directory */
196208
intfio_closedir(DIR*dir)
197209
{
198210
if (fio_is_remote_file((FILE*)dir))
@@ -213,7 +225,7 @@ int fio_closedir(DIR *dir)
213225
}
214226
}
215227

216-
228+
/* Open file */
217229
intfio_open(charconst*path,intmode,fio_locationlocation)
218230
{
219231
intfd;
@@ -250,6 +262,7 @@ int fio_open(char const* path, int mode, fio_location location)
250262
returnfd;
251263
}
252264

265+
/* Open stdio file */
253266
FILE*fio_fopen(charconst*path,charconst*mode,fio_locationlocation)
254267
{
255268
FILE*f;
@@ -266,6 +279,7 @@ FILE* fio_fopen(char const* path, char const* mode, fio_location location)
266279
returnf;
267280
}
268281

282+
/* Format output to file stream */
269283
intfio_fprintf(FILE*f,charconst*format, ...)
270284
{
271285
intrc;
@@ -291,6 +305,7 @@ int fio_fprintf(FILE* f, char const* format, ...)
291305
returnrc;
292306
}
293307

308+
/* Flush stream data (does nothing for remote file) */
294309
intfio_fflush(FILE*f)
295310
{
296311
intrc=0;
@@ -304,18 +319,21 @@ int fio_fflush(FILE* f)
304319
returnrc;
305320
}
306321

322+
/* Sync file to the disk (does nothing for remote file) */
307323
intfio_flush(intfd)
308324
{
309325
returnfio_is_remote_fd(fd) ?0 :fsync(fd);
310326
}
311327

328+
/* Close output stream */
312329
intfio_fclose(FILE*f)
313330
{
314331
returnfio_is_remote_file(f)
315332
?fio_close(fio_fileno(f))
316333
:fclose(f);
317334
}
318335

336+
/* Close file */
319337
intfio_close(intfd)
320338
{
321339
if (fio_is_remote_fd(fd))
@@ -340,13 +358,15 @@ int fio_close(int fd)
340358
}
341359
}
342360

361+
/* Truncate stdio file */
343362
intfio_ftruncate(FILE*f,off_tsize)
344363
{
345364
returnfio_is_remote_file(f)
346365
?fio_truncate(fio_fileno(f),size)
347366
:ftruncate(fileno(f),size);
348367
}
349368

369+
/* Truncate file */
350370
intfio_truncate(intfd,off_tsize)
351371
{
352372
if (fio_is_remote_fd(fd))
@@ -371,13 +391,15 @@ int fio_truncate(int fd, off_t size)
371391
}
372392
}
373393

394+
/* Set position in stdio file */
374395
intfio_fseek(FILE*f,off_toffs)
375396
{
376397
returnfio_is_remote_file(f)
377398
?fio_seek(fio_fileno(f),offs)
378399
:fseek(f,offs,SEEK_SET);
379400
}
380401

402+
/* Set position in file */
381403
intfio_seek(intfd,off_toffs)
382404
{
383405
if (fio_is_remote_fd(fd))
@@ -402,13 +424,15 @@ int fio_seek(int fd, off_t offs)
402424
}
403425
}
404426

427+
/* Write data to stdio file */
405428
size_tfio_fwrite(FILE*f,voidconst*buf,size_tsize)
406429
{
407430
returnfio_is_remote_file(f)
408431
?fio_write(fio_fileno(f),buf,size)
409432
:fwrite(buf,1,size,f);
410433
}
411434

435+
/* Write data to the file */
412436
ssize_tfio_write(intfd,voidconst*buf,size_tsize)
413437
{
414438
if (fio_is_remote_fd(fd))
@@ -433,13 +457,15 @@ ssize_t fio_write(int fd, void const* buf, size_t size)
433457
}
434458
}
435459

460+
/* Read data from stdio file */
436461
size_tfio_fread(FILE*f,void*buf,size_tsize)
437462
{
438463
returnfio_is_remote_file(f)
439464
?fio_read(fio_fileno(f),buf,size)
440465
:fread(buf,1,size,f);
441466
}
442467

468+
/* Read data from file */
443469
ssize_tfio_read(intfd,void*buf,size_tsize)
444470
{
445471
if (fio_is_remote_fd(fd))
@@ -472,13 +498,15 @@ ssize_t fio_read(int fd, void* buf, size_t size)
472498
}
473499
}
474500

501+
/* Get information about stdio file */
475502
intfio_ffstat(FILE*f,structstat*st)
476503
{
477504
returnfio_is_remote_file(f)
478505
?fio_fstat(fio_fileno(f),st)
479506
:fio_fstat(fileno(f),st);
480507
}
481508

509+
/* Get information about file descriptor */
482510
intfio_fstat(intfd,structstat*st)
483511
{
484512
if (fio_is_remote_fd(fd))
@@ -510,6 +538,7 @@ int fio_fstat(int fd, struct stat* st)
510538
}
511539
}
512540

541+
/* Get information about file */
513542
intfio_stat(charconst*path,structstat*st,boolfollow_symlinks,fio_locationlocation)
514543
{
515544
if (fio_is_remote(location))
@@ -544,6 +573,7 @@ int fio_stat(char const* path, struct stat* st, bool follow_symlinks, fio_locati
544573
}
545574
}
546575

576+
/* Check presence of the file */
547577
intfio_access(charconst*path,intmode,fio_locationlocation)
548578
{
549579
if (fio_is_remote(location))
@@ -576,6 +606,7 @@ int fio_access(char const* path, int mode, fio_location location)
576606
}
577607
}
578608

609+
/* Rename file */
579610
intfio_rename(charconst*old_path,charconst*new_path,fio_locationlocation)
580611
{
581612
if (fio_is_remote(location))
@@ -602,6 +633,7 @@ int fio_rename(char const* old_path, char const* new_path, fio_location location
602633
}
603634
}
604635

636+
/* Remove file */
605637
intfio_unlink(charconst*path,fio_locationlocation)
606638
{
607639
if (fio_is_remote(location))
@@ -626,6 +658,7 @@ int fio_unlink(char const* path, fio_location location)
626658
}
627659
}
628660

661+
/* Create directory */
629662
intfio_mkdir(charconst*path,intmode,fio_locationlocation)
630663
{
631664
if (fio_is_remote(location))
@@ -651,6 +684,7 @@ int fio_mkdir(char const* path, int mode, fio_location location)
651684
}
652685
}
653686

687+
/* Checnge file mode */
654688
intfio_chmod(charconst*path,intmode,fio_locationlocation)
655689
{
656690
if (fio_is_remote(location))
@@ -677,6 +711,8 @@ int fio_chmod(char const* path, int mode, fio_location location)
677711
}
678712

679713
#ifdefHAVE_LIBZ
714+
/* Open compressed file. In case of remove file, it is fetched to local temporary file in read-only mode or is written
715+
* to temoporary file and rtansfered to remote host by fio_gzclose. */
680716
gzFilefio_gzopen(charconst*path,charconst*mode,int*tmp_fd,fio_locationlocation)
681717
{
682718
gzFilefile;
@@ -715,6 +751,7 @@ gzFile fio_gzopen(char const* path, char const* mode, int* tmp_fd, fio_location
715751
returnfile;
716752
}
717753

754+
/* Close compressed file. In case of writing remote file, content of temporary file is trasfered to remote host */
718755
intfio_gzclose(gzFilefile,charconst*path,inttmp_fd)
719756
{
720757
if (tmp_fd >=0)
@@ -749,7 +786,7 @@ int fio_gzclose(gzFile file, char const* path, int tmp_fd)
749786
}
750787
#endif
751788

752-
789+
/* Send file content */
753790
staticvoidfio_send_file(intout,charconst*path)
754791
{
755792
intfd=open(path,O_RDONLY);
@@ -776,6 +813,7 @@ static void fio_send_file(int out, char const* path)
776813
}
777814
}
778815

816+
/* Send values of variables. Variables are described infio_bindings array and "var" is index in this array. */
779817
voidfio_transfer(fio_shared_variablevar)
780818
{
781819
size_tvar_size=fio_bindings[var].size;
@@ -794,6 +832,7 @@ void fio_transfer(fio_shared_variable var)
794832
free(msg);
795833
}
796834

835+
/* Execute commands at remote host */
797836
voidfio_communicate(intin,intout)
798837
{
799838
intfd[FIO_FDMAX];

‎src/utils/file.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ typedef enum
3434

3535
typedefenum
3636
{
37-
FIO_LOCAL_HOST,
38-
FIO_DB_HOST,
39-
FIO_BACKUP_HOST,
40-
FIO_REMOTE_HOST
37+
FIO_LOCAL_HOST,/* data is locate at local host */
38+
FIO_DB_HOST,/* data is located at Postgres server host */
39+
FIO_BACKUP_HOST,/* data is located at backup host */
40+
FIO_REMOTE_HOST/* date is located at remote host */
4141
}fio_location;
4242

4343
typedefenum

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp