@@ -1273,7 +1273,7 @@ InvalidateBuffer(volatile BufferDesc *buf)
1273
1273
UnlockBufHdr (buf );
1274
1274
LWLockRelease (oldPartitionLock );
1275
1275
/* safety check: should definitely not be our *own* pin */
1276
- if (GetPrivateRefCount (buf -> buf_id ) > 0 )
1276
+ if (GetPrivateRefCount (BufferDescriptorGetBuffer ( buf ) ) > 0 )
1277
1277
elog (ERROR , "buffer is pinned in InvalidateBuffer" );
1278
1278
WaitIO (buf );
1279
1279
goto retry ;
@@ -1426,16 +1426,16 @@ ReleaseAndReadBuffer(Buffer buffer,
1426
1426
static bool
1427
1427
PinBuffer (volatile BufferDesc * buf , BufferAccessStrategy strategy )
1428
1428
{
1429
- int b = buf -> buf_id ;
1429
+ Buffer b = BufferDescriptorGetBuffer ( buf ) ;
1430
1430
bool result ;
1431
1431
PrivateRefCountEntry * ref ;
1432
1432
1433
- ref = GetPrivateRefCountEntry (b + 1 , true);
1433
+ ref = GetPrivateRefCountEntry (b , true);
1434
1434
1435
1435
if (ref == NULL )
1436
1436
{
1437
1437
ReservePrivateRefCountEntry ();
1438
- ref = NewPrivateRefCountEntry (b + 1 );
1438
+ ref = NewPrivateRefCountEntry (b );
1439
1439
1440
1440
LockBufHdr (buf );
1441
1441
buf -> refcount ++ ;
@@ -1460,8 +1460,7 @@ PinBuffer(volatile BufferDesc *buf, BufferAccessStrategy strategy)
1460
1460
1461
1461
ref -> refcount ++ ;
1462
1462
Assert (ref -> refcount > 0 );
1463
- ResourceOwnerRememberBuffer (CurrentResourceOwner ,
1464
- BufferDescriptorGetBuffer (buf ));
1463
+ ResourceOwnerRememberBuffer (CurrentResourceOwner , b );
1465
1464
return result ;
1466
1465
}
1467
1466
@@ -1489,23 +1488,24 @@ PinBuffer(volatile BufferDesc *buf, BufferAccessStrategy strategy)
1489
1488
static void
1490
1489
PinBuffer_Locked (volatile BufferDesc * buf )
1491
1490
{
1492
- int b = buf -> buf_id ;
1491
+ Buffer b ;
1493
1492
PrivateRefCountEntry * ref ;
1494
1493
1495
1494
/*
1496
1495
* As explained, We don't expect any preexisting pins. That allows us to
1497
1496
* manipulate the PrivateRefCount after releasing the spinlock
1498
1497
*/
1499
- Assert (GetPrivateRefCountEntry (b + 1 , false) == NULL );
1498
+ Assert (GetPrivateRefCountEntry (BufferDescriptorGetBuffer ( buf ) , false) == NULL );
1500
1499
1501
1500
buf -> refcount ++ ;
1502
1501
UnlockBufHdr (buf );
1503
1502
1504
- ref = NewPrivateRefCountEntry (b + 1 );
1503
+ b = BufferDescriptorGetBuffer (buf );
1504
+
1505
+ ref = NewPrivateRefCountEntry (b );
1505
1506
ref -> refcount ++ ;
1506
1507
1507
- ResourceOwnerRememberBuffer (CurrentResourceOwner ,
1508
- BufferDescriptorGetBuffer (buf ));
1508
+ ResourceOwnerRememberBuffer (CurrentResourceOwner , b );
1509
1509
}
1510
1510
1511
1511
/*
@@ -1520,14 +1520,14 @@ static void
1520
1520
UnpinBuffer (volatile BufferDesc * buf , bool fixOwner )
1521
1521
{
1522
1522
PrivateRefCountEntry * ref ;
1523
+ Buffer b = BufferDescriptorGetBuffer (buf );
1523
1524
1524
1525
/* not moving as we're likely deleting it soon anyway */
1525
- ref = GetPrivateRefCountEntry (buf -> buf_id + 1 , false);
1526
+ ref = GetPrivateRefCountEntry (b , false);
1526
1527
Assert (ref != NULL );
1527
1528
1528
1529
if (fixOwner )
1529
- ResourceOwnerForgetBuffer (CurrentResourceOwner ,
1530
- BufferDescriptorGetBuffer (buf ));
1530
+ ResourceOwnerForgetBuffer (CurrentResourceOwner , b );
1531
1531
1532
1532
Assert (ref -> refcount > 0 );
1533
1533
ref -> refcount -- ;
@@ -2739,6 +2739,7 @@ PrintBufferDescs(void)
2739
2739
for (i = 0 ; i < NBuffers ; ++ i )
2740
2740
{
2741
2741
volatile BufferDesc * buf = GetBufferDescriptor (i );
2742
+ Buffer b = BufferDescriptorGetBuffer (buf );
2742
2743
2743
2744
/* theoretically we should lock the bufhdr here */
2744
2745
elog (LOG ,
@@ -2747,7 +2748,7 @@ PrintBufferDescs(void)
2747
2748
i , buf -> freeNext ,
2748
2749
relpathbackend (buf -> tag .rnode , InvalidBackendId , buf -> tag .forkNum ),
2749
2750
buf -> tag .blockNum , buf -> flags ,
2750
- buf -> refcount , GetPrivateRefCount (i ));
2751
+ buf -> refcount , GetPrivateRefCount (b ));
2751
2752
}
2752
2753
}
2753
2754
#endif
@@ -2761,8 +2762,9 @@ PrintPinnedBufs(void)
2761
2762
for (i = 0 ; i < NBuffers ; ++ i )
2762
2763
{
2763
2764
volatile BufferDesc * buf = GetBufferDescriptor (i );
2765
+ Buffer b = BufferDescriptorGetBuffer (buf );
2764
2766
2765
- if (GetPrivateRefCount (i + 1 ) > 0 )
2767
+ if (GetPrivateRefCount (b ) > 0 )
2766
2768
{
2767
2769
/* theoretically we should lock the bufhdr here */
2768
2770
elog (LOG ,
@@ -2771,7 +2773,7 @@ PrintPinnedBufs(void)
2771
2773
i , buf -> freeNext ,
2772
2774
relpathperm (buf -> tag .rnode , buf -> tag .forkNum ),
2773
2775
buf -> tag .blockNum , buf -> flags ,
2774
- buf -> refcount , GetPrivateRefCount (i + 1 ));
2776
+ buf -> refcount , GetPrivateRefCount (b ));
2775
2777
}
2776
2778
}
2777
2779
}
0 commit comments