@ -191,6 +191,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
/* shared->latest_page_number will be set later */
/* shared->latest_page_number will be set later */
shared - > slru_stats_idx = pgstat_slru_index ( name ) ;
ptr = ( char * ) shared ;
ptr = ( char * ) shared ;
offset = MAXALIGN ( sizeof ( SlruSharedData ) ) ;
offset = MAXALIGN ( sizeof ( SlruSharedData ) ) ;
shared - > page_buffer = ( char * * ) ( ptr + offset ) ;
shared - > page_buffer = ( char * * ) ( ptr + offset ) ;
@ -214,15 +216,11 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
offset + = MAXALIGN ( nslots * nlsns * sizeof ( XLogRecPtr ) ) ;
offset + = MAXALIGN ( nslots * nlsns * sizeof ( XLogRecPtr ) ) ;
}
}
Assert ( strlen ( name ) + 1 < SLRU_MAX_NAME_LENGTH ) ;
strlcpy ( shared - > lwlock_tranche_name , name , SLRU_MAX_NAME_LENGTH ) ;
shared - > lwlock_tranche_id = tranche_id ;
ptr + = BUFFERALIGN ( offset ) ;
ptr + = BUFFERALIGN ( offset ) ;
for ( slotno = 0 ; slotno < nslots ; slotno + + )
for ( slotno = 0 ; slotno < nslots ; slotno + + )
{
{
LWLockInitialize ( & shared - > buffer_locks [ slotno ] . lock ,
LWLockInitialize ( & shared - > buffer_locks [ slotno ] . lock ,
shared - > lwlock_ tranche_id) ;
tranche_id ) ;
shared - > page_buffer [ slotno ] = ptr ;
shared - > page_buffer [ slotno ] = ptr ;
shared - > page_status [ slotno ] = SLRU_PAGE_EMPTY ;
shared - > page_status [ slotno ] = SLRU_PAGE_EMPTY ;
@ -238,8 +236,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
Assert ( found ) ;
Assert ( found ) ;
/* Register SLRU tranche in the main tranches array */
/* Register SLRU tranche in the main tranches array */
LWLockRegisterTranche ( shared - > lwlock_tranche_id ,
LWLockRegisterTranche ( tranche_id , name ) ;
shared - > lwlock_tranche_name ) ;
/*
/*
* Initialize the unshared control struct , including directory path . We
* Initialize the unshared control struct , including directory path . We
@ -287,7 +284,7 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
shared - > latest_page_number = pageno ;
shared - > latest_page_number = pageno ;
/* update the stats counter of zeroed pages */
/* update the stats counter of zeroed pages */
pgstat_count_slru_page_zeroed ( ctl ) ;
pgstat_count_slru_page_zeroed ( shared - > slru_stats_idx ) ;
return slotno ;
return slotno ;
}
}
@ -408,7 +405,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
SlruRecentlyUsed ( shared , slotno ) ;
SlruRecentlyUsed ( shared , slotno ) ;
/* update the stats counter of pages found in the SLRU */
/* update the stats counter of pages found in the SLRU */
pgstat_count_slru_page_hit ( ctl ) ;
pgstat_count_slru_page_hit ( shared - > slru_stats_idx ) ;
return slotno ;
return slotno ;
}
}
@ -453,7 +450,7 @@ SimpleLruReadPage(SlruCtl ctl, int pageno, bool write_ok,
SlruRecentlyUsed ( shared , slotno ) ;
SlruRecentlyUsed ( shared , slotno ) ;
/* update the stats counter of pages not found in SLRU */
/* update the stats counter of pages not found in SLRU */
pgstat_count_slru_page_read ( ctl ) ;
pgstat_count_slru_page_read ( shared - > slru_stats_idx ) ;
return slotno ;
return slotno ;
}
}
@ -493,7 +490,7 @@ SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno, TransactionId xid)
SlruRecentlyUsed ( shared , slotno ) ;
SlruRecentlyUsed ( shared , slotno ) ;
/* update the stats counter of pages found in the SLRU */
/* update the stats counter of pages found in the SLRU */
pgstat_count_slru_page_hit ( ctl ) ;
pgstat_count_slru_page_hit ( shared - > slru_stats_idx ) ;
return slotno ;
return slotno ;
}
}
@ -612,7 +609,7 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
off_t endpos ;
off_t endpos ;
/* update the stats counter of checked pages */
/* update the stats counter of checked pages */
pgstat_count_slru_page_exists ( ctl ) ;
pgstat_count_slru_page_exists ( ctl - > shared - > slru_stats_idx ) ;
SlruFileName ( ctl , path , segno ) ;
SlruFileName ( ctl , path , segno ) ;
@ -749,7 +746,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
int fd = - 1 ;
int fd = - 1 ;
/* update the stats counter of written pages */
/* update the stats counter of written pages */
pgstat_count_slru_page_written ( ctl ) ;
pgstat_count_slru_page_written ( shared - > slru_stats_idx ) ;
/*
/*
* Honor the write - WAL - before - data rule , if appropriate , so that we do not
* Honor the write - WAL - before - data rule , if appropriate , so that we do not
@ -1147,7 +1144,7 @@ SimpleLruFlush(SlruCtl ctl, bool allow_redirtied)
bool ok ;
bool ok ;
/* update the stats counter of flushes */
/* update the stats counter of flushes */
pgstat_count_slru_flush ( ctl ) ;
pgstat_count_slru_flush ( shared - > slru_stats_idx ) ;
/*
/*
* Find and write dirty pages
* Find and write dirty pages
@ -1211,7 +1208,7 @@ SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
int slotno ;
int slotno ;
/* update the stats counter of truncates */
/* update the stats counter of truncates */
pgstat_count_slru_truncate ( ctl ) ;
pgstat_count_slru_truncate ( shared - > slru_stats_idx ) ;
/*
/*
* The cutoff point is the start of the segment containing cutoffPage .
* The cutoff point is the start of the segment containing cutoffPage .