aboutsummaryrefslogtreecommitdiff
path: root/src/backend/postmaster/checkpointer.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2015-10-06 15:45:02 -0400
committerRobert Haas <rhaas@postgresql.org>2015-10-06 15:45:02 -0400
commit8f6bb851bdb75d741b3a7543bbf681e3cd7e65dc (patch)
tree676d9f4141dfe2896a1ead18475529ac64172144 /src/backend/postmaster/checkpointer.c
parentb943f502b788a3708ca660785fd14a4ee938fdcd (diff)
downloadpostgresql-8f6bb851bdb75d741b3a7543bbf681e3cd7e65dc.tar.gz
postgresql-8f6bb851bdb75d741b3a7543bbf681e3cd7e65dc.zip
Remove more volatile qualifiers.
Prior to commit 0709b7ee72e4bc71ad07b7120acd117265ab51d0, access to variables within a spinlock-protected critical section had to be done through a volatile pointer, but that should no longer be necessary. This continues work begun in df4077cda2eae3eb4a5cf387da0c1e7616e73204 and 6ba4ecbf477e0b25dd7bde1b0c4e07fc2da19348. Thomas Munro and Michael Paquier
Diffstat (limited to 'src/backend/postmaster/checkpointer.c')
-rw-r--r--src/backend/postmaster/checkpointer.c64
1 files changed, 27 insertions, 37 deletions
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index 3b3a09ef886..dc5b8561550 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -288,13 +288,10 @@ CheckpointerMain(void)
/* Warn any waiting backends that the checkpoint failed. */
if (ckpt_active)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile CheckpointerShmemStruct *cps = CheckpointerShmem;
-
- SpinLockAcquire(&cps->ckpt_lck);
- cps->ckpt_failed++;
- cps->ckpt_done = cps->ckpt_started;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ CheckpointerShmem->ckpt_failed++;
+ CheckpointerShmem->ckpt_done = CheckpointerShmem->ckpt_started;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
ckpt_active = false;
}
@@ -428,9 +425,6 @@ CheckpointerMain(void)
bool ckpt_performed = false;
bool do_restartpoint;
- /* use volatile pointer to prevent code rearrangement */
- volatile CheckpointerShmemStruct *cps = CheckpointerShmem;
-
/*
* Check if we should perform a checkpoint or a restartpoint. As a
* side-effect, RecoveryInProgress() initializes TimeLineID if
@@ -443,11 +437,11 @@ CheckpointerMain(void)
* checkpoint we should perform, and increase the started-counter
* to acknowledge that we've started a new checkpoint.
*/
- SpinLockAcquire(&cps->ckpt_lck);
- flags |= cps->ckpt_flags;
- cps->ckpt_flags = 0;
- cps->ckpt_started++;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ flags |= CheckpointerShmem->ckpt_flags;
+ CheckpointerShmem->ckpt_flags = 0;
+ CheckpointerShmem->ckpt_started++;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
/*
* The end-of-recovery checkpoint is a real checkpoint that's
@@ -505,9 +499,9 @@ CheckpointerMain(void)
/*
* Indicate checkpoint completion to any waiting backends.
*/
- SpinLockAcquire(&cps->ckpt_lck);
- cps->ckpt_done = cps->ckpt_started;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ CheckpointerShmem->ckpt_done = CheckpointerShmem->ckpt_started;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
if (ckpt_performed)
{
@@ -957,8 +951,6 @@ CheckpointerShmemInit(void)
void
RequestCheckpoint(int flags)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile CheckpointerShmemStruct *cps = CheckpointerShmem;
int ntries;
int old_failed,
old_started;
@@ -992,13 +984,13 @@ RequestCheckpoint(int flags)
* a "stronger" request by another backend. The flag senses must be
* chosen to make this work!
*/
- SpinLockAcquire(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
- old_failed = cps->ckpt_failed;
- old_started = cps->ckpt_started;
- cps->ckpt_flags |= flags;
+ old_failed = CheckpointerShmem->ckpt_failed;
+ old_started = CheckpointerShmem->ckpt_started;
+ CheckpointerShmem->ckpt_flags |= flags;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
/*
* Send signal to request checkpoint. It's possible that the checkpointer
@@ -1046,9 +1038,9 @@ RequestCheckpoint(int flags)
/* Wait for a new checkpoint to start. */
for (;;)
{
- SpinLockAcquire(&cps->ckpt_lck);
- new_started = cps->ckpt_started;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ new_started = CheckpointerShmem->ckpt_started;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
if (new_started != old_started)
break;
@@ -1064,10 +1056,10 @@ RequestCheckpoint(int flags)
{
int new_done;
- SpinLockAcquire(&cps->ckpt_lck);
- new_done = cps->ckpt_done;
- new_failed = cps->ckpt_failed;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ new_done = CheckpointerShmem->ckpt_done;
+ new_failed = CheckpointerShmem->ckpt_failed;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
if (new_done - new_started >= 0)
break;
@@ -1368,15 +1360,13 @@ UpdateSharedMemoryConfig(void)
bool
FirstCallSinceLastCheckpoint(void)
{
- /* use volatile pointer to prevent code rearrangement */
- volatile CheckpointerShmemStruct *cps = CheckpointerShmem;
static int ckpt_done = 0;
int new_done;
bool FirstCall = false;
- SpinLockAcquire(&cps->ckpt_lck);
- new_done = cps->ckpt_done;
- SpinLockRelease(&cps->ckpt_lck);
+ SpinLockAcquire(&CheckpointerShmem->ckpt_lck);
+ new_done = CheckpointerShmem->ckpt_done;
+ SpinLockRelease(&CheckpointerShmem->ckpt_lck);
if (new_done != ckpt_done)
FirstCall = true;