diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/pgstat.h | 1 | ||||
-rw-r--r-- | src/include/storage/buf_internals.h | 7 | ||||
-rw-r--r-- | src/include/storage/bufmgr.h | 65 |
3 files changed, 73 insertions, 0 deletions
diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 75d258d9215..e79b8a34ebc 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -516,6 +516,7 @@ extern PgStat_CheckpointerStats *pgstat_fetch_stat_checkpointer(void); extern bool pgstat_bktype_io_stats_valid(PgStat_BktypeIO *context_ops, BackendType bktype); extern void pgstat_count_io_op(IOObject io_object, IOContext io_context, IOOp io_op); +extern void pgstat_count_io_op_n(IOObject io_object, IOContext io_context, IOOp io_op, uint32 cnt); extern PgStat_IO *pgstat_fetch_stat_io(void); extern const char *pgstat_get_io_context_name(IOContext io_context); extern const char *pgstat_get_io_object_name(IOObject io_object); diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h index 970d0090615..34feaea9945 100644 --- a/src/include/storage/buf_internals.h +++ b/src/include/storage/buf_internals.h @@ -422,6 +422,13 @@ extern PrefetchBufferResult PrefetchLocalBuffer(SMgrRelation smgr, BlockNumber blockNum); extern BufferDesc *LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum, bool *foundPtr); +extern BlockNumber ExtendBufferedRelLocal(ExtendBufferedWhat eb, + ForkNumber fork, + uint32 flags, + uint32 extend_by, + BlockNumber extend_upto, + Buffer *buffers, + uint32 *extended_by); extern void MarkLocalBufferDirty(Buffer buffer); extern void DropRelationLocalBuffers(RelFileLocator rlocator, ForkNumber forkNum, diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 537b89e8774..788aa279ba0 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -60,6 +60,53 @@ typedef struct PrefetchBufferResult bool initiated_io; /* If true, a miss resulting in async I/O */ } PrefetchBufferResult; +/* + * Flags influencing the behaviour of ExtendBufferedRel* + */ +typedef enum ExtendBufferedFlags +{ + /* + * Don't acquire extension lock. This is safe only if the relation isn't + * shared, an access exclusive lock is held or if this is the startup + * process. + */ + EB_SKIP_EXTENSION_LOCK = (1 << 0), + + /* Is this extension part of recovery? */ + EB_PERFORMING_RECOVERY = (1 << 1), + + /* + * Should the fork be created if it does not currently exist? This likely + * only ever makes sense for relation forks. + */ + EB_CREATE_FORK_IF_NEEDED = (1 << 2), + + /* Should the first (possibly only) return buffer be returned locked? */ + EB_LOCK_FIRST = (1 << 3), + + /* Should the smgr size cache be cleared? */ + EB_CLEAR_SIZE_CACHE = (1 << 4), + + /* internal flags follow */ + EB_LOCK_TARGET = (1 << 5), +} ExtendBufferedFlags; + +/* + * To identify the relation - either relation or smgr + relpersistence has to + * be specified. Used via the EB_REL()/EB_SMGR() macros below. This allows us + * to use the same function for both crash recovery and normal operation. + */ +typedef struct ExtendBufferedWhat +{ + Relation rel; + struct SMgrRelationData *smgr; + char relpersistence; +} ExtendBufferedWhat; + +#define EB_REL(p_rel) ((ExtendBufferedWhat){.rel = p_rel}) +#define EB_SMGR(p_smgr, p_relpersistence) ((ExtendBufferedWhat){.smgr = p_smgr, .relpersistence = p_relpersistence}) + + /* forward declared, to avoid having to expose buf_internals.h here */ struct WritebackContext; @@ -138,6 +185,24 @@ extern void CheckBufferIsPinnedOnce(Buffer buffer); extern Buffer ReleaseAndReadBuffer(Buffer buffer, Relation relation, BlockNumber blockNum); +extern Buffer ExtendBufferedRel(ExtendBufferedWhat eb, + ForkNumber forkNum, + BufferAccessStrategy strategy, + uint32 flags); +extern BlockNumber ExtendBufferedRelBy(ExtendBufferedWhat eb, + ForkNumber fork, + BufferAccessStrategy strategy, + uint32 flags, + uint32 extend_by, + Buffer *buffers, + uint32 *extended_by); +extern Buffer ExtendBufferedRelTo(ExtendBufferedWhat eb, + ForkNumber fork, + BufferAccessStrategy strategy, + uint32 flags, + BlockNumber extend_to, + ReadBufferMode mode); + extern void InitBufferPoolAccess(void); extern void AtEOXact_Buffers(bool isCommit); extern void PrintBufferLeakWarning(Buffer buffer); |