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

Commitce3da29

Browse files
committed
Use durable_rename
1 parentc6dec8c commitce3da29

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

‎src/backend/storage/file/cfs.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -961,16 +961,11 @@ static bool cfs_gc_file(char* map_path, bool background)
961961
* Use rename and rely on file system to provide atomicity of this operation.
962962
*/
963963
remove_backups= false;
964-
if (rename(file_bck_path,file_path)<0)
964+
if (durable_rename(file_bck_path,file_path,LOG)<0)
965965
{
966966
elog(WARNING,"CFS failed to rename file %s: %m",file_path);
967967
gotoCleanup;
968968
}
969-
if (fsync_parent_path(file_path,LOG)!=0)
970-
{
971-
elog(WARNING,"CFS failed to sync directory for file %s: %m",file_path);
972-
gotoCleanup;
973-
}
974969

975970
ReplaceMap:
976971
/*
@@ -1174,7 +1169,7 @@ static void cfs_gc_bgworker_main(Datum arg)
11741169
voidcfs_gc_start_bgworkers()
11751170
{
11761171
inti;
1177-
cfs_state->max_iterations=INT_MAX;
1172+
cfs_state->max_iterations=INT64_MAX;
11781173
cfs_state->n_workers=cfs_gc_workers;
11791174

11801175
for (i=0;i<cfs_gc_workers;i++)

‎src/backend/storage/file/fd.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ static void pre_sync_fname(const char *fname, bool isdir, int elevel);
330330
staticvoiddatadir_fsync_fname(constchar*fname,boolisdir,intelevel);
331331

332332
staticintfsync_fname_ext(constchar*fname,boolisdir,boolignore_perm,intelevel);
333+
staticintfsync_parent_path(constchar*fname,intelevel);
333334

334335

335336
/*
@@ -1774,7 +1775,7 @@ FileRead(File file, char *buffer, int amount)
17741775
amount=CFS_INODE_SIZE(inode);
17751776
if (amount==0)
17761777
{
1777-
uint32fileSize=pg_atomic_read_u32(&map->virtSize);
1778+
uint32fileSize=pg_atomic_read_u32(&map->hdr.virtSize);
17781779
if (VfdCache[file].seekPos+BLCKSZ <=fileSize)
17791780
{
17801781
amount=BLCKSZ;
@@ -2178,7 +2179,7 @@ FileSeek(File file, off_t offset, int whence)
21782179
if (VfdCache[file].fileFlags&PG_COMPRESSION)
21792180
{
21802181
FileMap*map=VfdCache[file].map;
2181-
uint32fileSize=pg_atomic_read_u32(&map->virtSize);
2182+
uint32fileSize=pg_atomic_read_u32(&map->hdr.virtSize);
21822183

21832184
if (offset>0&&offset>fileSize)
21842185
offset=fileSize;
@@ -2267,13 +2268,13 @@ FileTruncate(File file, off_t offset)
22672268
map->inodes[i]=0;
22682269
}
22692270

2270-
pg_atomic_write_u32(&map->virtSize,offset);
2271-
pg_atomic_fetch_sub_u32(&map->usedSize,released);
2271+
pg_atomic_write_u32(&map->hdr.virtSize,offset);
2272+
pg_atomic_fetch_sub_u32(&map->hdr.usedSize,released);
22722273

22732274
if (offset==0)
22742275
{
22752276
/* We can truncate compressed file only with zero offset */
2276-
pg_atomic_write_u32(&map->physSize,0);
2277+
pg_atomic_write_u32(&map->hdr.physSize,0);
22772278
returnCode=ftruncate(VfdCache[file].fd,0);
22782279
}
22792280
cfs_unlock_file(map);
@@ -3519,7 +3520,7 @@ fsync_fname_ext(const char *fname, bool isdir, bool ignore_perm, int elevel)
35193520
* This is aimed at making file operations persistent on disk in case of
35203521
* an OS crash or power failure.
35213522
*/
3522-
int
3523+
staticint
35233524
fsync_parent_path(constchar*fname,intelevel)
35243525
{
35253526
charparentpath[MAXPGPATH];

‎src/include/storage/cfs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include"port/atomics.h"
77
#include"storage/rijndael.h"
88

9-
#defineCFS_VERSION "0.41"
9+
#defineCFS_VERSION "0.42"
1010

1111
#defineCFS_GC_LOCK 0x10000000
1212

@@ -81,7 +81,7 @@ typedef struct
8181
intn_workers;
8282
/* Maximal number of iterations with GC should perform. Automatically started GC performs infinite number of iterations.
8383
* Manually started GC performs just one iteration. */
84-
intmax_iterations;
84+
int64max_iterations;
8585
/* Flag for temporary disabling GC */
8686
boolgc_enabled;
8787
/* Flag for controlling background GC */

‎src/include/storage/fd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ extern intpg_fsync_writethrough(int fd);
120120
externintpg_fdatasync(intfd);
121121
externvoidpg_flush_data(intfd,off_toffset,off_tamount);
122122
externvoidfsync_fname(constchar*fname,boolisdir);
123-
externintfsync_parent_path(constchar*fname,intelevel);
124123
externintdurable_rename(constchar*oldfile,constchar*newfile,intloglevel);
125124
externintdurable_link_or_rename(constchar*oldfile,constchar*newfile,intloglevel);
126125
externvoidSyncDataDirectory(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp