@@ -677,7 +677,8 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
677
677
if (!isLocalBuf )
678
678
{
679
679
if (mode == RBM_ZERO_AND_LOCK )
680
- LWLockAcquire (bufHdr -> content_lock , LW_EXCLUSIVE );
680
+ LWLockAcquire (BufferDescriptorGetContentLock (bufHdr ),
681
+ LW_EXCLUSIVE );
681
682
else if (mode == RBM_ZERO_AND_CLEANUP_LOCK )
682
683
LockBufferForCleanup (BufferDescriptorGetBuffer (bufHdr ));
683
684
}
@@ -818,7 +819,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
818
819
if ((mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK ) &&
819
820
!isLocalBuf )
820
821
{
821
- LWLockAcquire (bufHdr -> content_lock , LW_EXCLUSIVE );
822
+ LWLockAcquire (BufferDescriptorGetContentLock ( bufHdr ) , LW_EXCLUSIVE );
822
823
}
823
824
824
825
if (isLocalBuf )
@@ -984,7 +985,8 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
984
985
* happens to be trying to split the page the first one got from
985
986
* StrategyGetBuffer.)
986
987
*/
987
- if (LWLockConditionalAcquire (buf -> content_lock , LW_SHARED ))
988
+ if (LWLockConditionalAcquire (BufferDescriptorGetContentLock (buf ),
989
+ LW_SHARED ))
988
990
{
989
991
/*
990
992
* If using a nondefault strategy, and writing the buffer
@@ -1006,7 +1008,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
1006
1008
StrategyRejectBuffer (strategy , buf ))
1007
1009
{
1008
1010
/* Drop lock/pin and loop around for another buffer */
1009
- LWLockRelease (buf -> content_lock );
1011
+ LWLockRelease (BufferDescriptorGetContentLock ( buf ) );
1010
1012
UnpinBuffer (buf , true);
1011
1013
continue ;
1012
1014
}
@@ -1019,7 +1021,7 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
1019
1021
smgr -> smgr_rnode .node .relNode );
1020
1022
1021
1023
FlushBuffer (buf , NULL );
1022
- LWLockRelease (buf -> content_lock );
1024
+ LWLockRelease (BufferDescriptorGetContentLock ( buf ) );
1023
1025
1024
1026
TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_DONE (forkNum , blockNum ,
1025
1027
smgr -> smgr_rnode .node .spcNode ,
@@ -1334,7 +1336,7 @@ MarkBufferDirty(Buffer buffer)
1334
1336
1335
1337
Assert (BufferIsPinned (buffer ));
1336
1338
/* unfortunately we can't check if the lock is held exclusively */
1337
- Assert (LWLockHeldByMe (bufHdr -> content_lock ));
1339
+ Assert (LWLockHeldByMe (BufferDescriptorGetContentLock ( bufHdr ) ));
1338
1340
1339
1341
LockBufHdr (bufHdr );
1340
1342
@@ -1534,8 +1536,8 @@ UnpinBuffer(volatile BufferDesc *buf, bool fixOwner)
1534
1536
if (ref -> refcount == 0 )
1535
1537
{
1536
1538
/* I'd better not still hold any locks on the buffer */
1537
- Assert (!LWLockHeldByMe (buf -> content_lock ));
1538
- Assert (!LWLockHeldByMe (buf -> io_in_progress_lock ));
1539
+ Assert (!LWLockHeldByMe (BufferDescriptorGetContentLock ( buf ) ));
1540
+ Assert (!LWLockHeldByMe (BufferDescriptorGetIOLock ( buf ) ));
1539
1541
1540
1542
LockBufHdr (buf );
1541
1543
@@ -2055,11 +2057,11 @@ SyncOneBuffer(int buf_id, bool skip_recently_used)
2055
2057
* buffer is clean by the time we've locked it.)
2056
2058
*/
2057
2059
PinBuffer_Locked (bufHdr );
2058
- LWLockAcquire (bufHdr -> content_lock , LW_SHARED );
2060
+ LWLockAcquire (BufferDescriptorGetContentLock ( bufHdr ) , LW_SHARED );
2059
2061
2060
2062
FlushBuffer (bufHdr , NULL );
2061
2063
2062
- LWLockRelease (bufHdr -> content_lock );
2064
+ LWLockRelease (BufferDescriptorGetContentLock ( bufHdr ) );
2063
2065
UnpinBuffer (bufHdr , true);
2064
2066
2065
2067
return result | BUF_WRITTEN ;
@@ -2865,9 +2867,9 @@ FlushRelationBuffers(Relation rel)
2865
2867
(bufHdr -> flags & BM_VALID ) && (bufHdr -> flags & BM_DIRTY ))
2866
2868
{
2867
2869
PinBuffer_Locked (bufHdr );
2868
- LWLockAcquire (bufHdr -> content_lock , LW_SHARED );
2870
+ LWLockAcquire (BufferDescriptorGetContentLock ( bufHdr ) , LW_SHARED );
2869
2871
FlushBuffer (bufHdr , rel -> rd_smgr );
2870
- LWLockRelease (bufHdr -> content_lock );
2872
+ LWLockRelease (BufferDescriptorGetContentLock ( bufHdr ) );
2871
2873
UnpinBuffer (bufHdr , true);
2872
2874
}
2873
2875
else
@@ -2917,9 +2919,9 @@ FlushDatabaseBuffers(Oid dbid)
2917
2919
(bufHdr -> flags & BM_VALID ) && (bufHdr -> flags & BM_DIRTY ))
2918
2920
{
2919
2921
PinBuffer_Locked (bufHdr );
2920
- LWLockAcquire (bufHdr -> content_lock , LW_SHARED );
2922
+ LWLockAcquire (BufferDescriptorGetContentLock ( bufHdr ) , LW_SHARED );
2921
2923
FlushBuffer (bufHdr , NULL );
2922
- LWLockRelease (bufHdr -> content_lock );
2924
+ LWLockRelease (BufferDescriptorGetContentLock ( bufHdr ) );
2923
2925
UnpinBuffer (bufHdr , true);
2924
2926
}
2925
2927
else
@@ -2943,7 +2945,7 @@ FlushOneBuffer(Buffer buffer)
2943
2945
2944
2946
bufHdr = GetBufferDescriptor (buffer - 1 );
2945
2947
2946
- Assert (LWLockHeldByMe (bufHdr -> content_lock ));
2948
+ Assert (LWLockHeldByMe (BufferDescriptorGetContentLock ( bufHdr ) ));
2947
2949
2948
2950
FlushBuffer (bufHdr , NULL );
2949
2951
}
@@ -3040,7 +3042,7 @@ MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
3040
3042
3041
3043
Assert (GetPrivateRefCount (buffer ) > 0 );
3042
3044
/* here, either share or exclusive lock is OK */
3043
- Assert (LWLockHeldByMe (bufHdr -> content_lock ));
3045
+ Assert (LWLockHeldByMe (BufferDescriptorGetContentLock ( bufHdr ) ));
3044
3046
3045
3047
/*
3046
3048
* This routine might get called many times on the same page, if we are
@@ -3193,11 +3195,11 @@ LockBuffer(Buffer buffer, int mode)
3193
3195
buf = GetBufferDescriptor (buffer - 1 );
3194
3196
3195
3197
if (mode == BUFFER_LOCK_UNLOCK )
3196
- LWLockRelease (buf -> content_lock );
3198
+ LWLockRelease (BufferDescriptorGetContentLock ( buf ) );
3197
3199
else if (mode == BUFFER_LOCK_SHARE )
3198
- LWLockAcquire (buf -> content_lock , LW_SHARED );
3200
+ LWLockAcquire (BufferDescriptorGetContentLock ( buf ) , LW_SHARED );
3199
3201
else if (mode == BUFFER_LOCK_EXCLUSIVE )
3200
- LWLockAcquire (buf -> content_lock , LW_EXCLUSIVE );
3202
+ LWLockAcquire (BufferDescriptorGetContentLock ( buf ) , LW_EXCLUSIVE );
3201
3203
else
3202
3204
elog (ERROR , "unrecognized buffer lock mode: %d" , mode );
3203
3205
}
@@ -3218,7 +3220,8 @@ ConditionalLockBuffer(Buffer buffer)
3218
3220
3219
3221
buf = GetBufferDescriptor (buffer - 1 );
3220
3222
3221
- return LWLockConditionalAcquire (buf -> content_lock , LW_EXCLUSIVE );
3223
+ return LWLockConditionalAcquire (BufferDescriptorGetContentLock (buf ),
3224
+ LW_EXCLUSIVE );
3222
3225
}
3223
3226
3224
3227
/*
@@ -3428,8 +3431,8 @@ WaitIO(volatile BufferDesc *buf)
3428
3431
UnlockBufHdr (buf );
3429
3432
if (!(sv_flags & BM_IO_IN_PROGRESS ))
3430
3433
break ;
3431
- LWLockAcquire (buf -> io_in_progress_lock , LW_SHARED );
3432
- LWLockRelease (buf -> io_in_progress_lock );
3434
+ LWLockAcquire (BufferDescriptorGetIOLock ( buf ) , LW_SHARED );
3435
+ LWLockRelease (BufferDescriptorGetIOLock ( buf ) );
3433
3436
}
3434
3437
}
3435
3438
@@ -3462,7 +3465,7 @@ StartBufferIO(volatile BufferDesc *buf, bool forInput)
3462
3465
* Grab the io_in_progress lock so that other processes can wait for
3463
3466
* me to finish the I/O.
3464
3467
*/
3465
- LWLockAcquire (buf -> io_in_progress_lock , LW_EXCLUSIVE );
3468
+ LWLockAcquire (BufferDescriptorGetIOLock ( buf ) , LW_EXCLUSIVE );
3466
3469
3467
3470
LockBufHdr (buf );
3468
3471
@@ -3476,7 +3479,7 @@ StartBufferIO(volatile BufferDesc *buf, bool forInput)
3476
3479
* him to get unwedged.
3477
3480
*/
3478
3481
UnlockBufHdr (buf );
3479
- LWLockRelease (buf -> io_in_progress_lock );
3482
+ LWLockRelease (BufferDescriptorGetIOLock ( buf ) );
3480
3483
WaitIO (buf );
3481
3484
}
3482
3485
@@ -3486,7 +3489,7 @@ StartBufferIO(volatile BufferDesc *buf, bool forInput)
3486
3489
{
3487
3490
/* someone else already did the I/O */
3488
3491
UnlockBufHdr (buf );
3489
- LWLockRelease (buf -> io_in_progress_lock );
3492
+ LWLockRelease (BufferDescriptorGetIOLock ( buf ) );
3490
3493
return false;
3491
3494
}
3492
3495
@@ -3535,7 +3538,7 @@ TerminateBufferIO(volatile BufferDesc *buf, bool clear_dirty,
3535
3538
3536
3539
InProgressBuf = NULL ;
3537
3540
3538
- LWLockRelease (buf -> io_in_progress_lock );
3541
+ LWLockRelease (BufferDescriptorGetIOLock ( buf ) );
3539
3542
}
3540
3543
3541
3544
/*
@@ -3560,7 +3563,7 @@ AbortBufferIO(void)
3560
3563
* we can use TerminateBufferIO. Anyone who's executing WaitIO on the
3561
3564
* buffer will be in a busy spin until we succeed in doing this.
3562
3565
*/
3563
- LWLockAcquire (buf -> io_in_progress_lock , LW_EXCLUSIVE );
3566
+ LWLockAcquire (BufferDescriptorGetIOLock ( buf ) , LW_EXCLUSIVE );
3564
3567
3565
3568
LockBufHdr (buf );
3566
3569
Assert (buf -> flags & BM_IO_IN_PROGRESS );
0 commit comments