mirror of
https://github.com/postgres/postgres.git
synced 2025-11-25 12:03:53 +03:00
Refactor the fsync queue for wider use.
Previously, md.c and checkpointer.c were tightly integrated so that fsync calls could be handed off and processed in the background. Introduce a system of callbacks and file tags, so that other modules can hand off fsync work in the same way. For now only md.c uses the new interface, but other users are being proposed. Since there may be use cases that are not strictly SMGR implementations, use a new function table for sync handlers rather than extending the traditional SMGR one. Instead of using a bitmapset of segment numbers for each RelFileNode in the checkpointer's hash table, make the segment number part of the key. This requires sending explicit "forget" requests for every segment individually when relations are dropped, but suits the file layout schemes of proposed future users better (ie sparse or high segment numbers). Author: Shawn Debnath and Thomas Munro Reviewed-by: Thomas Munro, Andres Freund Discussion: https://postgr.es/m/CAEepm=2gTANm=e3ARnJT=n0h8hf88wqmaZxk0JYkxw+b21fNrw@mail.gmail.com
This commit is contained in:
51
src/include/storage/md.h
Normal file
51
src/include/storage/md.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* md.h
|
||||
* magnetic disk storage manager public interface declarations.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/storage/md.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef MD_H
|
||||
#define MD_H
|
||||
|
||||
#include "storage/block.h"
|
||||
#include "storage/relfilenode.h"
|
||||
#include "storage/smgr.h"
|
||||
#include "storage/sync.h"
|
||||
|
||||
/* md storage manager functionality */
|
||||
extern void mdinit(void);
|
||||
extern void mdclose(SMgrRelation reln, ForkNumber forknum);
|
||||
extern void mdcreate(SMgrRelation reln, ForkNumber forknum, bool isRedo);
|
||||
extern bool mdexists(SMgrRelation reln, ForkNumber forknum);
|
||||
extern void mdunlink(RelFileNodeBackend rnode, ForkNumber forknum, bool isRedo);
|
||||
extern void mdextend(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum, char *buffer, bool skipFsync);
|
||||
extern void mdprefetch(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum);
|
||||
extern void mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
||||
char *buffer);
|
||||
extern void mdwrite(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum, char *buffer, bool skipFsync);
|
||||
extern void mdwriteback(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum, BlockNumber nblocks);
|
||||
extern BlockNumber mdnblocks(SMgrRelation reln, ForkNumber forknum);
|
||||
extern void mdtruncate(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber nblocks);
|
||||
extern void mdimmedsync(SMgrRelation reln, ForkNumber forknum);
|
||||
|
||||
extern void ForgetDatabaseSyncRequests(Oid dbid);
|
||||
extern void DropRelationFiles(RelFileNode *delrels, int ndelrels, bool isRedo);
|
||||
|
||||
/* md sync callbacks */
|
||||
extern int mdsyncfiletag(const FileTag *ftag, char *path);
|
||||
extern int mdunlinkfiletag(const FileTag *ftag, char *path);
|
||||
extern bool mdfiletagmatches(const FileTag *ftag, const FileTag *candidate);
|
||||
|
||||
#endif /* MD_H */
|
||||
Reference in New Issue
Block a user