Commit e93b6298 authored by Robert Haas's avatar Robert Haas

Remove volatile qualifiers from bufmgr.c and freelist.c

Prior to commit 0709b7ee, access to
variables within a spinlock-protected critical section had to be done
through a volatile pointer, but that should no longer be necessary.

Review by Andres Freund
parent 8004953b
This diff is collapsed.
......@@ -98,9 +98,9 @@ typedef struct BufferAccessStrategyData
/* Prototypes for internal functions */
static volatile BufferDesc *GetBufferFromRing(BufferAccessStrategy strategy);
static BufferDesc *GetBufferFromRing(BufferAccessStrategy strategy);
static void AddBufferToRing(BufferAccessStrategy strategy,
volatile BufferDesc *buf);
BufferDesc *buf);
/*
* ClockSweepTick - Helper routine for StrategyGetBuffer()
......@@ -179,10 +179,10 @@ ClockSweepTick(void)
* To ensure that no one else can pin the buffer before we do, we must
* return the buffer with the buffer header spinlock still held.
*/
volatile BufferDesc *
BufferDesc *
StrategyGetBuffer(BufferAccessStrategy strategy)
{
volatile BufferDesc *buf;
BufferDesc *buf;
int bgwprocno;
int trycounter;
......@@ -338,7 +338,7 @@ StrategyGetBuffer(BufferAccessStrategy strategy)
* StrategyFreeBuffer: put a buffer on the freelist
*/
void
StrategyFreeBuffer(volatile BufferDesc *buf)
StrategyFreeBuffer(BufferDesc *buf)
{
SpinLockAcquire(&StrategyControl->buffer_strategy_lock);
......@@ -584,10 +584,10 @@ FreeAccessStrategy(BufferAccessStrategy strategy)
*
* The bufhdr spin lock is held on the returned buffer.
*/
static volatile BufferDesc *
static BufferDesc *
GetBufferFromRing(BufferAccessStrategy strategy)
{
volatile BufferDesc *buf;
BufferDesc *buf;
Buffer bufnum;
/* Advance to next ring slot */
......@@ -639,7 +639,7 @@ GetBufferFromRing(BufferAccessStrategy strategy)
* is called with the spinlock held, it had better be quite cheap.
*/
static void
AddBufferToRing(BufferAccessStrategy strategy, volatile BufferDesc *buf)
AddBufferToRing(BufferAccessStrategy strategy, BufferDesc *buf)
{
strategy->buffers[strategy->current] = BufferDescriptorGetBuffer(buf);
}
......@@ -656,7 +656,7 @@ AddBufferToRing(BufferAccessStrategy strategy, volatile BufferDesc *buf)
* if this buffer should be written and re-used.
*/
bool
StrategyRejectBuffer(BufferAccessStrategy strategy, volatile BufferDesc *buf)
StrategyRejectBuffer(BufferAccessStrategy strategy, BufferDesc *buf)
{
/* We only do this in bulkread mode */
if (strategy->btype != BAS_BULKREAD)
......
......@@ -194,11 +194,6 @@ typedef union BufferDescPadded
/*
* Macros for acquiring/releasing a shared buffer header's spinlock.
* Do not apply these to local buffers!
*
* Note: as a general coding rule, if you are using these then you probably
* need to be using a volatile-qualified pointer to the buffer header, to
* ensure that the compiler doesn't rearrange accesses to the header to
* occur before or after the spinlock is acquired/released.
*/
#define LockBufHdr(bufHdr) SpinLockAcquire(&(bufHdr)->buf_hdr_lock)
#define UnlockBufHdr(bufHdr) SpinLockRelease(&(bufHdr)->buf_hdr_lock)
......@@ -216,10 +211,10 @@ extern BufferDesc *LocalBufferDescriptors;
*/
/* freelist.c */
extern volatile BufferDesc *StrategyGetBuffer(BufferAccessStrategy strategy);
extern void StrategyFreeBuffer(volatile BufferDesc *buf);
extern BufferDesc *StrategyGetBuffer(BufferAccessStrategy strategy);
extern void StrategyFreeBuffer(BufferDesc *buf);
extern bool StrategyRejectBuffer(BufferAccessStrategy strategy,
volatile BufferDesc *buf);
BufferDesc *buf);
extern int StrategySyncStart(uint32 *complete_passes, uint32 *num_buf_alloc);
extern void StrategyNotifyBgWriter(int bgwprocno);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment