@@ -145,7 +145,7 @@ static int SlruSelectLRUPage(SlruCtl ctl, int pageno);
145
145
146
146
static bool SlruScanDirCbDeleteCutoff (SlruCtl ctl , char * filename ,
147
147
int segpage , void * data );
148
- static void SlruInternalDeleteSegment (SlruCtl ctl , char * filename );
148
+ static void SlruInternalDeleteSegment (SlruCtl ctl , int segno );
149
149
150
150
/*
151
151
* Initialization of shared memory
@@ -1298,19 +1298,28 @@ restart:;
1298
1298
}
1299
1299
1300
1300
/*
1301
- * Delete an individual SLRU segment, identified by the filename .
1301
+ * Delete an individual SLRU segment.
1302
1302
*
1303
1303
* NB: This does not touch the SLRU buffers themselves, callers have to ensure
1304
1304
* they either can't yet contain anything, or have already been cleaned out.
1305
1305
*/
1306
1306
static void
1307
- SlruInternalDeleteSegment (SlruCtl ctl , char * filename )
1307
+ SlruInternalDeleteSegment (SlruCtl ctl , int segno )
1308
1308
{
1309
1309
char path [MAXPGPATH ];
1310
1310
1311
- snprintf (path , MAXPGPATH , "%s/%s" , ctl -> Dir , filename );
1312
- ereport (DEBUG2 ,
1313
- (errmsg ("removing file \"%s\"" , path )));
1311
+ /* Forget any fsync requests queued for this segment. */
1312
+ if (ctl -> sync_handler != SYNC_HANDLER_NONE )
1313
+ {
1314
+ FileTag tag ;
1315
+
1316
+ INIT_SLRUFILETAG (tag , ctl -> sync_handler , segno );
1317
+ RegisterSyncRequest (& tag , SYNC_FORGET_REQUEST , true);
1318
+ }
1319
+
1320
+ /* Unlink the file. */
1321
+ SlruFileName (ctl , path , segno );
1322
+ ereport (DEBUG2 , (errmsg ("removing file \"%s\"" , path )));
1314
1323
unlink (path );
1315
1324
}
1316
1325
@@ -1322,7 +1331,6 @@ SlruDeleteSegment(SlruCtl ctl, int segno)
1322
1331
{
1323
1332
SlruShared shared = ctl -> shared ;
1324
1333
int slotno ;
1325
- char path [MAXPGPATH ];
1326
1334
bool did_write ;
1327
1335
1328
1336
/* Clean out any possibly existing references to the segment. */
@@ -1364,23 +1372,7 @@ SlruDeleteSegment(SlruCtl ctl, int segno)
1364
1372
if (did_write )
1365
1373
goto restart ;
1366
1374
1367
- snprintf (path , MAXPGPATH , "%s/%04X" , ctl -> Dir , segno );
1368
- ereport (DEBUG2 ,
1369
- (errmsg ("removing file \"%s\"" , path )));
1370
-
1371
- /*
1372
- * Tell the checkpointer to forget any sync requests, before we unlink the
1373
- * file.
1374
- */
1375
- if (ctl -> sync_handler != SYNC_HANDLER_NONE )
1376
- {
1377
- FileTag tag ;
1378
-
1379
- INIT_SLRUFILETAG (tag , ctl -> sync_handler , segno );
1380
- RegisterSyncRequest (& tag , SYNC_FORGET_REQUEST , true);
1381
- }
1382
-
1383
- unlink (path );
1375
+ SlruInternalDeleteSegment (ctl , segno );
1384
1376
1385
1377
LWLockRelease (shared -> ControlLock );
1386
1378
}
@@ -1413,7 +1405,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
1413
1405
int cutoffPage = * (int * ) data ;
1414
1406
1415
1407
if (ctl -> PagePrecedes (segpage , cutoffPage ))
1416
- SlruInternalDeleteSegment (ctl , filename );
1408
+ SlruInternalDeleteSegment (ctl , segpage / SLRU_PAGES_PER_SEGMENT );
1417
1409
1418
1410
return false; /* keep going */
1419
1411
}
@@ -1425,7 +1417,7 @@ SlruScanDirCbDeleteCutoff(SlruCtl ctl, char *filename, int segpage, void *data)
1425
1417
bool
1426
1418
SlruScanDirCbDeleteAll (SlruCtl ctl , char * filename , int segpage , void * data )
1427
1419
{
1428
- SlruInternalDeleteSegment (ctl , filename );
1420
+ SlruInternalDeleteSegment (ctl , segpage / SLRU_PAGES_PER_SEGMENT );
1429
1421
1430
1422
return false; /* keep going */
1431
1423
}
0 commit comments