Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8bd21f5

Browse files
author
Sokolov Yura
committed
cfs: set CFS_GC_LOCK to be dependent on MAX_BACKENDS
1 parent 67f29e1 commit 8bd21f5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/backend/storage/file/cfs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#include "port/atomics.h"
4646
#include "pgstat.h"
4747
#include "portability/mem.h"
48+
#include "postmaster/bgworker.h"
49+
#include "postmaster/postmaster.h"
4850
#include "storage/fd.h"
4951
#include "storage/cfs.h"
5052
#include "storage/ipc.h"
@@ -53,7 +55,6 @@
5355
#include "utils/rel.h"
5456
#include "utils/builtins.h"
5557
#include "utils/resowner_private.h"
56-
#include "postmaster/bgworker.h"
5758

5859

5960
/*
@@ -398,6 +399,12 @@ int cfs_shmem_size()
398399
void cfs_initialize()
399400
{
400401
bool found;
402+
403+
StaticAssertStmt((CFS_GC_LOCK & (CFS_GC_LOCK-1)) == 0,
404+
"CFS_GC_LOCK should be single bit");
405+
StaticAssertStmt(CFS_GC_LOCK > MAX_BACKENDS,
406+
"CFS_GC_LOCK should be larger than MAX_BACKENDS");
407+
401408
cfs_state = (CfsState*)ShmemInitStruct("CFS Control",
402409
sizeof(CfsState) + sizeof(pg_atomic_uint32)*MaxBackends, &found);
403410
if (!found)

src/include/storage/cfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#define CFS_VERSION "0.45"
1010

11-
#define CFS_GC_LOCK 0x10000000
11+
#define CFS_GC_LOCK (MAX_BACKENDS+1)
1212

1313
#define CFS_LOCK_MIN_TIMEOUT 100 /* microseconds: initial timeout of GC lock acquisition */
1414
#define CFS_LOCK_MAX_TIMEOUT 10000 /* microseconds */

0 commit comments

Comments
 (0)