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

Commitb8d6ab0

Browse files
author
Sergey Fukanchik
committed
[PBCKP-314] fio_mkdir has been replaced with pioMakeDir
1 parent5f419c3 commitb8d6ab0

File tree

11 files changed

+202
-65
lines changed

11 files changed

+202
-65
lines changed

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ borrowed.mk: $(firstword $(MAKEFILE_LIST))
9595
$(file >$@,# This file is autogenerated. Do not edit!)
9696
$(foreach borrowed_file,$(BORROWED_H_SRC)$(BORROWED_C_SRC), \
9797
$(file >>$@,$(addprefix$(BORROW_DIR)/,$(notdir$(borrowed_file))): |$(CURDIR)/$(BORROW_DIR)/$(realpath$(top_srcdir)/$(borrowed_file)))\
98-
$(file >>$@,$(shell echo ""'$$(LN_S)$(realpath$(top_srcdir)/$(borrowed_file))$$@'))\
98+
$(file >>$@,$(shell echo ""'$$(LN_S)-f$(realpath$(top_srcdir)/$(borrowed_file))$$@'))\
9999
)
100100
include borrowed.mk
101101

‎src/backup.c‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,15 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
250250
if (current.stream)
251251
{
252252
charstream_xlog_path[MAXPGPATH];
253+
err_ierr;
253254

254255
join_path_components(stream_xlog_path,current.database_dir,PG_XLOG_DIR);
255-
fio_mkdir(FIO_BACKUP_HOST,stream_xlog_path,DIR_PERMISSION, false);
256+
err=$i(pioMakeDir,current.backup_location, .path=stream_xlog_path,
257+
.mode=DIR_PERMISSION, .strict= false);
258+
if ($haserr(err))
259+
{
260+
elog(WARNING,"%s",$errmsg(err));
261+
}
256262

257263
start_WAL_streaming(backup_conn,stream_xlog_path,&instance_config.conn_opt,
258264
current.start_lsn,current.tli, true);
@@ -400,7 +406,16 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
400406
join_path_components(dirpath,current.database_dir,file->rel_path);
401407

402408
elog(LOG,"Create directory '%s'",dirpath);
403-
fio_mkdir(FIO_BACKUP_HOST,dirpath,DIR_PERMISSION, false);
409+
{
410+
err_ierr;
411+
412+
err=$i(pioMakeDir,current.backup_location, .path=dirpath,
413+
.mode=DIR_PERMISSION, .strict= false);
414+
if ($haserr(err))
415+
{
416+
elog(WARNING,"%s",$errmsg(err));
417+
}
418+
}
404419
}
405420

406421
}

‎src/catalog.c‎

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static pgBackup* get_closest_backup(timelineInfo *tlinfo);
2222
staticpgBackup*get_oldest_backup(timelineInfo*tlinfo);
2323
staticconstchar*backupModes[]= {"","PAGE","PTRACK","DELTA","FULL"};
2424
staticpgBackup*readBackupControlFile(constchar*path);
25-
staticintcreate_backup_dir(pgBackup*backup,constchar*backup_instance_path);
25+
staticerr_icreate_backup_dir(pgBackup*backup,constchar*backup_instance_path);
2626

2727
staticboolbackup_lock_exit_hook_registered= false;
2828
staticparray*locks=NULL;
@@ -1461,9 +1461,11 @@ pgBackupInitDir(pgBackup *backup, const char *backup_instance_path)
14611461
inti;
14621462
chartemp[MAXPGPATH];
14631463
parray*subdirs;
1464+
err_ierr;
14641465

