@@ -156,15 +156,20 @@ SimpleLruShmemSize(int nslots, int nlsns)
156
156
if (nlsns > 0 )
157
157
sz += MAXALIGN (nslots * nlsns * sizeof (XLogRecPtr ));/* group_lsn[] */
158
158
159
+ /* size of lwlocks */
160
+ sz = add_size (sz ,LWLockTrancheShmemSize (nslots ));
161
+
159
162
return BUFFERALIGN (sz )+ BLCKSZ * nslots ;
160
163
}
161
164
162
165
void
163
166
SimpleLruInit (SlruCtl ctl ,const char * name ,int nslots ,int nlsns ,
164
- LWLock * ctllock ,const char * subdir )
167
+ LWLock * ctllock ,const char * subdir ,
168
+ const char * lwlocks_tranche )
165
169
{
166
- SlruShared shared ;
167
- bool found ;
170
+ SlruShared shared ;
171
+ bool found ;
172
+ LWLockPadded * lwlock_array ;
168
173
169
174
shared = (SlruShared )ShmemInitStruct (name ,
170
175
SimpleLruShmemSize (nslots ,nlsns ),
@@ -212,13 +217,18 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
212
217
}
213
218
214
219
ptr += BUFFERALIGN (offset );
220
+
221
+ /* Create tranche and lwlocks required for slots */
222
+ LWLockCreateTranche (lwlocks_tranche ,nslots ,& lwlock_array );
223
+
224
+ /* Initialize slots */
215
225
for (slotno = 0 ;slotno < nslots ;slotno ++ )
216
226
{
217
227
shared -> page_buffer [slotno ]= ptr ;
218
228
shared -> page_status [slotno ]= SLRU_PAGE_EMPTY ;
219
229
shared -> page_dirty [slotno ]= false;
220
230
shared -> page_lru_count [slotno ]= 0 ;
221
- shared -> buffer_locks [slotno ]= LWLockAssign () ;
231
+ shared -> buffer_locks [slotno ]= & lwlock_array [ slotno ]. lock ;
222
232
ptr += BLCKSZ ;
223
233
}
224
234
}