Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 47d37f5

Browse files
committed
remove unused code, update ptrack.
1 parent 41d0c92 commit 47d37f5

File tree

14 files changed

+268
-274
lines changed

14 files changed

+268
-274
lines changed

src/backend/access/heap/ptrack.c

Lines changed: 256 additions & 153 deletions
Large diffs are not rendered by default.

src/backend/access/transam/xlog.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6763,7 +6763,6 @@ StartupXLOG(void)
67636763
do
67646764
{
67656765
bool switchedTLI = false;
6766-
int nblock;
67676766

67686767
#ifdef WAL_DEBUG
67696768
if (XLOG_DEBUG ||
@@ -6917,17 +6916,6 @@ StartupXLOG(void)
69176916
/* Pop the error context stack */
69186917
error_context_stack = errcallback.previous;
69196918

6920-
if (ptrack_enable)
6921-
for(nblock = 0; nblock < xlogreader->max_block_id; nblock++)
6922-
{
6923-
if(xlogreader->blocks[nblock].forknum == MAIN_FORKNUM)
6924-
{
6925-
ptrack_add_block(xlogreader->blocks[nblock].blkno,
6926-
xlogreader->blocks[nblock].rnode);
6927-
ptrack_save();
6928-
}
6929-
}
6930-
69316919
/*
69326920
* Update lastReplayedEndRecPtr after this record has been
69336921
* successfully replayed.

src/backend/access/transam/xlogfuncs.c

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ pg_stop_backup(PG_FUNCTION_ARGS)
168168
PG_RETURN_LSN(stoppoint);
169169
}
170170

171+
171172
/*
172173
* pg_stop_backup_v2: finish taking exclusive or nonexclusive on-line backup.
173174
*
@@ -275,30 +276,6 @@ pg_stop_backup_v2(PG_FUNCTION_ARGS)
275276
return (Datum) 0;
276277
}
277278

278-
Datum
279-
pg_ptrack_clear(PG_FUNCTION_ARGS)
280-
{
281-
if (!superuser() && !has_rolreplication(GetUserId()))
282-
ereport(ERROR,
283-
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
284-
(errmsg("must be superuser or replication role to clear ptrack files"))));
285-
286-
ptrack_clear();
287-
288-
PG_RETURN_VOID();
289-
}
290-
291-
Datum
292-
pg_ptrack_get_and_clear(PG_FUNCTION_ARGS)
293-
{
294-
if (!superuser() && !has_rolreplication(GetUserId()))
295-
ereport(ERROR,
296-
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
297-
(errmsg("must be superuser or replication role to clear ptrack files"))));
298-
299-
PG_RETURN_BYTEA_P(ptrack_get_and_clear(PG_GETARG_OID(0), PG_GETARG_OID(1)));
300-
}
301-
302279
/*
303280
* pg_switch_xlog: switch to next xlog file
304281
*

src/backend/access/transam/xloginsert.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "access/xlog.h"
2424
#include "access/xlog_internal.h"
2525
#include "access/xloginsert.h"
26-
#include "access/ptrack.h"
2726
#include "catalog/pg_control.h"
2827
#include "common/pg_lzcompress.h"
2928
#include "miscadmin.h"
@@ -257,10 +256,6 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
257256
#endif
258257

259258
regbuf->in_use = true;
260-
if (ptrack_enable && regbuf->forkno == MAIN_FORKNUM)
261-
{
262-
ptrack_add_block(regbuf->block, regbuf->rnode);
263-
}
264259
}
265260

266261
/*

src/backend/storage/buffer/bufmgr.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -783,18 +783,6 @@ ReadBufferWithoutRelcache(RelFileNode rnode, ForkNumber forkNum,
783783
mode, strategy, &hit);
784784
}
785785

786-
Buffer
787-
ReadBufferWithoutRelcache2(SMgrRelation smgr, ForkNumber forkNum,
788-
BlockNumber blockNum, ReadBufferMode mode,
789-
BufferAccessStrategy strategy)
790-
{
791-
bool hit;
792-
793-
return ReadBuffer_common(smgr, RELPERSISTENCE_PERMANENT, RELKIND_UNKNOWN, forkNum, blockNum,
794-
mode, strategy, &hit);
795-
}
796-
797-
798786
/*
799787
* ReadBuffer_common -- common logic for all ReadBuffer variants
800788
*

src/backend/storage/lmgr/lmgr.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -390,30 +390,6 @@ UnlockRelationForExtension(Relation relation, LOCKMODE lockmode)
390390
LockRelease(&tag, lockmode, false);
391391
}
392392

393-
void
394-
LockSmgrForExtension(SMgrRelation smgr, LOCKMODE lockmode)
395-
{
396-
LOCKTAG tag;
397-
398-
SET_LOCKTAG_SMGR(tag, smgr->smgr_rnode.node.relNode);
399-
400-
(void) LockAcquire(&tag, lockmode, false, false);
401-
}
402-
403-
/*
404-
* UnlockRelationForExtension
405-
*/
406-
void
407-
UnlockSmgrForExtension(SMgrRelation smgr, LOCKMODE lockmode)
408-
{
409-
LOCKTAG tag;
410-
411-
SET_LOCKTAG_SMGR(tag ,smgr->smgr_rnode.node.relNode);
412-
413-
LockRelease(&tag, lockmode, false);
414-
}
415-
416-
417393
/*
418394
* LockPage
419395
*
@@ -1064,11 +1040,6 @@ DescribeLockTag(StringInfo buf, const LOCKTAG *tag)
10641040
tag->locktag_field3,
10651041
tag->locktag_field4);
10661042
break;
1067-
case LOCKTAG_SMGR:
1068-
appendStringInfo(buf,
1069-
_("smgr lock %u"),
1070-
tag->locktag_field1);
1071-
break;
10721043
default:
10731044
appendStringInfo(buf,
10741045
_("unrecognized locktag type %d"),

src/include/access/ptrack.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
#include "storage/relfilenode.h"
88
#include "utils/relcache.h"
99

10-
extern PGDLLIMPORT unsigned int blocks_track_count;
10+
/* Number of bits allocated for each heap block. */
11+
#define PTRACK_BITS_PER_HEAPBLOCK 1
1112

1213
extern PGDLLIMPORT bool ptrack_enable;
1314

14-
extern void ptrack_save(void);
15-
16-
extern void ptrack_add_block(BlockNumber block_number, RelFileNode rel);
15+
extern void ptrack_add_block(Relation rel, BlockNumber heapBlk);
16+
extern void ptrack_add_block_redo(RelFileNode rnode, BlockNumber heapBlk);
17+
extern void ptrack_pin(Relation rel, BlockNumber heapBlk, Buffer *buf);
18+
extern void ptrack_set(BlockNumber heapBlk, Buffer ptrackBuf);
1719

1820
extern void ptrack_clear(void);
1921
extern bytea *ptrack_get_and_clear(Oid tablespace_oid, Oid table_oid);

src/include/access/xlog_fn.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
extern Datum pg_start_backup(PG_FUNCTION_ARGS);
1717
extern Datum pg_stop_backup(PG_FUNCTION_ARGS);
1818
extern Datum pg_stop_backup_v2(PG_FUNCTION_ARGS);
19-
extern Datum pg_ptrack_clear(PG_FUNCTION_ARGS);
20-
extern Datum pg_ptrack_get_and_clear(PG_FUNCTION_ARGS);
2119
extern Datum pg_switch_xlog(PG_FUNCTION_ARGS);
2220
extern Datum pg_create_restore_point(PG_FUNCTION_ARGS);
2321
extern Datum pg_current_xlog_location(PG_FUNCTION_ARGS);
@@ -35,6 +33,5 @@ extern Datum pg_is_xlog_replay_paused(PG_FUNCTION_ARGS);
3533
extern Datum pg_xlog_location_diff(PG_FUNCTION_ARGS);
3634
extern Datum pg_is_in_backup(PG_FUNCTION_ARGS);
3735
extern Datum pg_backup_start_time(PG_FUNCTION_ARGS);
38-
extern Datum pg_ptrack_test(PG_FUNCTION_ARGS);
3936

4037
#endif /* XLOG_FN_H */

src/include/common/relpath.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef enum ForkNumber
3939

4040
#define MAX_FORKNUM PAGESTRACK_FORKNUM
4141

42-
#define FORKNAMECHARS 6 /* max chars for a fork name */
42+
#define FORKNAMECHARS 5 /* max chars for a fork name */
4343

4444
extern const char *const forkNames[];
4545

src/include/miscadmin.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#define MISCADMIN_H
2525

2626
#include "pgtime.h" /* for pg_time_t */
27-
#include "access/ptrack.h"
2827

2928

3029
#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
@@ -131,14 +130,6 @@ do { \
131130
#define START_CRIT_SECTION() (CritSectionCount++)
132131

133132
#define END_CRIT_SECTION() \
134-
do { \
135-
Assert(CritSectionCount > 0); \
136-
CritSectionCount--; \
137-
if (!CritSectionCount && ptrack_enable && blocks_track_count > 0) \
138-
ptrack_save(); \
139-
} while(0)
140-
141-
#define END_CRIT_SECTION_WITHOUT_TRACK() \
142133
do { \
143134
Assert(CritSectionCount > 0); \
144135
CritSectionCount--; \

src/include/storage/bufmgr.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "storage/buf.h"
1919
#include "storage/bufpage.h"
2020
#include "storage/relfilenode.h"
21-
#include "storage/smgr.h"
2221
#include "utils/relcache.h"
2322
#include "utils/snapmgr.h"
2423
#include "utils/tqual.h"
@@ -173,10 +172,6 @@ extern Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum,
173172
extern Buffer ReadBufferWithoutRelcache(RelFileNode rnode,
174173
ForkNumber forkNum, BlockNumber blockNum,
175174
ReadBufferMode mode, BufferAccessStrategy strategy);
176-
extern Buffer ReadBufferWithoutRelcache2(SMgrRelation smgr,
177-
ForkNumber forkNum, BlockNumber blockNum,
178-
ReadBufferMode mode, BufferAccessStrategy strategy);
179-
180175
extern void ReleaseBuffer(Buffer buffer);
181176
extern void UnlockReleaseBuffer(Buffer buffer);
182177
extern void MarkBufferDirty(Buffer buffer);

src/include/storage/lmgr.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "lib/stringinfo.h"
1818
#include "storage/itemptr.h"
1919
#include "storage/lock.h"
20-
#include "storage/smgr.h"
2120
#include "utils/rel.h"
2221

2322

@@ -58,9 +57,6 @@ extern bool ConditionalLockRelationForExtension(Relation relation,
5857
LOCKMODE lockmode);
5958
extern int RelationExtensionLockWaiterCount(Relation relation);
6059

61-
extern void LockSmgrForExtension(SMgrRelation smgr, LOCKMODE lockmode);
62-
extern void UnlockSmgrForExtension(SMgrRelation smgr, LOCKMODE lockmode);
63-
6460
/* Lock a page (currently only used within indexes) */
6561
extern void LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);
6662
extern bool ConditionalLockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);

src/include/storage/lock.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ typedef enum LockTagType
161161
* Also, we use DB OID = 0 for shared objects such as tablespaces.
162162
*/
163163
LOCKTAG_USERLOCK, /* reserved for old contrib/userlock code */
164-
LOCKTAG_ADVISORY, /* advisory user locks */
165-
LOCKTAG_SMGR /**/
164+
LOCKTAG_ADVISORY /* advisory user locks */
166165
} LockTagType;
167166

168167
#define LOCKTAG_LAST_TYPE LOCKTAG_ADVISORY
@@ -208,14 +207,6 @@ typedef struct LOCKTAG
208207
(locktag).locktag_type = LOCKTAG_RELATION_EXTEND, \
209208
(locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
210209

211-
#define SET_LOCKTAG_SMGR(locktag,relfilenode) \
212-
((locktag).locktag_field1 = (relfilenode), \
213-
(locktag).locktag_field2 = 0, \
214-
(locktag).locktag_field3 = 0, \
215-
(locktag).locktag_field4 = 0, \
216-
(locktag).locktag_type = LOCKTAG_SMGR, \
217-
(locktag).locktag_lockmethodid = DEFAULT_LOCKMETHOD)
218-
219210
#define SET_LOCKTAG_PAGE(locktag,dboid,reloid,blocknum) \
220211
((locktag).locktag_field1 = (dboid), \
221212
(locktag).locktag_field2 = (reloid), \

src/include/storage/smgr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ typedef struct SMgrRelationData
4646
struct SMgrRelationData **smgr_owner;
4747

4848
/*
49-
* These next three fields are not actually used or manipulated by smgr,
49+
* These next four fields are not actually used or manipulated by smgr,
5050
* except that they are reset to InvalidBlockNumber upon a cache flush
5151
* event (in particular, upon truncation of the relation). Higher levels
5252
* store cached state here so that it will be reset when truncation
53-
* happens. In all three cases, InvalidBlockNumber means "unknown".
53+
* happens. In all four cases, InvalidBlockNumber means "unknown".
5454
*/
5555
BlockNumber smgr_targblock; /* current insertion target block */
5656
BlockNumber smgr_fsm_nblocks; /* last known size of fsm fork */
5757
BlockNumber smgr_vm_nblocks; /* last known size of vm fork */
58-
BlockNumber smgr_ptrack_nblocks; /* last known size of vm fork */
58+
BlockNumber smgr_ptrack_nblocks; /* last known size of ptrack fork */
5959

6060
/*
6161
* It's unnecessary to create a physical file for a local temp

0 commit comments

Comments
 (0)