|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <limits.h>#include <unistd.h>#include <fcntl.h>#include <sys/file.h>#include "access/xlogutils.h"#include "commands/tablespace.h"#include "common/file_utils.h"#include "miscadmin.h"#include "pg_trace.h"#include "pgstat.h"#include "storage/aio.h"#include "storage/bufmgr.h"#include "storage/fd.h"#include "storage/md.h"#include "storage/relfilelocator.h"#include "storage/smgr.h"#include "storage/sync.h"#include "utils/memutils.h"
Go to the source code of this file.
Data Structures | |
| struct | _MdfdVec |
| struct | MdPathStr |
Macros | |
| #define | INIT_MD_FILETAG(a, xx_rlocator, xx_forknum, xx_segno) |
| #define | EXTENSION_FAIL (1 << 0) |
| #define | EXTENSION_RETURN_NULL (1 << 1) |
| #define | EXTENSION_CREATE (1 << 2) |
| #define | EXTENSION_CREATE_RECOVERY (1 << 3) |
| #define | EXTENSION_DONT_OPEN (1 << 5) |
| #define | SEGMENT_CHARS OIDCHARS |
| #define | MD_PATH_STR_MAXLEN |
Typedefs | |
| typedef struct _MdfdVec | MdfdVec |
| typedef struct MdPathStr | MdPathStr |
Variables | |
| static MemoryContext | MdCxt |
| const PgAioHandleCallbacks | aio_md_readv_cb |
| #define INIT_MD_FILETAG | ( | a, | |
| xx_rlocator, | |||
| xx_forknum, | |||
| xx_segno | |||
| ) |
Definition at line 101 of file md.c.
| #define MD_PATH_STR_MAXLEN |
|
static |
Definition at line 1632 of file md.c.
References fb(), MdCxt, MemoryContextAlloc(), pfree(), and repalloc().
Referenced by _mdfd_openseg(), mdclose(), mdcreate(), mdimmedsync(), mdopenfork(), mdregistersync(), and mdtruncate().
|
static |
Definition at line 1743 of file md.c.
References _mdfd_openseg(), _mdfd_segpath(), _mdnblocks(), Assert, elog, ereport, errcode_for_file_access(), errmsg(), ERROR, EXTENSION_CREATE, EXTENSION_CREATE_RECOVERY, EXTENSION_DONT_OPEN, EXTENSION_FAIL, EXTENSION_RETURN_NULL, FATAL, fb(), FILE_POSSIBLY_DELETED, InRecovery, MCXT_ALLOC_ZERO, mdextend(), _MdfdVec::mdfd_segno, mdopenfork(), palloc_aligned(), pfree(), PG_IO_ALIGN_SIZE, and str.
Referenced by mdextend(), mdfd(), mdprefetch(), mdreadv(), mdstartreadv(), mdwriteback(), mdwritev(), and mdzeroextend().
Definition at line 176 of file md.c.
References fb(), IO_DIRECT_DATA, io_direct_flags, PG_BINARY, and PG_O_DIRECT.
Referenced by _mdfd_openseg(), mdcreate(), mdopenfork(), and mdsyncfiletag().
|
static |
Definition at line 1700 of file md.c.
References _fdvec_resize(), _mdfd_open_flags(), _mdfd_segpath(), _mdnblocks(), Assert, fb(), fd(), _MdfdVec::mdfd_segno, _MdfdVec::mdfd_vfd, PathNameOpenFile(), and MdPathStr::str.
Referenced by _mdfd_getseg(), mdimmedsync(), mdnblocks(), and mdregistersync().
|
static |
Definition at line 1680 of file md.c.
References fb(), relpath, sprintf, MdPathStr::str, and RelPathStr::str.
Referenced by _mdfd_getseg(), _mdfd_openseg(), and mdsyncfiletag().
|
static |
Definition at line 1872 of file md.c.
References ereport, errcode_for_file_access(), errmsg(), ERROR, fb(), FilePathName(), FileSize(), len, and _MdfdVec::mdfd_vfd.
Referenced by _mdfd_getseg(), _mdfd_openseg(), mdextend(), mdnblocks(), mdopenfork(), and mdzeroextend().
Definition at line 784 of file md.c.
References Assert, fb(), i, PG_IO_ALIGN_SIZE, PG_O_DIRECT, and TYPEALIGN.
Referenced by mdreadv(), mdstartreadv(), and mdwritev().
Definition at line 353 of file md.c.
References ereport, errcode_for_file_access(), errmsg(), fb(), pg_truncate(), and WARNING.
Referenced by mdunlinkfork().
| void DropRelationFiles | ( | RelFileLocator * | delrels, |
| int | ndelrels, | ||
| bool | isRedo | ||
| ) |
Definition at line 1600 of file md.c.
References fb(), i, INVALID_PROC_NUMBER, MAX_FORKNUM, palloc_array, pfree(), smgrclose(), smgrdounlinkall(), smgropen(), and XLogDropRelation().
Referenced by FinishPreparedTransaction(), xact_redo_abort(), and xact_redo_commit().
Definition at line 1582 of file md.c.
References RelFileLocator::dbOid, INIT_MD_FILETAG, InvalidBlockNumber, InvalidForkNumber, RegisterSyncRequest(), RelFileLocator::relNumber, RelFileLocator::spcOid, and SYNC_FILTER_REQUEST.
Referenced by createdb_failure_callback(), dbase_redo(), and dropdb().
|
static |
Definition at line 1978 of file md.c.
References Assert, PgAioResult::error_data, fb(), PgAioResult::id, LOG_SERVER_ONLY, PgAioTargetData::nblocks, PGAIO_HCB_MD_READV, pgaio_io_get_target_data(), pgaio_result_report(), PGAIO_RS_ERROR, PGAIO_RS_PARTIAL, PgAioResult::result, PgAioTargetData::smgr, and PgAioResult::status.
|
static |
Definition at line 2045 of file md.c.
References PgAioTargetData::blockNum, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errcode_for_file_access(), errmsg(), PgAioResult::error_data, fb(), PgAioTargetData::forkNum, INVALID_PROC_NUMBER, PgAioTargetData::is_temp, MyProcNumber, PgAioTargetData::nblocks, relpathbackend, PgAioResult::result, PgAioTargetData::rlocator, PgAioTargetData::smgr, and RelPathStr::str.
| void mdclose | ( | SMgrRelation | reln, |
| ForkNumber | forknum | ||
| ) |
Definition at line 713 of file md.c.
References _fdvec_resize(), fb(), FileClose(), and _MdfdVec::mdfd_vfd.
Referenced by mdexists().
| void mdcreate | ( | SMgrRelation | reln, |
| ForkNumber | forknum, | ||
| bool | isRedo | ||
| ) |
Definition at line 222 of file md.c.
References _fdvec_resize(), _mdfd_open_flags(), Assert, ereport, errcode_for_file_access(), errmsg(), ERROR, fb(), fd(), mdfd(), PathNameOpenFile(), register_dirty_segment(), relpath, SmgrIsTemp, RelPathStr::str, and TablespaceCreateDbspace().
| bool mdexists | ( | SMgrRelation | reln, |
| ForkNumber | forknum | ||
| ) |
Definition at line 203 of file md.c.
References EXTENSION_RETURN_NULL, fb(), InRecovery, mdclose(), and mdopenfork().
| void mdextend | ( | SMgrRelation | reln, |
| ForkNumber | forknum, | ||
| BlockNumber | blocknum, | ||
| const void * | buffer, | ||
| bool | skipFsync | ||
| ) |
Definition at line 487 of file md.c.
References _mdfd_getseg(), _mdnblocks(), Assert, ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), ERROR, EXTENSION_CREATE, fb(), FilePathName(), FileWrite(), InvalidBlockNumber, _MdfdVec::mdfd_vfd, mdnblocks(), PG_IO_ALIGN_SIZE, PG_O_DIRECT, register_dirty_segment(), relpath, SmgrIsTemp, and TYPEALIGN.
Referenced by _mdfd_getseg().
| int mdfd | ( | SMgrRelation | reln, |
| ForkNumber | forknum, | ||
| BlockNumber | blocknum, | ||
| uint32 * | off | ||
| ) |
Definition at line 1483 of file md.c.
References _mdfd_getseg(), Assert, EXTENSION_FAIL, fb(), FileGetRawDesc(), _MdfdVec::mdfd_vfd, and mdopenfork().
Referenced by mdcreate(), and mdopenfork().
Definition at line 1963 of file md.c.
References RelFileLocator::dbOid, fb(), and FileTag::rlocator.
| void mdimmedsync | ( | SMgrRelation | reln, |
| ForkNumber | forknum | ||
| ) |
Definition at line 1430 of file md.c.
References _fdvec_resize(), _mdfd_openseg(), data_sync_elevel(), ereport, errcode_for_file_access(), errmsg(), ERROR, fb(), FileClose(), FilePathName(), FileSync(), _MdfdVec::mdfd_vfd, and mdnblocks().
Definition at line 190 of file md.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, MdCxt, and TopMemoryContext.
| uint32 mdmaxcombine | ( | SMgrRelation | reln, |
| ForkNumber | forknum, | ||
| BlockNumber | blocknum | ||
| ) |
| BlockNumber mdnblocks | ( | SMgrRelation | reln, |
| ForkNumber | forknum | ||
| ) |
Definition at line 1223 of file md.c.
References _mdfd_openseg(), _mdnblocks(), Assert, elog, EXTENSION_FAIL, FATAL, fb(), and mdopenfork().
Referenced by mdextend(), mdimmedsync(), mdregistersync(), mdwritev(), and mdzeroextend().
| void mdopen | ( | SMgrRelation | reln | ) |
Definition at line 702 of file md.c.
References fb(), and MAX_FORKNUM.
|
static |
Definition at line 664 of file md.c.
References _fdvec_resize(), _mdfd_open_flags(), _mdnblocks(), Assert, ereport, errcode_for_file_access(), errmsg(), ERROR, EXTENSION_RETURN_NULL, fb(), fd(), FILE_POSSIBLY_DELETED, mdfd(), PathNameOpenFile(), relpath, and RelPathStr::str.
Referenced by _mdfd_getseg(), mdexists(), mdfd(), and mdnblocks().
| bool mdprefetch | ( | SMgrRelation | reln, |
| ForkNumber | forknum, | ||
| BlockNumber | blocknum, | ||
| int | nblocks | ||
| ) |
Definition at line 736 of file md.c.
References _mdfd_getseg(), Assert, EXTENSION_FAIL, EXTENSION_RETURN_NULL, fb(), FilePrefetch(), InRecovery, IO_DIRECT_DATA, io_direct_flags, MaxBlockNumber, _MdfdVec::mdfd_vfd, and Min.
| void mdreadv | ( | SMgrRelation | reln, |
| ForkNumber | forknum, | ||
| BlockNumber | blocknum, | ||
| void ** | buffers, | ||
| BlockNumber | nblocks | ||
| ) |
Definition at line 847 of file md.c.
References _mdfd_getseg(), Assert, buffers_to_iovec(), compute_remaining_iovec(), elog, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errcode_for_file_access(), errmsg(), ERROR, EXTENSION_CREATE_RECOVERY, EXTENSION_FAIL, fb(), FilePathName(), FileReadV(), i, InRecovery, lengthof, _MdfdVec::mdfd_vfd, Min, PG_IOV_MAX, and zero_damaged_pages.
| void mdregistersync | ( | SMgrRelation | reln, |
| ForkNumber | forknum | ||
| ) |
Definition at line 1379 of file md.c.
References _fdvec_resize(), _mdfd_openseg(), fb(), FileClose(), _MdfdVec::mdfd_vfd, mdnblocks(), and register_dirty_segment().
| void mdstartreadv | ( | PgAioHandle * | ioh, |
| SMgrRelation | reln, | ||
| ForkNumber | forknum, | ||
| BlockNumber | blocknum, | ||
| void ** | buffers, | ||
| BlockNumber | nblocks | ||
| ) |
Definition at line 985 of file md.c.
References _mdfd_getseg(), Assert, buffers_to_iovec(), elog, ereport, errcode_for_file_access(), errmsg(), ERROR, EXTENSION_CREATE_RECOVERY, EXTENSION_FAIL, fb(), FilePathName(), FileStartReadV(), IO_DIRECT_DATA, io_direct_flags, _MdfdVec::mdfd_vfd, Min, PGAIO_HCB_MD_READV, PGAIO_HF_BUFFERED, pgaio_io_get_iovec(), pgaio_io_register_callbacks(), pgaio_io_set_flag(), and pgaio_io_set_target_smgr().
Definition at line 1893 of file md.c.
References _mdfd_open_flags(), _mdfd_segpath(), fb(), FileClose(), FilePathName(), FileSync(), FileTag::forknum, INVALID_PROC_NUMBER, IOCONTEXT_NORMAL, IOOBJECT_RELATION, IOOP_FSYNC, MAXPGPATH, MD_PATH_STR_MAXLEN, PathNameOpenFile(), pgstat_count_io_op_time(), pgstat_prepare_io_time(), FileTag::rlocator, FileTag::segno, smgropen(), MdPathStr::str, strlcpy(), and track_io_timing.
| void mdtruncate | ( | SMgrRelation | reln, |
| ForkNumber | forknum, | ||
| BlockNumber | curnblk, | ||
| BlockNumber | nblocks | ||
| ) |
Definition at line 1290 of file md.c.
References _fdvec_resize(), Assert, ereport, errcode_for_file_access(), errmsg(), ERROR, fb(), FileClose(), FilePathName(), FileTruncate(), InRecovery, _MdfdVec::mdfd_vfd, register_dirty_segment(), relpath, and SmgrIsTemp.
| void mdunlink | ( | RelFileLocatorBackend | rlocator, |
| ForkNumber | forknum, | ||
| bool | isRedo | ||
| ) |
Definition at line 337 of file md.c.
References fb(), InvalidForkNumber, MAX_FORKNUM, and mdunlinkfork().
Definition at line 1945 of file md.c.
References fb(), MAIN_FORKNUM, MAXPGPATH, relpathperm, FileTag::rlocator, RelPathStr::str, and strlcpy().
|
static |
Definition at line 374 of file md.c.
References do_truncate(), ereport, errcode_for_file_access(), errmsg(), fb(), IsBinaryUpgrade, MAIN_FORKNUM, register_forget_request(), register_unlink_segment(), RelFileLocatorBackendIsTemp, relpath, sprintf, RelPathStr::str, and WARNING.
Referenced by mdunlink().
| void mdwriteback | ( | SMgrRelation | reln, |
| ForkNumber | forknum, | ||
| BlockNumber | blocknum, | ||
| BlockNumber | nblocks | ||
| ) |
Definition at line 1164 of file md.c.
References _mdfd_getseg(), Assert, EXTENSION_DONT_OPEN, fb(), FileWriteback(), IO_DIRECT_DATA, io_direct_flags, and _MdfdVec::mdfd_vfd.
| void mdwritev | ( | SMgrRelation | reln, |
| ForkNumber | forknum, | ||
| BlockNumber | blocknum, | ||
| const void ** | buffers, | ||
| BlockNumber | nblocks, | ||
| bool | skipFsync | ||
| ) |
Definition at line 1059 of file md.c.
References _mdfd_getseg(), Assert, buffers_to_iovec(), compute_remaining_iovec(), elog, ereport, errcode_for_file_access(), errhint(), errmsg(), ERROR, EXTENSION_CREATE_RECOVERY, EXTENSION_FAIL, fb(), FilePathName(), FileWriteV(), lengthof, _MdfdVec::mdfd_vfd, mdnblocks(), Min, PG_IOV_MAX, register_dirty_segment(), and SmgrIsTemp.
| void mdzeroextend | ( | SMgrRelation | reln, |
| ForkNumber | forknum, | ||
| BlockNumber | blocknum, | ||
| int | nblocks, | ||
| bool | skipFsync | ||
| ) |
Definition at line 552 of file md.c.
References _mdfd_getseg(), _mdnblocks(), Assert, ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), ERROR, EXTENSION_CREATE, fb(), FileFallocate(), FilePathName(), FileZero(), InvalidBlockNumber, _MdfdVec::mdfd_vfd, mdnblocks(), register_dirty_segment(), relpath, and SmgrIsTemp.
|
static |
Definition at line 1507 of file md.c.
References Assert, data_sync_elevel(), DEBUG1, ereport, errcode_for_file_access(), errmsg(), errmsg_internal(), ERROR, fb(), FilePathName(), FileSync(), INIT_MD_FILETAG, IOCONTEXT_NORMAL, IOOBJECT_RELATION, IOOP_FSYNC, _MdfdVec::mdfd_segno, _MdfdVec::mdfd_vfd, pgstat_count_io_op_time(), pgstat_prepare_io_time(), RegisterSyncRequest(), SmgrIsTemp, SYNC_REQUEST, and track_io_timing.
Referenced by mdcreate(), mdextend(), mdregistersync(), mdtruncate(), mdwritev(), and mdzeroextend().
|
static |
Definition at line 1568 of file md.c.
References INIT_MD_FILETAG, RelFileLocatorBackend::locator, RegisterSyncRequest(), and SYNC_FORGET_REQUEST.
Referenced by mdunlinkfork().
|
static |
Definition at line 1551 of file md.c.
References Assert, INIT_MD_FILETAG, RelFileLocatorBackend::locator, RegisterSyncRequest(), RelFileLocatorBackendIsTemp, and SYNC_UNLINK_REQUEST.
Referenced by mdunlinkfork().
| StaticAssertDecl | ( | RELSEG_SIZE | , |
| 0 &&RELSEG_SIZE<= | INT_MAX, | ||
| "RELSEG_SIZE must fit in an integer" | |||
| ) |
| const PgAioHandleCallbacks aio_md_readv_cb |
|
static |
Definition at line 97 of file md.c.
Referenced by _fdvec_resize(), and mdinit().