14651466
/* Try to create backup directory at first */
1466-
if (create_backup_dir(backup,backup_instance_path)!=0)
1467+
err=create_backup_dir(backup,backup_instance_path);
1468+
if ($haserr(err))
14671469
{
14681470
/* Clear backup_id as indication of error */
14691471
backup->backup_id=INVALID_BACKUP_ID;
@@ -1498,8 +1500,14 @@ pgBackupInitDir(pgBackup *backup, const char *backup_instance_path)
14981500
/* create directories for actual backup files */
14991501
for (i=0;i<parray_num(subdirs);i++)
15001502
{
1503+
err_ierr;
15011504
join_path_components(temp,backup->root_dir,parray_get(subdirs,i));
1502-
fio_mkdir(FIO_BACKUP_HOST,temp,DIR_PERMISSION, false);
1505+
err=$i(pioMakeDir,backup->backup_location, .path=temp,
1506+
.mode=DIR_PERMISSION, .strict= false);
1507+
if ($haserr(err))
1508+
{
1509+
elog(WARNING,"%s",$errmsg(err));
1510+
}
15031511
}
15041512

15051513
free_dir_list(subdirs);
@@ -1512,22 +1520,24 @@ pgBackupInitDir(pgBackup *backup, const char *backup_instance_path)
15121520
* 0 - ok
15131521
* -1 - error (warning message already emitted)
15141522
*/
1515-
int
1523+
staticerr_i
15161524
create_backup_dir(pgBackup*backup,constchar*backup_instance_path)
15171525
{
1518-
intrc;
15191526
charpath[MAXPGPATH];
1527+
err_ierr;
15201528

15211529
join_path_components(path,backup_instance_path,base36enc(backup->backup_id));
15221530

15231531
/* TODO: add wrapper for remote mode */
1524-
rc=fio_mkdir(FIO_BACKUP_HOST,path,DIR_PERMISSION, true);
1525-
1526-
if (rc==0)
1532+
err=$i(pioMakeDir,backup->backup_location, .path=path,
1533+
.mode=DIR_PERMISSION, .strict= true);
1534+
if (!$haserr(err))
1535+
{
15271536
backup->root_dir=pgut_strdup(path);
1528-
else
1529-
elog(WARNING,"Cannot create directory \"%s\": %s",path,strerror(errno));
1530-
returnrc;
1537+
}else {
1538+
elog(WARNING,"%s",$errmsg(err));
1539+
}
1540+
returnerr;
15311541
}
15321542

15331543
/*
@@ -2969,6 +2979,9 @@ pgBackupInit(pgBackup *backup)
29692979
backup->files=NULL;
29702980
backup->note=NULL;
29712981
backup->content_crc=0;
2982+
2983+
backup->backup_location=pioDriveForLocation(FIO_BACKUP_HOST);
2984+
backup->database_location=pioDriveForLocation(FIO_DB_HOST);
29722985
}
29732986

29742987
/* free pgBackup object */
@@ -2977,6 +2990,10 @@ pgBackupFree(void *backup)
29772990
{
29782991
pgBackup*b= (pgBackup*)backup;
29792992

2993+
/* Both point to global static vars */
2994+
b->backup_location.self=NULL;
2995+
b->database_location.self=NULL;
2996+
29802997
pg_free(b->primary_conninfo);
29812998
pg_free(b->external_dir_str);
29822999
pg_free(b->root_dir);

‎src/catchup.c‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ int
613613
do_catchup(constchar*source_pgdata,constchar*dest_pgdata,intnum_threads,boolsync_dest_files,
614614
parray*exclude_absolute_paths_list,parray*exclude_relative_paths_list)
615615
{
616+
pioDrive_ilocal_location=pioDriveForLocation(FIO_LOCAL_HOST);
616617
PGconn*source_conn=NULL;
617618
PGNodeInfosource_node_info;
618619
boolbackup_logs= false;
@@ -704,7 +705,14 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
704705
join_path_components(dest_xlog_path,dest_pgdata,PG_XLOG_DIR);
705706
if (!dry_run)
706707
{
707-
fio_mkdir(FIO_LOCAL_HOST,dest_xlog_path,DIR_PERMISSION, false);
708+
err_ierr;
709+
710+
err=$i(pioMakeDir,local_location, .path=dest_xlog_path,
711+
.mode=DIR_PERMISSION, .strict= false);
712+
if($haserr(err))
713+
{
714+
elog(WARNING,"%s",$errmsg(err));
715+
}
708716
start_WAL_streaming(source_conn,dest_xlog_path,&instance_config.conn_opt,
709717
current.start_lsn,current.tli, false);
710718
}
@@ -820,7 +828,16 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
820828

821829
elog(LOG,"Create directory '%s'",dirpath);
822830
if (!dry_run)
823-
fio_mkdir(FIO_LOCAL_HOST,dirpath,DIR_PERMISSION, false);
831+
{
832+
err_ierr;
833+
834+
err=$i(pioMakeDir,local_location, .path=dirpath,
835+
.mode=DIR_PERMISSION, .strict= false);
836+
if ($haserr(err))
837+
{
838+
elog(WARNING,"%s",$errmsg(err));
839+
}
840+
}
824841
}
825842
else
826843
{
@@ -853,10 +870,16 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
853870

854871
if (!dry_run)
855872
{
873+
err_ierr;
874+
856875
/* create tablespace directory */
857-
if (fio_mkdir(FIO_LOCAL_HOST,linked_path,file->mode, false)!=0)
858-
elog(ERROR,"Could not create tablespace directory \"%s\": %s",
859-
linked_path,strerror(errno));
876+
err=$i(pioMakeDir,local_location, .path=linked_path,
877+
.mode=file->mode, .strict= false);
878+
if ($haserr(err))
879+
{
880+
elog(ERROR,"Could not create tablespace directory \"%s\": \"%s\"",
881+
linked_path,$errmsg(err));
882+
}
860883

861884
/* create link to linked_path */
862885
if (fio_symlink(FIO_LOCAL_HOST,linked_path,to_path, true)<0)

‎src/dir.c‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ create_data_directories(parray *dest_files, const char *data_dir, const char *ba
847847
boolextract_tablespaces,boolincremental,fio_locationlocation,
848848
constchar*waldir_path)
849849
{
850+
pioDrive_idrive=pioDriveForLocation(location);
850851
inti;
851852
parray*links=NULL;
852853
mode_tpg_tablespace_mode=DIR_PERMISSION;
@@ -932,7 +933,16 @@ create_data_directories(parray *dest_files, const char *data_dir, const char *ba
932933
waldir_path,to_path);
933934

934935
/* create tablespace directory from waldir_path*/
935-
fio_mkdir(location,waldir_path,pg_tablespace_mode, false);
936+
{
937+
err_ierr;
938+
939+
err=$i(pioMakeDir,drive, .path=waldir_path,
940+
.mode=pg_tablespace_mode, .strict= false);
941+
if ($haserr(err))
942+
{
943+
elog(WARNING,"%s",$errmsg(err));
944+
}
945+
}
936946

937947
/* create link to linked_path */
938948
if (fio_symlink(location,waldir_path,to_path,incremental)<0)
@@ -974,7 +984,16 @@ create_data_directories(parray *dest_files, const char *data_dir, const char *ba
974984
linked_path,to_path);
975985

976986
/* create tablespace directory */
977-
fio_mkdir(location,linked_path,pg_tablespace_mode, false);
987+
{
988+
err_ierr;
989+
990+
err=$i(pioMakeDir,drive, .path=linked_path,
991+
.mode=pg_tablespace_mode, .strict= false);
992+
if ($haserr(err))
993+
{
994+
elog(WARNING,"%s",$errmsg(err));
995+
}
996+
}
978997

979998
/* create link to linked_path */
980999
if (fio_symlink(location,linked_path,to_path,incremental)<0)
@@ -992,7 +1011,16 @@ create_data_directories(parray *dest_files, const char *data_dir, const char *ba
9921011
join_path_components(to_path,data_dir,dir->rel_path);
9931012

9941013
// TODO check exit code
995-
fio_mkdir(location,to_path,dir->mode, false);
1014+
{
1015+
err_ierr;
1016+
1017+
err=$i(pioMakeDir,drive, .path=to_path, .mode=dir->mode,
1018+
.strict= false);
1019+
if ($haserr(err))
1020+
{
1021+
elog(WARNING,"%s",$errmsg(err));
1022+
}
1023+
}
9961024
}
9971025

9981026
if (extract_tablespaces)

‎src/init.c‎

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
int
1919
do_init(CatalogState*catalogState)
2020
{
21+
pioDrive_ibackup_location=pioDriveForLocation(FIO_BACKUP_HOST);
2122
intresults;
23+
err_ierr;
2224

2325
results=pg_check_dir(catalogState->catalog_path);
2426

@@ -32,13 +34,28 @@ do_init(CatalogState *catalogState)
3234
}
3335

3436
/* create backup catalog root directory */
35-
fio_mkdir(FIO_BACKUP_HOST,catalogState->catalog_path,DIR_PERMISSION, false);
37+
err=$i(pioMakeDir,backup_location, .path=catalogState->catalog_path,
38+
.mode=DIR_PERMISSION, .strict= false);
39+
if ($haserr(err))
40+
{
41+
elog(WARNING,"%s",$errmsg(err));
42+
}
3643

3744
/* create backup catalog data directory */
38-
fio_mkdir(FIO_BACKUP_HOST,catalogState->backup_subdir_path,DIR_PERMISSION, false);
45+
err=$i(pioMakeDir,backup_location, .path=catalogState->backup_subdir_path,
46+
.mode=DIR_PERMISSION, .strict= false);
47+
if ($haserr(err))
48+
{
49+
elog(WARNING,"%s",$errmsg(err));
50+
}
3951

4052
/* create backup catalog wal directory */
41-
fio_mkdir(FIO_BACKUP_HOST,catalogState->wal_subdir_path,DIR_PERMISSION, false);
53+
err=$i(pioMakeDir,backup_location, .path=catalogState->wal_subdir_path,
54+
.mode=DIR_PERMISSION, .strict= false);
55+
if ($haserr(err))
56+
{
57+
elog(WARNING,"%s",$errmsg(err));
58+
}
4259

4360
elog(INFO,"Backup catalog '%s' successfully inited",catalogState->catalog_path);
4461
return0;
@@ -47,8 +64,10 @@ do_init(CatalogState *catalogState)
4764
int
4865
do_add_instance(InstanceState*instanceState,InstanceConfig*instance)
4966
{
67+
pioDrive_ibackup_location=pioDriveForLocation(FIO_BACKUP_HOST);
5068
structstatst;
5169
CatalogState*catalogState=instanceState->catalog_state;
70+
err_ierr;
5271

5372
/* PGDATA is always required */
5473
if (instance->pgdata==NULL)
@@ -85,8 +104,18 @@ do_add_instance(InstanceState *instanceState, InstanceConfig *instance)
85104
instanceState->instance_name,instanceState->instance_wal_subdir_path);
86105

87106
/* Create directory for data files of this specific instance */
88-
fio_mkdir(FIO_BACKUP_HOST,instanceState->instance_backup_subdir_path,DIR_PERMISSION, false);
89-
fio_mkdir(FIO_BACKUP_HOST,instanceState->instance_wal_subdir_path,DIR_PERMISSION, false);
107+
err=$i(pioMakeDir,backup_location, .path=instanceState->instance_backup_subdir_path,
108+
.mode=DIR_PERMISSION, .strict= false);
109+
if ($haserr(err))
110+
{
111+
elog(WARNING,"%s",$errmsg(err));
112+
}
113+
err=$i(pioMakeDir,backup_location, .path=instanceState->instance_wal_subdir_path,
114+
.mode=DIR_PERMISSION, .strict= false);
115+
if ($haserr(err))
116+
{
117+
elog(WARNING,"%s",$errmsg(err));
118+
}
90119

91120
/*
92121
* Write initial configuration file.

‎src/merge.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,17 @@ merge_chain(InstanceState *instanceState,
641641
{
642642
chardirpath[MAXPGPATH];
643643
charnew_container[MAXPGPATH];
644+
err_ierr;
644645

645646
makeExternalDirPathByNum(new_container,full_external_prefix,
646647
file->external_dir_num);
647648
join_path_components(dirpath,new_container,file->rel_path);
648-
fio_mkdir(FIO_BACKUP_HOST,dirpath,DIR_PERMISSION, false);
649+
err=$i(pioMakeDir,dest_backup->backup_location, .path=dirpath,
650+
.mode=DIR_PERMISSION, .strict= false);
651+
if ($haserr(err))
652+
{
653+
elog(WARNING,"%s",$errmsg(err));
654+
}
649655
}
650656

651657
pg_atomic_init_flag(&file->lock);

‎src/pg_probackup.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ struct pgBackup
488488

489489
/* map used for access to page headers */
490490
HeaderMaphdr_map;
491+
492+
pioDrive_idatabase_location;/* Where to backup from/restore to */
493+
pioDrive_ibackup_location;/* Where to save to/read from */
491494
};
492495

493496
/* Recovery target for restore and validate subcommands */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp