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

Commit4b609bd

Browse files
committed
Refector CFS intialization
1 parenta72d35d commit4b609bd

File tree

5 files changed

+33
-18
lines changed

5 files changed

+33
-18
lines changed

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

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -389,23 +389,31 @@ void cfs_decrypt(const char* fname, void* block, uint32 offs, uint32 size)
389389
*Section 3: Compression implementation.
390390
* ----------------------------------------------------------------
391391
*/
392-
voidcfs_initialize()
392+
intcfs_shmem_size()
393393
{
394-
cfs_state= (CfsState*)ShmemAlloc(sizeof(CfsState));
395-
memset(&cfs_state->gc_stat,0,sizeofcfs_state->gc_stat);
396-
pg_atomic_init_flag(&cfs_state->gc_started);
397-
pg_atomic_init_u32(&cfs_state->n_active_gc,0);
398-
cfs_state->n_workers=0;
399-
cfs_state->gc_enabled=cfs_gc_enabled;
400-
cfs_state->max_iterations=0;
401-
402-
if (cfs_encryption)
403-
cfs_crypto_init();
404-
405-
elog(LOG,"Start CFS version %s compression algorithm %s encryption %s",
406-
CFS_VERSION,cfs_algorithm(),cfs_encryption ?"enabled" :"disabled");
394+
returnsizeof(CfsState);
407395
}
408396

397+
voidcfs_initialize()
398+
{
399+
boolfound;
400+
cfs_state= (CfsState*)ShmemInitStruct("CFS Control",sizeof(CfsState),&found);
401+
if (!found)
402+
{
403+
memset(&cfs_state->gc_stat,0,sizeofcfs_state->gc_stat);
404+
pg_atomic_init_flag(&cfs_state->gc_started);
405+
pg_atomic_init_u32(&cfs_state->n_active_gc,0);
406+
cfs_state->n_workers=0;
407+
cfs_state->gc_enabled=cfs_gc_enabled;
408+
cfs_state->max_iterations=0;
409+
410+
if (cfs_encryption)
411+
cfs_crypto_init();
412+
413+
elog(LOG,"Start CFS version %s compression algorithm %s encryption %s GC %s",
414+
CFS_VERSION,cfs_algorithm(),cfs_encryption ?"enabled" :"disabled",cfs_gc_enabled ?"enabled" :"disabled");
415+
}
416+
}
409417
intcfs_msync(FileMap*map)
410418
{
411419
#ifdefWIN32
@@ -566,7 +574,7 @@ void cfs_lock_file(FileMap* map, char const* file_path)
566574
char*map_bck_path=psprintf("%s.cfm.bck",file_path);
567575
char*file_bck_path=psprintf("%s.bck",file_path);
568576

569-
elog(WARNING,"CFS indicates that GC of %s was interrupted:try to perform recovery",file_path);
577+
elog(WARNING,"CFS indicates that GC of %s was interrupted:trying to perform recovery",file_path);
570578

571579
if (access(file_bck_path,R_OK)!=0)
572580
{

‎src/backend/storage/ipc/ipci.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include"storage/procsignal.h"
4545
#include"storage/sinvaladt.h"
4646
#include"storage/spin.h"
47+
#include"storage/cfs.h"
4748
#include"utils/snapmgr.h"
4849

4950

@@ -142,6 +143,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int port)
142143
size=add_size(size,BTreeShmemSize());
143144
size=add_size(size,SyncScanShmemSize());
144145
size=add_size(size,AsyncShmemSize());
146+
size=add_size(size,cfs_shmem_size());
145147
#ifdefEXEC_BACKEND
146148
size=add_size(size,ShmemBackendArraySize());
147149
#endif
@@ -254,7 +256,8 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int port)
254256
BTreeShmemInit();
255257
SyncScanShmemInit();
256258
AsyncShmemInit();
257-
259+
cfs_initialize();
260+
258261
/*
259262
* Init array of Latches in SHMEM for WAITLSN
260263
*/

‎src/backend/storage/lmgr/lwlocknames.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ CommitTsLock39
4747
ReplicationOriginLock40
4848
MultiXactTruncationLock41
4949
OldSnapshotTimeMapLock42
50+
CfsGcLock 43

‎src/backend/utils/misc/guc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10859,12 +10859,14 @@ static void set_cfs_gc_enabled(bool newval, void* extra)
1085910859
{
1086010860
cfs_gc_enabled=newval;
1086110861
if (cfs_state&&MyProcPid==PostmasterPid)
10862-
cfs_control_gc(newval);
10862+
{
10863+
cfs_state->gc_enabled=newval;
10864+
}
1086310865
}
1086410866

1086510867
staticcharconst*show_cfs_gc_enabled(void)
1086610868
{
10867-
returncfs_gc_enabled ?"on" :"off";
10869+
return(cfs_state ?cfs_state->gc_enabled :cfs_gc_enabled) ?"on" :"off";
1086810870
}
1086910871

1087010872

‎src/include/storage/cfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ int cfs_msync(FileMap* map);
119119
FileMap*cfs_mmap(intmd);
120120
intcfs_munmap(FileMap*map);
121121
voidcfs_initialize(void);
122+
intcfs_shmem_size(void);
122123

123124
voidcfs_encrypt(constchar*fname,void*block,uint32offs,uint32size);
124125
voidcfs_decrypt(constchar*fname,void*block,uint32offs,uint32size);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp