@@ -738,7 +738,8 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
738
738
if (!isLocalBuf )
739
739
{
740
740
if (mode == RBM_ZERO_AND_LOCK )
741
- LWLockAcquire (bufHdr -> content_lock , LW_EXCLUSIVE );
741
+ LWLockAcquire (BufferDescriptorGetContentLock (bufHdr ),
742
+ LW_EXCLUSIVE );
742
743
else if (mode == RBM_ZERO_AND_CLEANUP_LOCK )
743
744
LockBufferForCleanup (BufferDescriptorGetBuffer (bufHdr ));
744
745
}
@@ -879,7 +880,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
879
880
if ((mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK ) &&
880
881
!isLocalBuf )
881
882
{
882
- LWLockAcquire (bufHdr -> content_lock , LW_EXCLUSIVE );
883
+ LWLockAcquire (BufferDescriptorGetContentLock ( bufHdr ) , LW_EXCLUSIVE );
883
884
}
884
885
885
886
if (isLocalBuf )
@@ -1045,7 +1046,8 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
1045
1046
* happens to be trying to split the page the first one got from
1046
1047
* StrategyGetBuffer.)
1047
1048
*/
1048
- if (LWLockConditionalAcquire (buf -> content_lock , LW_SHARED ))
1049
+ if (LWLockConditionalAcquire (BufferDescriptorGetContentLock (buf ),
1050
+ LW_SHARED ))
1049
1051
{
1050
1052
/*
1051
1053
* If using a nondefault strategy, and writing the buffer
@@ -1067,7 +1069,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
1067
1069
StrategyRejectBuffer (strategy , buf ))
1068
1070
{
1069
1071
/* Drop lock/pin and loop around for another buffer */
1070
- LWLockRelease (buf -> content_lock );
1072
+ LWLockRelease (BufferDescriptorGetContentLock ( buf ) );
1071
1073
UnpinBuffer (buf , true);
1072
1074
continue ;
1073
1075
}
@@ -1080,7 +1082,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
1080
1082
smgr -> smgr_rnode .node .relNode );
1081
1083
1082
1084
FlushBuffer (buf , NULL );
1083
- LWLockRelease (buf -> content_lock );
1085
+ LWLockRelease (BufferDescriptorGetContentLock ( buf ) );
1084
1086
1085
1087
TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_DONE (forkNum , blockNum ,
1086
1088
smgr -> smgr_rnode .node .spcNode ,
@@ -1395,7 +1397,7 @@ MarkBufferDirty(Buffer buffer)
1395
1397
1396
1398
Assert (BufferIsPinned (buffer ));
1397
1399
/* unfortunately we can't check if the lock is held exclusively */
1398
- Assert (LWLockHeldByMe (bufHdr -> content_lock ));
1400
+ Assert (LWLockHeldByMe (BufferDescriptorGetContentLock ( bufHdr ) ));
1399
1401
1400
1402
LockBufHdr (bufHdr );
1401
1403
@@ -1595,8 +1597,8 @@ UnpinBuffer(BufferDesc *buf, bool fixOwner)
1595
1597
if (ref -> refcount == 0 )
1596
1598
{
1597
1599
/* I'd better not still hold any locks on the buffer */
1598
- Assert (!LWLockHeldByMe (buf -> content_lock ));
1599
- Assert (!LWLockHeldByMe (buf -> io_in_progress_lock ));
1600
+ Assert (!LWLockHeldByMe (BufferDescriptorGetContentLock ( buf ) ));
1601
+ Assert (!LWLockHeldByMe (BufferDescriptorGetIOLock ( buf ) ));
1600
1602
1601
1603
LockBufHdr (buf );
1602
1604
@@ -2116,11 +2118,11 @@ SyncOneBuffer(int buf_id, bool skip_recently_used)
2116
2118
* buffer is clean by the time we've locked it.)
2117
2119
*/
2118
2120
PinBuffer_Locked (bufHdr );
2119
- LWLockAcquire (bufHdr -> content_lock , LW_SHARED );
2121
+ LWLockAcquire (BufferDescriptorGetContentLock ( bufHdr ) , LW_SHARED );
2120
2122
2121
2123
FlushBuffer (bufHdr , NULL );
2122
2124
2123
- LWLockRelease (bufHdr -> content_lock );
2125
+ LWLockRelease (BufferDescriptorGetContentLock ( bufHdr ) );
2124
2126
UnpinBuffer (bufHdr , true);
2125
2127
2126
2128
return result | BUF_WRITTEN ;
@@ -2926,9 +2928,9 @@ FlushRelationBuffers(Relation rel)
2926
2928
(bufHdr -> flags & BM_VALID ) && (bufHdr -> flags & BM_DIRTY ))
2927
2929
{
2928
2930
PinBuffer_Locked (bufHdr );
2929
- LWLockAcquire (bufHdr -> content_lock , LW_SHARED );
2931
+ LWLockAcquire (BufferDescriptorGetContentLock ( bufHdr ) , LW_SHARED );
2930
2932
FlushBuffer (bufHdr , rel -> rd_smgr );
2931
- LWLockRelease (bufHdr -> content_lock );
2933
+ LWLockRelease (BufferDescriptorGetContentLock ( bufHdr ) );
2932
2934
UnpinBuffer (bufHdr , true);
2933
2935
}
2934
2936
else
@@ -2978,9 +2980,9 @@ FlushDatabaseBuffers(Oid dbid)
2978
2980
(bufHdr -> flags & BM_VALID ) && (bufHdr -> flags & BM_DIRTY ))
2979
2981
{
2980
2982
PinBuffer_Locked (bufHdr );
2981
- LWLockAcquire (bufHdr -> content_lock , LW_SHARED );
2983
+ LWLockAcquire (BufferDescriptorGetContentLock ( bufHdr ) , LW_SHARED );
2982
2984
FlushBuffer (bufHdr , NULL );
2983
- LWLockRelease (bufHdr -> content_lock );
2985
+ LWLockRelease (BufferDescriptorGetContentLock ( bufHdr ) );
2984
2986
UnpinBuffer (bufHdr , true);
2985
2987
}
2986
2988
else
@@ -3004,7 +3006,7 @@ FlushOneBuffer(Buffer buffer)
3004
3006
3005
3007
bufHdr = GetBufferDescriptor (buffer - 1 );
3006
3008
3007
- Assert (LWLockHeldByMe (bufHdr -> content_lock ));
3009
+ Assert (LWLockHeldByMe (BufferDescriptorGetContentLock ( bufHdr ) ));
3008
3010
3009
3011
FlushBuffer (bufHdr , NULL );
3010
3012
}
@@ -3101,7 +3103,7 @@ MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
3101
3103
3102
3104
Assert (GetPrivateRefCount (buffer ) > 0 );
3103
3105
/* here, either share or exclusive lock is OK */
3104
- Assert (LWLockHeldByMe (bufHdr -> content_lock ));
3106
+ Assert (LWLockHeldByMe (BufferDescriptorGetContentLock ( bufHdr ) ));
3105
3107
3106
3108
/*
3107
3109
* This routine might get called many times on the same page, if we are
@@ -3254,11 +3256,11 @@ LockBuffer(Buffer buffer, int mode)
3254
3256
buf = GetBufferDescriptor (buffer - 1 );
3255
3257
3256
3258
if (mode == BUFFER_LOCK_UNLOCK )
3257
- LWLockRelease (buf -> content_lock );
3259
+ LWLockRelease (BufferDescriptorGetContentLock ( buf ) );
3258
3260
else if (mode == BUFFER_LOCK_SHARE )
3259
- LWLockAcquire (buf -> content_lock , LW_SHARED );
3261
+ LWLockAcquire (BufferDescriptorGetContentLock ( buf ) , LW_SHARED );
3260
3262
else if (mode == BUFFER_LOCK_EXCLUSIVE )
3261
- LWLockAcquire (buf -> content_lock , LW_EXCLUSIVE );
3263
+ LWLockAcquire (BufferDescriptorGetContentLock ( buf ) , LW_EXCLUSIVE );
3262
3264
else
3263
3265
elog (ERROR , "unrecognized buffer lock mode: %d" , mode );
3264
3266
}
@@ -3279,7 +3281,8 @@ ConditionalLockBuffer(Buffer buffer)
3279
3281
3280
3282
buf = GetBufferDescriptor (buffer - 1 );
3281
3283
3282
- return LWLockConditionalAcquire (buf -> content_lock , LW_EXCLUSIVE );
3284
+ return LWLockConditionalAcquire (BufferDescriptorGetContentLock (buf ),
3285
+ LW_EXCLUSIVE );
3283
3286
}
3284
3287
3285
3288
/*
@@ -3489,8 +3492,8 @@ WaitIO(BufferDesc *buf)
3489
3492
UnlockBufHdr (buf );
3490
3493
if (!(sv_flags & BM_IO_IN_PROGRESS ))
3491
3494
break ;
3492
- LWLockAcquire (buf -> io_in_progress_lock , LW_SHARED );
3493
- LWLockRelease (buf -> io_in_progress_lock );
3495
+ LWLockAcquire (BufferDescriptorGetIOLock ( buf ) , LW_SHARED );
3496
+ LWLockRelease (BufferDescriptorGetIOLock ( buf ) );
3494
3497
}
3495
3498
}
3496
3499
@@ -3523,7 +3526,7 @@ StartBufferIO(BufferDesc *buf, bool forInput)
3523
3526
* Grab the io_in_progress lock so that other processes can wait for
3524
3527
* me to finish the I/O.
3525
3528
*/
3526
- LWLockAcquire (buf -> io_in_progress_lock , LW_EXCLUSIVE );
3529
+ LWLockAcquire (BufferDescriptorGetIOLock ( buf ) , LW_EXCLUSIVE );
3527
3530
3528
3531
LockBufHdr (buf );
3529
3532
@@ -3537,7 +3540,7 @@ StartBufferIO(BufferDesc *buf, bool forInput)
3537
3540
* him to get unwedged.
3538
3541
*/
3539
3542
UnlockBufHdr (buf );
3540
- LWLockRelease (buf -> io_in_progress_lock );
3543
+ LWLockRelease (BufferDescriptorGetIOLock ( buf ) );
3541
3544
WaitIO (buf );
3542
3545
}
3543
3546
@@ -3547,7 +3550,7 @@ StartBufferIO(BufferDesc *buf, bool forInput)
3547
3550
{
3548
3551
/* someone else already did the I/O */
3549
3552
UnlockBufHdr (buf );
3550
- LWLockRelease (buf -> io_in_progress_lock );
3553
+ LWLockRelease (BufferDescriptorGetIOLock ( buf ) );
3551
3554
return false;
3552
3555
}
3553
3556
@@ -3595,7 +3598,7 @@ TerminateBufferIO(BufferDesc *buf, bool clear_dirty, int set_flag_bits)
3595
3598
3596
3599
InProgressBuf = NULL ;
3597
3600
3598
- LWLockRelease (buf -> io_in_progress_lock );
3601
+ LWLockRelease (BufferDescriptorGetIOLock ( buf ) );
3599
3602
}
3600
3603
3601
3604
/*
@@ -3620,7 +3623,7 @@ AbortBufferIO(void)
3620
3623
* we can use TerminateBufferIO. Anyone who's executing WaitIO on the
3621
3624
* buffer will be in a busy spin until we succeed in doing this.
3622
3625
*/
3623
- LWLockAcquire (buf -> io_in_progress_lock , LW_EXCLUSIVE );
3626
+ LWLockAcquire (BufferDescriptorGetIOLock ( buf ) , LW_EXCLUSIVE );
3624
3627
3625
3628
LockBufHdr (buf );
3626
3629
Assert (buf -> flags & BM_IO_IN_PROGRESS );
0 commit comments