original) (raw)
PostgreSQL Source Code: src/include/storage/fd.h File Reference (#include "[port/pg_iovec.h](pg%5F%5Fiovec%5F8h%5Fsource.html)"
#include <[dirent.h](dirent%5F8h%5Fsource.html)>
#include <fcntl.h>
Go to the source code of this file.
Macros | |
---|---|
#define | IO_DIRECT_DATA 0x01 |
#define | IO_DIRECT_WAL 0x02 |
#define | IO_DIRECT_WAL_INIT 0x04 |
#define | FILE_POSSIBLY_DELETED(err) ((err) == ENOENT) |
#define | PG_O_DIRECT 0 |
Typedefs | |
---|---|
typedef int | File |
Functions | |
---|---|
File | PathNameOpenFile (const char *fileName, int fileFlags) |
File | PathNameOpenFilePerm (const char *fileName, int fileFlags, mode_t fileMode) |
File | OpenTemporaryFile (bool interXact) |
void | FileClose (File file) |
int | FilePrefetch (File file, off_t offset, off_t amount, uint32 wait_event_info) |
ssize_t | FileReadV (File file, const struct iovec *iov, int iovcnt, off_t offset, uint32 wait_event_info) |
ssize_t | FileWriteV (File file, const struct iovec *iov, int iovcnt, off_t offset, uint32 wait_event_info) |
int | FileStartReadV (struct PgAioHandle *ioh, File file, int iovcnt, off_t offset, uint32 wait_event_info) |
int | FileSync (File file, uint32 wait_event_info) |
int | FileZero (File file, off_t offset, off_t amount, uint32 wait_event_info) |
int | FileFallocate (File file, off_t offset, off_t amount, uint32 wait_event_info) |
off_t | FileSize (File file) |
int | FileTruncate (File file, off_t offset, uint32 wait_event_info) |
void | FileWriteback (File file, off_t offset, off_t nbytes, uint32 wait_event_info) |
char * | FilePathName (File file) |
int | FileGetRawDesc (File file) |
int | FileGetRawFlags (File file) |
mode_t | FileGetRawMode (File file) |
File | PathNameCreateTemporaryFile (const char *path, bool error_on_failure) |
File | PathNameOpenTemporaryFile (const char *path, int mode) |
bool | PathNameDeleteTemporaryFile (const char *path, bool error_on_failure) |
void | PathNameCreateTemporaryDir (const char *basedir, const char *directory) |
void | PathNameDeleteTemporaryDir (const char *dirname) |
void | TempTablespacePath (char *path, Oid tablespace) |
FILE * | AllocateFile (const char *name, const char *mode) |
int | FreeFile (FILE *file) |
FILE * | OpenPipeStream (const char *command, const char *mode) |
int | ClosePipeStream (FILE *file) |
DIR * | AllocateDir (const char *dirname) |
struct dirent * | ReadDir (DIR *dir, const char *dirname) |
struct dirent * | ReadDirExtended (DIR *dir, const char *dirname, int elevel) |
int | FreeDir (DIR *dir) |
int | OpenTransientFile (const char *fileName, int fileFlags) |
int | OpenTransientFilePerm (const char *fileName, int fileFlags, mode_t fileMode) |
int | CloseTransientFile (int fd) |
int | BasicOpenFile (const char *fileName, int fileFlags) |
int | BasicOpenFilePerm (const char *fileName, int fileFlags, mode_t fileMode) |
bool | AcquireExternalFD (void) |
void | ReserveExternalFD (void) |
void | ReleaseExternalFD (void) |
int | MakePGDirectory (const char *directoryName) |
void | InitFileAccess (void) |
void | InitTemporaryFileAccess (void) |
void | set_max_safe_fds (void) |
void | closeAllVfds (void) |
void | SetTempTablespaces (Oid *tableSpaces, int numSpaces) |
bool | TempTablespacesAreSet (void) |
int | GetTempTablespaces (Oid *tableSpaces, int numSpaces) |
Oid | GetNextTempTableSpace (void) |
void | AtEOXact_Files (bool isCommit) |
void | AtEOSubXact_Files (bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid) |
void | RemovePgTempFiles (void) |
void | RemovePgTempFilesInDir (const char *tmpdirname, bool missing_ok, bool unlink_all) |
bool | looks_like_temp_rel_name (const char *name) |
int | pg_fsync (int fd) |
int | pg_fsync_no_writethrough (int fd) |
int | pg_fsync_writethrough (int fd) |
int | pg_fdatasync (int fd) |
bool | pg_file_exists (const char *name) |
void | pg_flush_data (int fd, off_t offset, off_t nbytes) |
int | pg_truncate (const char *path, off_t length) |
void | fsync_fname (const char *fname, bool isdir) |
int | fsync_fname_ext (const char *fname, bool isdir, bool ignore_perm, int elevel) |
int | durable_rename (const char *oldfile, const char *newfile, int elevel) |
int | durable_unlink (const char *fname, int elevel) |
void | SyncDataDirectory (void) |
int | data_sync_elevel (int elevel) |
static ssize_t | FileRead (File file, void *buffer, size_t amount, off_t offset, uint32 wait_event_info) |
static ssize_t | FileWrite (File file, const void *buffer, size_t amount, off_t offset, uint32 wait_event_info) |
Variables | |
---|---|
PGDLLIMPORT int | max_files_per_process |
PGDLLIMPORT bool | data_sync_retry |
PGDLLIMPORT int | recovery_init_sync_method |
PGDLLIMPORT int | io_direct_flags |
PGDLLIMPORT int | max_safe_fds |
◆ FILE_POSSIBLY_DELETED
| #define FILE_POSSIBLY_DELETED | ( | | err | ) | ((err) == ENOENT) | | ------------------------------- | - | | ------------------------------------------------------ | - | -------------------------------------------------------------------- |
Definition at line 78 of file fd.h.
◆ IO_DIRECT_DATA
#define IO_DIRECT_DATA 0x01
Definition at line 54 of file fd.h.
◆ IO_DIRECT_WAL
#define IO_DIRECT_WAL 0x02
Definition at line 55 of file fd.h.
◆ IO_DIRECT_WAL_INIT
#define IO_DIRECT_WAL_INIT 0x04
Definition at line 56 of file fd.h.
◆ PG_O_DIRECT
Definition at line 97 of file fd.h.
Definition at line 51 of file fd.h.
◆ AcquireExternalFD()
bool AcquireExternalFD | ( | void | ) |
---|
◆ AllocateDir()
DIR * AllocateDir | ( | const char * | dirname | ) |
---|
Definition at line 2907 of file fd.c.
2908{
2909 DIR *dir;
2910
2911 DO_DB(elog(LOG, "AllocateDir: Allocated %d (%s)",
2913
2914
2917 (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
2918 errmsg("exceeded maxAllocatedDescs (%d) while trying to open directory \"%s\"",
2920
2921
2923
2924TryAgain:
2925 if ((dir = opendir(dirname)) != NULL)
2926 {
2928
2934 }
2935
2936 if (errno == EMFILE || errno == ENFILE)
2937 {
2938 int save_errno = errno;
2939
2941 (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
2942 errmsg("out of file descriptors: %m; release and retry")));
2943 errno = 0;
2945 goto TryAgain;
2946 errno = save_errno;
2947 }
2948
2949 return NULL;
2950}
DIR * opendir(const char *)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
static bool ReleaseLruFile(void)
static int maxAllocatedDescs
static int numAllocatedDescs
static AllocateDesc * allocatedDescs
static bool reserveAllocatedDesc(void)
static void ReleaseLruFiles(void)
SubTransactionId create_subid
union AllocateDesc::@20 desc
SubTransactionId GetCurrentSubTransactionId(void)
References allocatedDescs, AllocateDescDir, AllocateDesc::create_subid, AllocateDesc::desc, AllocateDesc::dir, DO_DB, elog, ereport, errcode(), errmsg(), ERROR, GetCurrentSubTransactionId(), AllocateDesc::kind, LOG, maxAllocatedDescs, numAllocatedDescs, opendir(), ReleaseLruFile(), ReleaseLruFiles(), and reserveAllocatedDesc().
Referenced by calculate_database_size(), calculate_tablespace_size(), CheckPointLogicalRewriteHeap(), CheckPointSnapBuild(), CheckTablespaceDirectory(), CleanupBackupHistory(), copydir(), db_dir_size(), DeleteAllExportedSnapshotFiles(), destroy_tablespace_directories(), directory_is_empty(), do_pg_backup_start(), dsm_cleanup_for_mmap(), extension_file_exists(), get_ext_ver_list(), GetConfFilesInDir(), getInstallationPaths(), GetWalSummaries(), movedb(), ParseTzFile(), perform_base_backup(), pg_available_extension_versions(), pg_available_extensions(), pg_ls_dir(), pg_ls_dir_files(), pg_tablespace_databases(), pg_tzenumerate_next(), pg_tzenumerate_start(), pgarch_readyXlog(), RelationCacheInitFileRemove(), RelationCacheInitFileRemoveInDir(), RemoveNonParentXlogFiles(), RemoveOldXlogFiles(), RemovePgTempFiles(), RemovePgTempFilesInDir(), RemovePgTempRelationFiles(), RemovePgTempRelationFilesInDbspace(), RemoveTempXlogFiles(), ReorderBufferCleanupSerializedTXNs(), ResetUnloggedRelations(), ResetUnloggedRelationsInDbspaceDir(), ResetUnloggedRelationsInTablespaceDir(), restoreTwoPhaseData(), scan_directory_ci(), sendDir(), SlruScanDirectory(), StartupReorderBuffer(), StartupReplicationSlots(), SyncDataDirectory(), UpdateLogicalMappings(), walkdir(), and XLogGetOldestSegno().
◆ AllocateFile()
FILE * AllocateFile | ( | const char * | name, |
---|---|---|---|
const char * | mode | ||
) |
Definition at line 2644 of file fd.c.
2645{
2646 FILE *file;
2647
2648 DO_DB(elog(LOG, "AllocateFile: Allocated %d (%s)",
2650
2651
2654 (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
2655 errmsg("exceeded maxAllocatedDescs (%d) while trying to open file \"%s\"",
2657
2658
2660
2661TryAgain:
2662 if ((file = fopen(name, mode)) != NULL)
2663 {
2665
2671 }
2672
2673 if (errno == EMFILE || errno == ENFILE)
2674 {
2675 int save_errno = errno;
2676
2678 (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
2679 errmsg("out of file descriptors: %m; release and retry")));
2680 errno = 0;
2682 goto TryAgain;
2683 errno = save_errno;
2684 }
2685
2686 return NULL;
2687}
static PgChecksumMode mode
References allocatedDescs, AllocateDescFile, AllocateDesc::create_subid, AllocateDesc::desc, DO_DB, elog, ereport, errcode(), errmsg(), ERROR, AllocateDesc::file, GetCurrentSubTransactionId(), AllocateDesc::kind, LOG, maxAllocatedDescs, mode, name, numAllocatedDescs, ReleaseLruFile(), ReleaseLruFiles(), and reserveAllocatedDesc().
Referenced by AlterSystemSetConfigFile(), apw_dump_now(), apw_load_buffers(), BeginCopyFrom(), BeginCopyTo(), checkControlFile(), do_pg_backup_stop(), entry_reset(), existsTimeLineHistory(), ExportSnapshot(), gc_qtexts(), GetHugePageSize(), ImportSnapshot(), load_dh_file(), load_relcache_init_file(), open_auth_file(), parse_extension_control_file(), ParseConfigFile(), ParseTzFile(), pg_current_logfile(), pg_promote(), pgss_shmem_shutdown(), pgss_shmem_startup(), pgstat_read_statsfile(), pgstat_write_statsfile(), read_backup_label(), read_binary_file(), read_tablespace_map(), read_whole_file(), readTimeLineHistory(), tsearch_readline_begin(), ValidatePgVersion(), write_relcache_init_file(), XLogArchiveForceDone(), and XLogArchiveNotify().
◆ AtEOSubXact_Files()
◆ AtEOXact_Files()
void AtEOXact_Files | ( | bool | isCommit | ) |
---|
Definition at line 3229 of file fd.c.
3230{
3234}
static int numTempTableSpaces
static Oid * tempTableSpaces
static void CleanupTempFiles(bool isCommit, bool isProcExit)
References CleanupTempFiles(), numTempTableSpaces, and tempTableSpaces.
Referenced by AbortTransaction(), AutoVacLauncherMain(), BackgroundWriterMain(), CheckpointerMain(), CommitTransaction(), pgarch_archiveXlog(), PrepareTransaction(), WalSummarizerMain(), and WalWriterMain().
◆ BasicOpenFile()
int BasicOpenFile | ( | const char * | fileName, |
---|---|---|---|
int | fileFlags | ||
) |
Definition at line 1089 of file fd.c.
1090{
1092}
int BasicOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
References BasicOpenFilePerm(), and pg_file_create_mode.
Referenced by AlterSystemSetConfigFile(), ReadControlFile(), update_controlfile(), wal_segment_open(), WalSndSegmentOpen(), WriteControlFile(), XLogFileInit(), XLogFileInitInternal(), XLogFileOpen(), and XLogFileRead().
◆ BasicOpenFilePerm()
int BasicOpenFilePerm | ( | const char * | fileName, |
---|---|---|---|
int | fileFlags, | ||
mode_t | fileMode | ||
) |
Definition at line 1111 of file fd.c.
1112{
1113 int fd;
1114
1115tryAgain:
1116#ifdef PG_O_DIRECT_USE_F_NOCACHE
1117
1118
1119
1120
1121
1123 (O_APPEND |
1125 O_CREAT |
1127 O_EXCL |
1128 O_RDWR |
1129 O_RDONLY |
1130 O_SYNC |
1131 O_TRUNC |
1132 O_WRONLY)) == 0,
1133 "PG_O_DIRECT value collides with standard flag");
1134 fd = open(fileName, fileFlags & ~PG_O_DIRECT, fileMode);
1135#else
1136 fd = open(fileName, fileFlags, fileMode);
1137#endif
1138
1139 if (fd >= 0)
1140 {
1141#ifdef PG_O_DIRECT_USE_F_NOCACHE
1143 {
1144 if (fcntl(fd, F_NOCACHE, 1) < 0)
1145 {
1146 int save_errno = errno;
1147
1149 errno = save_errno;
1150 return -1;
1151 }
1152 }
1153#endif
1154
1155 return fd;
1156 }
1157
1158 if (errno == EMFILE || errno == ENFILE)
1159 {
1160 int save_errno = errno;
1161
1163 (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
1164 errmsg("out of file descriptors: %m; release and retry")));
1165 errno = 0;
1167 goto tryAgain;
1168 errno = save_errno;
1169 }
1170
1171 return -1;
1172}
#define StaticAssertStmt(condition, errmessage)
static int fd(const char *x, int i)
References close, ereport, errcode(), errmsg(), fd(), LOG, O_CLOEXEC, O_DSYNC, PG_O_DIRECT, ReleaseLruFile(), and StaticAssertStmt.
Referenced by BasicOpenFile(), LruInsert(), OpenTransientFilePerm(), PathNameOpenFilePerm(), and readRecoverySignalFile().
◆ closeAllVfds()
void closeAllVfds | ( | void | ) |
---|
◆ ClosePipeStream()
int ClosePipeStream | ( | FILE * | file | ) |
---|
Definition at line 3055 of file fd.c.
3056{
3057 int i;
3058
3060
3061
3063 {
3065
3068 }
3069
3070
3071 elog(WARNING, "file passed to ClosePipeStream was not obtained from OpenPipeStream");
3072
3073 return pclose(file);
3074}
References allocatedDescs, AllocateDescPipe, AllocateDesc::desc, DO_DB, elog, AllocateDesc::file, FreeDesc(), i, AllocateDesc::kind, LOG, numAllocatedDescs, and WARNING.
Referenced by ClosePipeFromProgram(), ClosePipeToProgram(), pg_import_system_collations(), run_ssl_passphrase_command(), and shell_finish_command().
◆ CloseTransientFile()
int CloseTransientFile | ( | int | fd | ) |
---|
Definition at line 2871 of file fd.c.
2872{
2873 int i;
2874
2876
2877
2879 {
2881
2884 }
2885
2886
2887 elog(WARNING, "fd passed to CloseTransientFile was not obtained from OpenTransientFile");
2888
2890
2892}
void pgaio_closing_fd(int fd)
References allocatedDescs, AllocateDescRawFD, close, AllocateDesc::desc, DO_DB, elog, AllocateDesc::fd, fd(), FreeDesc(), i, AllocateDesc::kind, LOG, numAllocatedDescs, pgaio_closing_fd(), and WARNING.
Referenced by ApplyLogicalMappingFile(), be_lo_export(), CheckPointLogicalRewriteHeap(), CheckPointReplicationOrigin(), clone_file(), compare_files(), copy_file(), CreateDirAndVersionFile(), dsm_impl_mmap(), durable_rename(), fsync_fname_ext(), get_controlfile_by_exact_path(), heap_xlog_logical_rewrite(), lo_import_internal(), perform_base_backup(), pg_truncate(), qtext_load_file(), qtext_store(), read_relmap_file(), ReadTwoPhaseFile(), RecreateTwoPhaseFile(), ReorderBufferSerializeChange(), ReorderBufferSerializeTXN(), RestoreSlotFromDisk(), SaveSlotToPath(), sendFile(), SendTimeLineHistory(), SimpleLruDoesPhysicalPageExist(), SimpleLruWriteAll(), SlruInternalWritePage(), SlruPhysicalReadPage(), SlruPhysicalWritePage(), SlruSyncFileTag(), SnapBuildRestoreContents(), SnapBuildRestoreSnapshot(), SnapBuildSerialize(), StartupReplicationOrigin(), write_relmap_file(), writeTimeLineHistory(), writeTimeLineHistoryFile(), and XLogFileCopy().
◆ data_sync_elevel()
int data_sync_elevel | ( | int | elevel | ) |
---|
Definition at line 4001 of file fd.c.
References data_sync_retry, and PANIC.
Referenced by CheckPointLogicalRewriteHeap(), CreateDirAndVersionFile(), FileClose(), fsync_fname(), heap_xlog_logical_rewrite(), logical_end_heap_rewrite(), LruDelete(), mdimmedsync(), pg_flush_data(), ProcessSyncRequests(), register_dirty_segment(), SlruReportIOError(), writeTimeLineHistory(), writeTimeLineHistoryFile(), and XLogFileCopy().
◆ durable_rename()
int durable_rename | ( | const char * | oldfile, |
---|---|---|---|
const char * | newfile, | ||
int | elevel | ||
) |
Definition at line 782 of file fd.c.
783{
784 int fd;
785
786
787
788
789
790
791
792
794 return -1;
795
797 if (fd < 0)
798 {
799 if (errno != ENOENT)
800 {
803 errmsg("could not open file \"%s\": %m", newfile)));
804 return -1;
805 }
806 }
807 else
808 {
810 {
811 int save_errno;
812
813
814 save_errno = errno;
816 errno = save_errno;
817
820 errmsg("could not fsync file \"%s\": %m", newfile)));
821 return -1;
822 }
823
825 {
828 errmsg("could not close file \"%s\": %m", newfile)));
829 return -1;
830 }
831 }
832
833
834 if (rename(oldfile, newfile) < 0)
835 {
838 errmsg("could not rename file \"%s\" to \"%s\": %m",
839 oldfile, newfile)));
840 return -1;
841 }
842
843
844
845
846
848 return -1;
849
851 return -1;
852
853 return 0;
854}
int errcode_for_file_access(void)
int CloseTransientFile(int fd)
int fsync_fname_ext(const char *fname, bool isdir, bool ignore_perm, int elevel)
static int fsync_parent_path(const char *fname, int elevel)
int OpenTransientFile(const char *fileName, int fileFlags)
References CloseTransientFile(), ereport, errcode_for_file_access(), errmsg(), fd(), fsync_fname_ext(), fsync_parent_path(), OpenTransientFile(), PG_BINARY, and pg_fsync().
Referenced by AlterSystemSetConfigFile(), apw_dump_now(), BaseBackup(), basic_archive_file(), bbsink_server_end_manifest(), CheckPointReplicationOrigin(), CleanupAfterArchiveRecovery(), dir_close(), InitWalRecovery(), InstallXLogFileSegment(), KeepFileRestoredFromArchive(), pgss_shmem_shutdown(), pgstat_write_statsfile(), StartupXLOG(), SummarizeWAL(), write_relmap_file(), writeTimeLineHistory(), writeTimeLineHistoryFile(), and XLogArchiveForceDone().
◆ durable_unlink()
int durable_unlink | ( | const char * | fname, |
---|---|---|---|
int | elevel | ||
) |
◆ FileClose()
void FileClose | ( | File | file | ) |
---|
Definition at line 1982 of file fd.c.
1983{
1984 Vfd *vfdP;
1985
1987
1989 file, VfdCache[file].fileName));
1990
1992
1994 {
1996
1997
1998 if (close(vfdP->fd) != 0)
1999 {
2000
2001
2002
2003
2005 "could not close file \"%s\": %m", vfdP->fileName);
2006 }
2007
2010
2011
2013 }
2014
2016 {
2017
2020 }
2021
2022
2023
2024
2026 {
2027 struct stat filestats;
2028 int stat_errno;
2029
2030
2031
2032
2033
2034
2035
2036
2037 vfdP->fdstate &= ~FD_DELETE_AT_CLOSE;
2038
2039
2040
2042 stat_errno = errno;
2043 else
2044 stat_errno = 0;
2045
2046
2050 errmsg("could not delete file \"%s\": %m", vfdP->fileName)));
2051
2052
2053 if (stat_errno == 0)
2055 else
2056 {
2057 errno = stat_errno;
2060 errmsg("could not stat file \"%s\": %m", vfdP->fileName)));
2061 }
2062 }
2063
2064
2067
2068
2069
2070
2072}
#define FD_DELETE_AT_CLOSE
static void Delete(File file)
static void ResourceOwnerForgetFile(ResourceOwner owner, File file)
#define FileIsValid(file)
static void FreeVfd(File file)
#define FD_TEMP_FILE_LIMIT
int data_sync_elevel(int elevel)
static void ReportTemporaryFileUsage(const char *path, off_t size)
static uint64 temporary_files_size
References Assert(), close, data_sync_elevel(), Delete(), DO_DB, elog, ereport, errcode_for_file_access(), errmsg(), vfd::fd, FD_DELETE_AT_CLOSE, FD_TEMP_FILE_LIMIT, vfd::fdstate, FileIsNotOpen, FileIsValid, vfd::fileName, vfd::fileSize, FreeVfd(), LOG, nfile, pgaio_closing_fd(), ReportTemporaryFileUsage(), ResourceOwnerForgetFile(), vfd::resowner, stat::st_size, stat, temporary_files_size, VFD_CLOSED, and VfdCache.
Referenced by bbsink_server_end_archive(), bbsink_server_end_manifest(), BufFileClose(), BufFileTruncateFileSet(), CleanupTempFiles(), logical_end_heap_rewrite(), mdclose(), mdimmedsync(), mdregistersync(), mdsyncfiletag(), mdtruncate(), pg_wal_summary_contents(), PrepareForIncrementalBackup(), ReorderBufferIterTXNFinish(), ReorderBufferRestoreChanges(), ResOwnerReleaseFile(), and SummarizeWAL().
◆ FileFallocate()
int FileFallocate | ( | File | file, |
---|---|---|---|
off_t | offset, | ||
off_t | amount, | ||
uint32 | wait_event_info | ||
) |
Definition at line 2424 of file fd.c.
2425{
2426#ifdef HAVE_POSIX_FALLOCATE
2427 int returnCode;
2428
2430
2432 file, VfdCache[file].fileName,
2434
2436 if (returnCode < 0)
2437 return -1;
2438
2439retry:
2441 returnCode = posix_fallocate(VfdCache[file].fd, offset, amount);
2443
2444 if (returnCode == 0)
2445 return 0;
2446 else if (returnCode == EINTR)
2447 goto retry;
2448
2449
2450 errno = returnCode;
2451
2452
2453
2454
2455
2456 if (returnCode != EINVAL && returnCode != EOPNOTSUPP)
2457 return -1;
2458#endif
2459
2460 return FileZero(file, offset, amount, wait_event_info);
2461}
static int FileAccess(File file)
int FileZero(File file, off_t offset, off_t amount, uint32 wait_event_info)
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)
References Assert(), DO_DB, EINTR, elog, EOPNOTSUPP, fd(), FileAccess(), FileIsValid, FileZero(), INT64_FORMAT, LOG, pgstat_report_wait_end(), pgstat_report_wait_start(), and VfdCache.
Referenced by mdzeroextend().
◆ FileGetRawDesc()
int FileGetRawDesc | ( | File | file | ) |
---|
◆ FileGetRawFlags()
int FileGetRawFlags | ( | File | file | ) |
---|
◆ FileGetRawMode()
mode_t FileGetRawMode | ( | File | file | ) |
---|
◆ FilePathName()
char * FilePathName | ( | File | file | ) |
---|
Definition at line 2516 of file fd.c.
References Assert(), FileIsValid, vfd::fileName, and VfdCache.
Referenced by _mdnblocks(), bbsink_server_archive_contents(), bbsink_server_end_archive(), bbsink_server_manifest_contents(), BufFileDumpBuffer(), BufFileLoadBuffer(), BufFileSeek(), BufFileSize(), BufFileTruncateFileSet(), mdextend(), mdimmedsync(), mdreadv(), mdstartreadv(), mdsyncfiletag(), mdtruncate(), mdwritev(), mdzeroextend(), pg_wal_summary_contents(), PrepareForIncrementalBackup(), ReadWalSummary(), register_dirty_segment(), and WriteWalSummary().
◆ FilePrefetch()
int FilePrefetch | ( | File | file, |
---|---|---|---|
off_t | offset, | ||
off_t | amount, | ||
uint32 | wait_event_info | ||
) |
Definition at line 2083 of file fd.c.
2084{
2086
2088 file, VfdCache[file].fileName,
2090
2091#if defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED)
2092 {
2093 int returnCode;
2094
2096 if (returnCode < 0)
2097 return returnCode;
2098
2099retry:
2101 returnCode = posix_fadvise(VfdCache[file].fd, offset, amount,
2102 POSIX_FADV_WILLNEED);
2104
2105 if (returnCode == EINTR)
2106 goto retry;
2107
2108 return returnCode;
2109 }
2110#elif defined(__darwin__)
2111 {
2112 struct radvisory
2113 {
2114 off_t ra_offset;
2115 int ra_count;
2116 } ra;
2117 int returnCode;
2118
2120 if (returnCode < 0)
2121 return returnCode;
2122
2123 ra.ra_offset = offset;
2124 ra.ra_count = amount;
2126 returnCode = fcntl(VfdCache[file].fd, F_RDADVISE, &ra);
2128 if (returnCode != -1)
2129 return 0;
2130 else
2131 return errno;
2132 }
2133#else
2134 return 0;
2135#endif
2136}
References Assert(), DO_DB, EINTR, elog, fd(), FileAccess(), FileIsValid, INT64_FORMAT, LOG, pgstat_report_wait_end(), pgstat_report_wait_start(), and VfdCache.
Referenced by mdprefetch().
◆ FileRead()
static ssize_t FileRead ( File file, void * buffer, size_t amount, off_t offset, uint32 wait_event_info ) | inlinestatic |
---|
Definition at line 199 of file fd.h.
201{
202 struct iovec iov = {
203 .iov_base = buffer,
204 .iov_len = amount
205 };
206
207 return FileReadV(file, &iov, 1, offset, wait_event_info);
208}
ssize_t FileReadV(File file, const struct iovec *iov, int iovcnt, off_t offset, uint32 wait_event_info)
References FileReadV().
Referenced by BufFileLoadBuffer(), ReadWalSummary(), and ReorderBufferRestoreChanges().
◆ FileReadV()
ssize_t FileReadV | ( | File | file, |
---|---|---|---|
const struct iovec * | iov, | ||
int | iovcnt, | ||
off_t | offset, | ||
uint32 | wait_event_info | ||
) |
Definition at line 2165 of file fd.c.
2167{
2168 ssize_t returnCode;
2169 Vfd *vfdP;
2170
2172
2174 file, VfdCache[file].fileName,
2176 iovcnt));
2177
2179 if (returnCode < 0)
2180 return returnCode;
2181
2183
2184retry:
2186 returnCode = pg_preadv(vfdP->fd, iov, iovcnt, offset);
2188
2189 if (returnCode < 0)
2190 {
2191
2192
2193
2194
2195
2196
2197
2198#ifdef WIN32
2199 DWORD error = GetLastError();
2200
2202 {
2203 case ERROR_NO_SYSTEM_RESOURCES:
2206 break;
2207 default:
2209 break;
2210 }
2211#endif
2212
2213 if (errno == EINTR)
2214 goto retry;
2215 }
2216
2217 return returnCode;
2218}
static ssize_t pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
void pg_usleep(long microsec)
void _dosmaperr(unsigned long)
References _dosmaperr(), Assert(), DO_DB, EINTR, elog, error(), vfd::fd, FileAccess(), FileIsValid, INT64_FORMAT, LOG, pg_preadv(), pg_usleep(), pgstat_report_wait_end(), pgstat_report_wait_start(), and VfdCache.
Referenced by FileRead(), and mdreadv().
◆ FileSize()
off_t FileSize | ( | File | file | ) |
---|
Definition at line 2464 of file fd.c.
2465{
2467
2469 file, VfdCache[file].fileName));
2470
2472 {
2474 return (off_t) -1;
2475 }
2476
2477 return lseek(VfdCache[file].fd, 0, SEEK_END);
2478}
References Assert(), DO_DB, elog, fd(), FileAccess(), FileIsNotOpen, FileIsValid, LOG, and VfdCache.
Referenced by _mdnblocks(), BufFileSeek(), and BufFileSize().
◆ FileStartReadV()
int FileStartReadV | ( | struct PgAioHandle * | ioh, |
---|---|---|---|
File | file, | ||
int | iovcnt, | ||
off_t | offset, | ||
uint32 | wait_event_info | ||
) |
Definition at line 2221 of file fd.c.
2224{
2225 int returnCode;
2226 Vfd *vfdP;
2227
2229
2231 file, VfdCache[file].fileName,
2233 iovcnt));
2234
2236 if (returnCode < 0)
2237 return returnCode;
2238
2240
2242
2243 return 0;
2244}
void pgaio_io_start_readv(PgAioHandle *ioh, int fd, int iovcnt, uint64 offset)
References Assert(), DO_DB, elog, vfd::fd, FileAccess(), FileIsValid, INT64_FORMAT, LOG, pgaio_io_start_readv(), and VfdCache.
Referenced by mdstartreadv().
◆ FileSync()
int FileSync | ( | File | file, |
---|---|---|---|
uint32 | wait_event_info | ||
) |
Definition at line 2352 of file fd.c.
2353{
2354 int returnCode;
2355
2357
2359 file, VfdCache[file].fileName));
2360
2362 if (returnCode < 0)
2363 return returnCode;
2364
2368
2369 return returnCode;
2370}
References Assert(), DO_DB, elog, fd(), FileAccess(), FileIsValid, LOG, pg_fsync(), pgstat_report_wait_end(), pgstat_report_wait_start(), and VfdCache.
Referenced by bbsink_server_end_archive(), logical_end_heap_rewrite(), mdimmedsync(), mdsyncfiletag(), and register_dirty_segment().
◆ FileTruncate()
int FileTruncate | ( | File | file, |
---|---|---|---|
off_t | offset, | ||
uint32 | wait_event_info | ||
) |
Definition at line 2481 of file fd.c.
2482{
2483 int returnCode;
2484
2486
2488 file, VfdCache[file].fileName));
2489
2491 if (returnCode < 0)
2492 return returnCode;
2493
2497
2498 if (returnCode == 0 && VfdCache[file].fileSize > offset)
2499 {
2500
2504 }
2505
2506 return returnCode;
2507}
static int pg_ftruncate(int fd, off_t length)
References Assert(), DO_DB, elog, fd(), FD_TEMP_FILE_LIMIT, FileAccess(), FileIsValid, vfd::fileSize, LOG, pg_ftruncate(), pgstat_report_wait_end(), pgstat_report_wait_start(), temporary_files_size, and VfdCache.
Referenced by BufFileTruncateFileSet(), and mdtruncate().
◆ FileWrite()
static ssize_t FileWrite ( File file, const void * buffer, size_t amount, off_t offset, uint32 wait_event_info ) | inlinestatic |
---|
Definition at line 211 of file fd.h.
213{
214 struct iovec iov = {
215 .iov_base = unconstify(void *, buffer),
216 .iov_len = amount
217 };
218
219 return FileWriteV(file, &iov, 1, offset, wait_event_info);
220}
#define unconstify(underlying_type, expr)
ssize_t FileWriteV(File file, const struct iovec *iov, int iovcnt, off_t offset, uint32 wait_event_info)
References FileWriteV(), and unconstify.
Referenced by bbsink_server_archive_contents(), bbsink_server_manifest_contents(), BufFileDumpBuffer(), logical_heap_rewrite_flush_mappings(), mdextend(), and WriteWalSummary().
◆ FileWriteback()
void FileWriteback | ( | File | file, |
---|---|---|---|
off_t | offset, | ||
off_t | nbytes, | ||
uint32 | wait_event_info | ||
) |
Definition at line 2139 of file fd.c.
2140{
2141 int returnCode;
2142
2144
2146 file, VfdCache[file].fileName,
2148
2149 if (nbytes <= 0)
2150 return;
2151
2153 return;
2154
2156 if (returnCode < 0)
2157 return;
2158
2162}
void pg_flush_data(int fd, off_t offset, off_t nbytes)
References Assert(), DO_DB, elog, fd(), FileAccess(), FileIsValid, INT64_FORMAT, LOG, pg_flush_data(), PG_O_DIRECT, pgstat_report_wait_end(), pgstat_report_wait_start(), and VfdCache.
Referenced by mdwriteback().
◆ FileWriteV()
ssize_t FileWriteV | ( | File | file, |
---|---|---|---|
const struct iovec * | iov, | ||
int | iovcnt, | ||
off_t | offset, | ||
uint32 | wait_event_info | ||
) |
Definition at line 2247 of file fd.c.
2249{
2250 ssize_t returnCode;
2251 Vfd *vfdP;
2252
2254
2256 file, VfdCache[file].fileName,
2258 iovcnt));
2259
2261 if (returnCode < 0)
2262 return returnCode;
2263
2265
2266
2267
2268
2269
2270
2271
2272
2273
2275 {
2276 off_t past_write = offset;
2277
2278 for (int i = 0; i < iovcnt; ++i)
2279 past_write += iov[i].iov_len;
2280
2281 if (past_write > vfdP->fileSize)
2282 {
2284
2285 newTotal += past_write - vfdP->fileSize;
2288 (errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
2289 errmsg("temporary file size exceeds \"temp_file_limit\" (%dkB)",
2291 }
2292 }
2293
2294retry:
2296 returnCode = pg_pwritev(vfdP->fd, iov, iovcnt, offset);
2298
2299 if (returnCode >= 0)
2300 {
2301
2302
2303
2304
2305
2306
2307
2308 errno = ENOSPC;
2309
2310
2311
2312
2314 {
2315 off_t past_write = offset + returnCode;
2316
2317 if (past_write > vfdP->fileSize)
2318 {
2320 vfdP->fileSize = past_write;
2321 }
2322 }
2323 }
2324 else
2325 {
2326
2327
2328
2329#ifdef WIN32
2330 DWORD error = GetLastError();
2331
2333 {
2334 case ERROR_NO_SYSTEM_RESOURCES:
2337 break;
2338 default:
2340 break;
2341 }
2342#endif
2343
2344 if (errno == EINTR)
2345 goto retry;
2346 }
2347
2348 return returnCode;
2349}
static ssize_t pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
References _dosmaperr(), Assert(), DO_DB, EINTR, elog, ereport, errcode(), errmsg(), ERROR, error(), vfd::fd, FD_TEMP_FILE_LIMIT, vfd::fdstate, FileAccess(), FileIsValid, vfd::fileSize, i, INT64_FORMAT, LOG, pg_pwritev(), pg_usleep(), pgstat_report_wait_end(), pgstat_report_wait_start(), temp_file_limit, temporary_files_size, and VfdCache.
Referenced by FileWrite(), and mdwritev().
◆ FileZero()
int FileZero | ( | File | file, |
---|---|---|---|
off_t | offset, | ||
off_t | amount, | ||
uint32 | wait_event_info | ||
) |
Definition at line 2379 of file fd.c.
2380{
2381 int returnCode;
2382 ssize_t written;
2383
2385
2387 file, VfdCache[file].fileName,
2389
2391 if (returnCode < 0)
2392 return returnCode;
2393
2397
2398 if (written < 0)
2399 return -1;
2400 else if (written != amount)
2401 {
2402
2403 if (errno == 0)
2404 errno = ENOSPC;
2405 return -1;
2406 }
2407
2408 return 0;
2409}
ssize_t pg_pwrite_zeros(int fd, size_t size, off_t offset)
References Assert(), DO_DB, elog, fd(), FileAccess(), FileIsValid, INT64_FORMAT, LOG, pg_pwrite_zeros(), pgstat_report_wait_end(), pgstat_report_wait_start(), and VfdCache.
Referenced by FileFallocate(), and mdzeroextend().
◆ FreeDir()
Definition at line 3025 of file fd.c.
3026{
3027 int i;
3028
3029
3030 if (dir == NULL)
3031 return 0;
3032
3034
3035
3037 {
3039
3042 }
3043
3044
3045 elog(WARNING, "dir passed to FreeDir was not obtained from AllocateDir");
3046
3048}
References allocatedDescs, AllocateDescDir, closedir(), AllocateDesc::desc, AllocateDesc::dir, DO_DB, elog, FreeDesc(), i, AllocateDesc::kind, LOG, numAllocatedDescs, and WARNING.
Referenced by calculate_database_size(), calculate_tablespace_size(), CheckPointLogicalRewriteHeap(), CheckPointSnapBuild(), CleanupBackupHistory(), copydir(), db_dir_size(), DeleteAllExportedSnapshotFiles(), destroy_tablespace_directories(), directory_is_empty(), do_pg_backup_start(), dsm_cleanup_for_mmap(), extension_file_exists(), get_ext_ver_list(), GetConfFilesInDir(), getInstallationPaths(), GetWalSummaries(), movedb(), ParseTzFile(), perform_base_backup(), pg_available_extension_versions(), pg_available_extensions(), pg_ls_dir(), pg_ls_dir_files(), pg_tablespace_databases(), pg_tzenumerate_end(), pg_tzenumerate_next(), pgarch_readyXlog(), RelationCacheInitFileRemove(), RelationCacheInitFileRemoveInDir(), RemoveNonParentXlogFiles(), RemoveOldXlogFiles(), RemovePgTempFiles(), RemovePgTempFilesInDir(), RemovePgTempRelationFiles(), RemovePgTempRelationFilesInDbspace(), RemoveTempXlogFiles(), ReorderBufferCleanupSerializedTXNs(), ResetUnloggedRelations(), ResetUnloggedRelationsInDbspaceDir(), ResetUnloggedRelationsInTablespaceDir(), restoreTwoPhaseData(), scan_directory_ci(), sendDir(), SlruScanDirectory(), StartupReorderBuffer(), StartupReplicationSlots(), SyncDataDirectory(), UpdateLogicalMappings(), walkdir(), and XLogGetOldestSegno().
◆ FreeFile()
int FreeFile | ( | FILE * | file | ) |
---|
Definition at line 2843 of file fd.c.
2844{
2845 int i;
2846
2848
2849
2851 {
2853
2856 }
2857
2858
2859 elog(WARNING, "file passed to FreeFile was not obtained from AllocateFile");
2860
2861 return fclose(file);
2862}
References allocatedDescs, AllocateDescFile, AllocateDesc::desc, DO_DB, elog, AllocateDesc::file, FreeDesc(), i, AllocateDesc::kind, LOG, numAllocatedDescs, and WARNING.
Referenced by AlterSystemSetConfigFile(), apw_dump_now(), apw_load_buffers(), checkControlFile(), do_pg_backup_stop(), EndCopy(), EndCopyFrom(), entry_reset(), existsTimeLineHistory(), ExportSnapshot(), free_auth_file(), gc_qtexts(), GetHugePageSize(), ImportSnapshot(), load_dh_file(), load_relcache_init_file(), parse_extension_control_file(), ParseConfigFile(), ParseTzFile(), pg_current_logfile(), pg_promote(), pgss_shmem_shutdown(), pgss_shmem_startup(), pgstat_read_statsfile(), pgstat_write_statsfile(), read_backup_label(), read_binary_file(), read_tablespace_map(), read_whole_file(), readTimeLineHistory(), tsearch_readline_end(), ValidatePgVersion(), write_relcache_init_file(), XLogArchiveForceDone(), and XLogArchiveNotify().
◆ fsync_fname()
void fsync_fname | ( | const char * | fname, |
---|---|---|---|
bool | isdir | ||
) |
Definition at line 756 of file fd.c.
References data_sync_elevel(), ERROR, and fsync_fname_ext().
Referenced by _CloseArchive(), basic_archive_file(), CheckPointLogicalRewriteHeap(), CheckPointTwoPhase(), copydir(), CreateDirAndVersionFile(), CreateSlotOnDisk(), dir_close(), dir_finish(), dir_open_for_write(), main(), ReplicationSlotDropPtr(), ResetUnloggedRelationsInDbspaceDir(), RestoreSlotFromDisk(), SaveSlotToPath(), SimpleLruWriteAll(), SnapBuildRestoreSnapshot(), SnapBuildSerialize(), StartupReplicationSlots(), swap_catalog_files(), sync_queue_sync_all(), and tar_finish().
◆ fsync_fname_ext()
int fsync_fname_ext | ( | const char * | fname, |
---|---|---|---|
bool | isdir, | ||
bool | ignore_perm, | ||
int | elevel | ||
) |
Definition at line 3862 of file fd.c.
3863{
3864 int fd;
3865 int flags;
3866 int returncode;
3867
3868
3869
3870
3871
3872
3873
3875 if (!isdir)
3876 flags |= O_RDWR;
3877 else
3878 flags |= O_RDONLY;
3879
3881
3882
3883
3884
3885
3886
3887 if (fd < 0 && isdir && (errno == EISDIR || errno == EACCES))
3888 return 0;
3889 else if (fd < 0 && ignore_perm && errno == EACCES)
3890 return 0;
3891 else if (fd < 0)
3892 {
3895 errmsg("could not open file \"%s\": %m", fname)));
3896 return -1;
3897 }
3898
3900
3901
3902
3903
3904
3905 if (returncode != 0 && !(isdir && (errno == EBADF || errno == EINVAL)))
3906 {
3907 int save_errno;
3908
3909
3910 save_errno = errno;
3912 errno = save_errno;
3913
3916 errmsg("could not fsync file \"%s\": %m", fname)));
3917 return -1;
3918 }
3919
3921 {
3924 errmsg("could not close file \"%s\": %m", fname)));
3925 return -1;
3926 }
3927
3928 return 0;
3929}
References CloseTransientFile(), ereport, errcode_for_file_access(), errmsg(), fd(), OpenTransientFile(), PG_BINARY, and pg_fsync().
Referenced by datadir_fsync_fname(), durable_rename(), fsync_fname(), and fsync_parent_path().
◆ GetNextTempTableSpace()
Oid GetNextTempTableSpace | ( | void | ) |
---|
◆ GetTempTablespaces()
int GetTempTablespaces | ( | Oid * | tableSpaces, |
---|---|---|---|
int | numSpaces | ||
) |
◆ InitFileAccess()
void InitFileAccess | ( | void | ) |
---|
Definition at line 903 of file fd.c.
904{
906
907
911 (errcode(ERRCODE_OUT_OF_MEMORY),
912 errmsg("out of memory")));
913
916
918}
#define MemSet(start, val, len)
References Assert(), ereport, errcode(), errmsg(), FATAL, vfd::fd, malloc, MemSet, SizeVfdCache, VFD_CLOSED, and VfdCache.
Referenced by BaseInit().
◆ InitTemporaryFileAccess()
void InitTemporaryFileAccess | ( | void | ) |
---|
◆ looks_like_temp_rel_name()
bool looks_like_temp_rel_name | ( | const char * | name | ) |
---|
Definition at line 3514 of file fd.c.
3515{
3516 int pos;
3517 int savepos;
3518
3519
3520 if (name[0] != 't')
3521 return false;
3522
3523
3524 for (pos = 1; isdigit((unsigned char) name[pos]); ++pos)
3525 ;
3526 if (pos == 1 || name[pos] != '_')
3527 return false;
3528
3529
3530 for (savepos = ++pos; isdigit((unsigned char) name[pos]); ++pos)
3531 ;
3532 if (savepos == pos)
3533 return false;
3534
3535
3536 if (name[pos] == '_')
3537 {
3539
3540 if (forkchar <= 0)
3541 return false;
3542 pos += forkchar + 1;
3543 }
3544 if (name[pos] == '.')
3545 {
3546 int segchar;
3547
3548 for (segchar = 1; isdigit((unsigned char) name[pos + segchar]); ++segchar)
3549 ;
3550 if (segchar <= 1)
3551 return false;
3552 pos += segchar;
3553 }
3554
3555
3556 if (name[pos] != '\0')
3557 return false;
3558 return true;
3559}
int forkname_chars(const char *str, ForkNumber *fork)
References forkname_chars(), and name.
Referenced by RemovePgTempRelationFilesInDbspace(), and sendDir().
◆ MakePGDirectory()
int MakePGDirectory | ( | const char * | directoryName | ) |
---|
Definition at line 3978 of file fd.c.
References mkdir, and pg_dir_create_mode.
Referenced by bbsink_server_new(), copydir(), create_tablespace_directories(), CreateDirAndVersionFile(), CreateSlotOnDisk(), OpenTemporaryFileInTablespace(), PathNameCreateTemporaryDir(), SysLogger_Start(), SysLoggerMain(), TablespaceCreateDbspace(), test_slru_shmem_startup(), and ValidateXLOGDirectoryStructure().
◆ OpenPipeStream()
FILE * OpenPipeStream | ( | const char * | command, |
---|---|---|---|
const char * | mode | ||
) |
Definition at line 2747 of file fd.c.
2748{
2749 FILE *file;
2750 int save_errno;
2751
2752 DO_DB(elog(LOG, "OpenPipeStream: Allocated %d (%s)",
2754
2755
2758 (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
2759 errmsg("exceeded maxAllocatedDescs (%d) while trying to execute command \"%s\"",
2761
2762
2764
2765TryAgain:
2766 fflush(NULL);
2768 errno = 0;
2769 file = popen(command, mode);
2770 save_errno = errno;
2772 errno = save_errno;
2773 if (file != NULL)
2774 {
2776
2782 }
2783
2784 if (errno == EMFILE || errno == ENFILE)
2785 {
2787 (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
2788 errmsg("out of file descriptors: %m; release and retry")));
2790 goto TryAgain;
2791 errno = save_errno;
2792 }
2793
2794 return NULL;
2795}
References allocatedDescs, AllocateDescPipe, AllocateDesc::create_subid, AllocateDesc::desc, DO_DB, elog, ereport, errcode(), errmsg(), ERROR, AllocateDesc::file, GetCurrentSubTransactionId(), AllocateDesc::kind, LOG, maxAllocatedDescs, mode, numAllocatedDescs, pqsignal, ReleaseLruFile(), ReleaseLruFiles(), reserveAllocatedDesc(), and SIGPIPE.
Referenced by BeginCopyFrom(), BeginCopyTo(), pg_import_system_collations(), run_ssl_passphrase_command(), and shell_run_command().
◆ OpenTemporaryFile()
File OpenTemporaryFile | ( | bool | interXact | ) |
---|
Definition at line 1728 of file fd.c.
1729{
1730 File file = 0;
1731
1732 Assert(temporary_files_allowed);
1733
1734
1735
1736
1737
1738 if (!interXact)
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1751 {
1753
1756 }
1757
1758
1759
1760
1761
1762
1763 if (file <= 0)
1766 DEFAULTTABLESPACE_OID,
1767 true);
1768
1769
1771
1772
1773 if (!interXact)
1775
1776 return file;
1777}
#define OidIsValid(objectId)
Oid GetNextTempTableSpace(void)
static File OpenTemporaryFileInTablespace(Oid tblspcOid, bool rejectError)
static void RegisterTemporaryFile(File file)
ResourceOwner CurrentResourceOwner
void ResourceOwnerEnlarge(ResourceOwner owner)
References Assert(), CurrentResourceOwner, FD_DELETE_AT_CLOSE, FD_TEMP_FILE_LIMIT, vfd::fdstate, GetNextTempTableSpace(), MyDatabaseTableSpace, numTempTableSpaces, OidIsValid, OpenTemporaryFileInTablespace(), RegisterTemporaryFile(), ResourceOwnerEnlarge(), and VfdCache.
Referenced by BufFileCreateTemp(), and extendBufFile().
◆ OpenTransientFile()
int OpenTransientFile | ( | const char * | fileName, |
---|---|---|---|
int | fileFlags | ||
) |
Definition at line 2694 of file fd.c.
2695{
2697}
int OpenTransientFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
References OpenTransientFilePerm(), and pg_file_create_mode.
Referenced by ApplyLogicalMappingFile(), CheckPointLogicalRewriteHeap(), CheckPointReplicationOrigin(), clone_file(), compare_files(), copy_file(), CreateDirAndVersionFile(), dsm_impl_mmap(), durable_rename(), fsync_fname_ext(), get_controlfile_by_exact_path(), heap_xlog_logical_rewrite(), lo_import_internal(), perform_base_backup(), pg_truncate(), qtext_load_file(), qtext_store(), read_relmap_file(), ReadTwoPhaseFile(), RecreateTwoPhaseFile(), ReorderBufferSerializeTXN(), RestoreSlotFromDisk(), SaveSlotToPath(), sendFile(), SendTimeLineHistory(), SimpleLruDoesPhysicalPageExist(), SlruPhysicalReadPage(), SlruPhysicalWritePage(), SlruSyncFileTag(), SnapBuildRestoreSnapshot(), SnapBuildSerialize(), StartupReplicationOrigin(), write_relmap_file(), writeTimeLineHistory(), writeTimeLineHistoryFile(), and XLogFileCopy().
◆ OpenTransientFilePerm()
int OpenTransientFilePerm | ( | const char * | fileName, |
---|---|---|---|
int | fileFlags, | ||
mode_t | fileMode | ||
) |
Definition at line 2703 of file fd.c.
2704{
2705 int fd;
2706
2707 DO_DB(elog(LOG, "OpenTransientFile: Allocated %d (%s)",
2709
2710
2713 (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
2714 errmsg("exceeded maxAllocatedDescs (%d) while trying to open file \"%s\"",
2716
2717
2719
2721
2722 if (fd >= 0)
2723 {
2725
2730
2731 return fd;
2732 }
2733
2734 return -1;
2735}
References allocatedDescs, AllocateDescRawFD, BasicOpenFilePerm(), AllocateDesc::create_subid, AllocateDesc::desc, DO_DB, elog, ereport, errcode(), errmsg(), ERROR, AllocateDesc::fd, fd(), GetCurrentSubTransactionId(), AllocateDesc::kind, LOG, maxAllocatedDescs, numAllocatedDescs, ReleaseLruFiles(), and reserveAllocatedDesc().
Referenced by be_lo_export(), and OpenTransientFile().
◆ PathNameCreateTemporaryDir()
void PathNameCreateTemporaryDir | ( | const char * | basedir, |
---|---|---|---|
const char * | directory | ||
) |
◆ PathNameCreateTemporaryFile()
File PathNameCreateTemporaryFile | ( | const char * | path, |
---|---|---|---|
bool | error_on_failure | ||
) |
Definition at line 1865 of file fd.c.
1866{
1868
1869 Assert(temporary_files_allowed);
1870
1872
1873
1874
1875
1876
1878 if (file <= 0)
1879 {
1880 if (error_on_failure)
1883 errmsg("could not create temporary file \"%s\": %m",
1884 path)));
1885 else
1886 return file;
1887 }
1888
1889
1891
1892
1894
1895 return file;
1896}
File PathNameOpenFile(const char *fileName, int fileFlags)
References Assert(), CurrentResourceOwner, ereport, errcode_for_file_access(), errmsg(), ERROR, FD_TEMP_FILE_LIMIT, vfd::fdstate, PathNameOpenFile(), PG_BINARY, RegisterTemporaryFile(), ResourceOwnerEnlarge(), and VfdCache.
Referenced by FileSetCreate().
◆ PathNameDeleteTemporaryDir()
void PathNameDeleteTemporaryDir | ( | const char * | dirname | ) |
---|
Definition at line 1695 of file fd.c.
1696{
1697 struct stat statbuf;
1698
1699
1700 if (stat(dirname, &statbuf) != 0 && errno == ENOENT)
1701 return;
1702
1703
1704
1705
1706
1707
1708
1709
1711}
static void unlink_if_exists_fname(const char *fname, bool isdir, int elevel)
static void walkdir(const char *path, void(*action)(const char *fname, bool isdir, int elevel), bool process_symlinks, int elevel)
References LOG, stat, unlink_if_exists_fname(), and walkdir().
Referenced by FileSetDeleteAll().
◆ PathNameDeleteTemporaryFile()
bool PathNameDeleteTemporaryFile | ( | const char * | path, |
---|---|---|---|
bool | error_on_failure | ||
) |
Definition at line 1936 of file fd.c.
1937{
1938 struct stat filestats;
1939 int stat_errno;
1940
1941
1942 if (stat(path, &filestats) != 0)
1943 stat_errno = errno;
1944 else
1945 stat_errno = 0;
1946
1947
1948
1949
1950
1951
1952 if (stat_errno == ENOENT)
1953 return false;
1954
1955 if (unlink(path) < 0)
1956 {
1957 if (errno != ENOENT)
1960 errmsg("could not unlink temporary file \"%s\": %m",
1961 path)));
1962 return false;
1963 }
1964
1965 if (stat_errno == 0)
1967 else
1968 {
1969 errno = stat_errno;
1972 errmsg("could not stat file \"%s\": %m", path)));
1973 }
1974
1975 return true;
1976}
References ereport, errcode_for_file_access(), errmsg(), ERROR, LOG, ReportTemporaryFileUsage(), stat::st_size, and stat.
Referenced by FileSetDelete(), and unlink_if_exists_fname().
◆ PathNameOpenFile()
File PathNameOpenFile | ( | const char * | fileName, |
---|---|---|---|
int | fileFlags | ||
) |
Definition at line 1579 of file fd.c.
1580{
1582}
File PathNameOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
References PathNameOpenFilePerm(), and pg_file_create_mode.
Referenced by _mdfd_openseg(), bbsink_server_begin_archive(), bbsink_server_begin_manifest(), logical_rewrite_log_mapping(), mdcreate(), mdopenfork(), mdsyncfiletag(), OpenTemporaryFileInTablespace(), OpenWalSummaryFile(), PathNameCreateTemporaryFile(), PathNameOpenTemporaryFile(), ReorderBufferRestoreChanges(), and SummarizeWAL().
◆ PathNameOpenFilePerm()
File PathNameOpenFilePerm | ( | const char * | fileName, |
---|---|---|---|
int | fileFlags, | ||
mode_t | fileMode | ||
) |
Definition at line 1592 of file fd.c.
1593{
1594 char *fnamecopy;
1596 Vfd *vfdP;
1597
1598 DO_DB(elog(LOG, "PathNameOpenFilePerm: %s %x %o",
1599 fileName, fileFlags, fileMode));
1600
1601
1602
1603
1604 fnamecopy = strdup(fileName);
1605 if (fnamecopy == NULL)
1607 (errcode(ERRCODE_OUT_OF_MEMORY),
1608 errmsg("out of memory")));
1609
1612
1613
1615
1616
1617
1618
1619
1620
1621
1623
1625
1626 if (vfdP->fd < 0)
1627 {
1628 int save_errno = errno;
1629
1631 free(fnamecopy);
1632 errno = save_errno;
1633 return -1;
1634 }
1636 DO_DB(elog(LOG, "PathNameOpenFile: success %d",
1637 vfdP->fd));
1638
1640
1641 vfdP->fileFlags = fileFlags & ~(O_CREAT | O_TRUNC | O_EXCL);
1646
1648
1649 return file;
1650}
static File AllocateVfd(void)
static void Insert(File file)
References AllocateVfd(), BasicOpenFilePerm(), DO_DB, elog, ereport, errcode(), errmsg(), ERROR, vfd::fd, vfd::fdstate, vfd::fileFlags, vfd::fileMode, vfd::fileName, vfd::fileSize, free, FreeVfd(), Insert(), LOG, nfile, O_CLOEXEC, ReleaseLruFiles(), vfd::resowner, and VfdCache.
Referenced by PathNameOpenFile().
◆ PathNameOpenTemporaryFile()
File PathNameOpenTemporaryFile | ( | const char * | path, |
---|---|---|---|
int | mode | ||
) |
Definition at line 1905 of file fd.c.
1906{
1908
1909 Assert(temporary_files_allowed);
1910
1912
1914
1915
1916 if (file <= 0 && errno != ENOENT)
1919 errmsg("could not open temporary file \"%s\": %m",
1920 path)));
1921
1922 if (file > 0)
1923 {
1924
1926 }
1927
1928 return file;
1929}
References Assert(), CurrentResourceOwner, ereport, errcode_for_file_access(), errmsg(), ERROR, mode, PathNameOpenFile(), PG_BINARY, RegisterTemporaryFile(), and ResourceOwnerEnlarge().
Referenced by FileSetOpen().
◆ pg_fdatasync()
int pg_fdatasync | ( | int | fd | ) |
---|
◆ pg_file_exists()
bool pg_file_exists | ( | const char * | name | ) |
---|
Definition at line 503 of file fd.c.
504{
505 struct stat st;
506
508
510 return (st.st_mode);
511 else if (!(errno == ENOENT || errno == ENOTDIR || errno == EACCES))
514 errmsg("could not access file \"%s\": %m", name)));
515
516 return false;
517}
References Assert(), ereport, errcode_for_file_access(), errmsg(), ERROR, name, S_ISDIR, stat::st_mode, and stat.
Referenced by expand_dynamic_library_name(), find_in_path(), find_in_paths(), and provider_init().
◆ pg_flush_data()
void pg_flush_data | ( | int | fd, |
---|---|---|---|
off_t | offset, | ||
off_t | nbytes | ||
) |
Definition at line 525 of file fd.c.
526{
527
528
529
530
531
532
534 return;
535
536
537
538
539
540#if defined(HAVE_SYNC_FILE_RANGE)
541 {
542 int rc;
543 static bool not_implemented_by_kernel = false;
544
545 if (not_implemented_by_kernel)
546 return;
547
548retry:
549
550
551
552
553
554
555
556
557
558
559 rc = sync_file_range(fd, offset, nbytes,
560 SYNC_FILE_RANGE_WRITE);
561 if (rc != 0)
562 {
563 int elevel;
564
566 goto retry;
567
568
569
570
571
572
573 if (errno == ENOSYS)
574 {
576 not_implemented_by_kernel = true;
577 }
578 else
580
583 errmsg("could not flush dirty data: %m")));
584 }
585
586 return;
587 }
588#endif
589#if !defined(WIN32) && defined(MS_ASYNC)
590 {
591 void *p;
592 static int pagesize = 0;
593
594
595
596
597
598
599
600
601
602
603
604
605
606 if (offset == 0 && nbytes == 0)
607 {
608 nbytes = lseek(fd, 0, SEEK_END);
609 if (nbytes < 0)
610 {
613 errmsg("could not determine dirty data size: %m")));
614 return;
615 }
616 }
617
618
619
620
621
622
623
624
625 if (pagesize == 0)
626 pagesize = sysconf(_SC_PAGESIZE);
627
628
629 if (pagesize > 0)
630 nbytes = (nbytes / pagesize) * pagesize;
631
632
633 if (nbytes <= 0)
634 return;
635
636
637
638
639
640
641 if (nbytes <= (off_t) SSIZE_MAX)
642 p = mmap(NULL, nbytes, PROT_READ, MAP_SHARED, fd, offset);
643 else
645
647 {
648 int rc;
649
650 rc = msync(p, (size_t) nbytes, MS_ASYNC);
651 if (rc != 0)
652 {
655 errmsg("could not flush dirty data: %m")));
656
657 }
658
659 rc = munmap(p, (size_t) nbytes);
660 if (rc != 0)
661 {
662
665 errmsg("could not munmap() while flushing data: %m")));
666 }
667
668 return;
669 }
670 }
671#endif
672#if defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
673 {
674 int rc;
675
676
677
678
679
680
681
682
683
684 rc = posix_fadvise(fd, offset, nbytes, POSIX_FADV_DONTNEED);
685
686 if (rc != 0)
687 {
688
691 errmsg("could not flush dirty data: %m")));
692 }
693
694 return;
695 }
696#endif
697}
References data_sync_elevel(), EINTR, enableFsync, ereport, errcode_for_file_access(), errmsg(), FATAL, fd(), MAP_FAILED, and WARNING.
Referenced by copy_file(), and FileWriteback().
◆ pg_fsync()
Definition at line 386 of file fd.c.
387{
388#if !defined(WIN32) && defined(USE_ASSERT_CHECKING)
389 struct stat st;
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
411 {
412 int desc_flags = fcntl(fd, F_GETFL);
413
414
415
416
417
419 Assert((desc_flags & (O_RDWR | O_WRONLY)) == 0);
420 else
421 Assert((desc_flags & (O_RDWR | O_WRONLY)) != 0);
422 }
423 errno = 0;
424#endif
425
426
427#if defined(HAVE_FSYNC_WRITETHROUGH)
430 else
431#endif
433}
int pg_fsync_no_writethrough(int fd)
int pg_fsync_writethrough(int fd)
@ WAL_SYNC_METHOD_FSYNC_WRITETHROUGH
References Assert(), fd(), fstat, pg_fsync_no_writethrough(), pg_fsync_writethrough(), S_ISDIR, stat::st_mode, wal_sync_method, and WAL_SYNC_METHOD_FSYNC_WRITETHROUGH.
Referenced by AddToDataDirLockFile(), assign_wal_sync_method(), BootStrapXLOG(), CheckPointLogicalRewriteHeap(), CreateDirAndVersionFile(), CreateLockFile(), durable_rename(), FileSync(), fsync_fname_ext(), heap_xlog_logical_rewrite(), readRecoverySignalFile(), RecreateTwoPhaseFile(), RestoreSlotFromDisk(), SaveSlotToPath(), SlruPhysicalWritePage(), SlruSyncFileTag(), SnapBuildSerialize(), update_controlfile(), write_auto_conf_file(), WriteControlFile(), writeTimeLineHistory(), writeTimeLineHistoryFile(), XLogFileCopy(), and XLogFileInitInternal().
◆ pg_fsync_no_writethrough()
int pg_fsync_no_writethrough | ( | int | fd | ) |
---|
◆ pg_fsync_writethrough()
int pg_fsync_writethrough | ( | int | fd | ) |
---|
Definition at line 461 of file fd.c.
462{
464 {
465#if defined(F_FULLFSYNC)
466 return (fcntl(fd, F_FULLFSYNC, 0) == -1) ? -1 : 0;
467#else
468 errno = ENOSYS;
469 return -1;
470#endif
471 }
472 else
473 return 0;
474}
References enableFsync, and fd().
Referenced by issue_xlog_fsync(), pg_fsync(), and test_sync().
◆ pg_truncate()
int pg_truncate | ( | const char * | path, |
---|---|---|---|
off_t | length | ||
) |
◆ ReadDir()
struct dirent * ReadDir | ( | DIR * | dir, |
---|---|---|---|
const char * | dirname | ||
) |
Definition at line 2973 of file fd.c.
2974{
2976}
struct dirent * ReadDirExtended(DIR *dir, const char *dirname, int elevel)
References ERROR, and ReadDirExtended().
Referenced by calculate_database_size(), calculate_tablespace_size(), CheckPointLogicalRewriteHeap(), CheckPointSnapBuild(), CheckTablespaceDirectory(), CleanupBackupHistory(), copydir(), db_dir_size(), destroy_tablespace_directories(), directory_is_empty(), do_pg_backup_start(), dsm_cleanup_for_mmap(), extension_file_exists(), get_ext_ver_list(), GetConfFilesInDir(), GetWalSummaries(), movedb(), perform_base_backup(), pg_available_extension_versions(), pg_available_extensions(), pg_ls_dir(), pg_ls_dir_files(), pg_tablespace_databases(), pg_tzenumerate_next(), pgarch_readyXlog(), RemoveNonParentXlogFiles(), RemoveOldXlogFiles(), RemoveTempXlogFiles(), ResetUnloggedRelations(), ResetUnloggedRelationsInDbspaceDir(), ResetUnloggedRelationsInTablespaceDir(), restoreTwoPhaseData(), sendDir(), SlruScanDirectory(), StartupReorderBuffer(), StartupReplicationSlots(), UpdateLogicalMappings(), and XLogGetOldestSegno().
◆ ReadDirExtended()
struct dirent * ReadDirExtended | ( | DIR * | dir, |
---|---|---|---|
const char * | dirname, | ||
int | elevel | ||
) |
Definition at line 2988 of file fd.c.
2989{
2990 struct dirent *dent;
2991
2992
2993 if (dir == NULL)
2994 {
2997 errmsg("could not open directory \"%s\": %m",
2998 dirname)));
2999 return NULL;
3000 }
3001
3002 errno = 0;
3003 if ((dent = readdir(dir)) != NULL)
3004 return dent;
3005
3006 if (errno)
3009 errmsg("could not read directory \"%s\": %m",
3010 dirname)));
3011 return NULL;
3012}
struct dirent * readdir(DIR *)
References ereport, errcode_for_file_access(), errmsg(), and readdir().
Referenced by DeleteAllExportedSnapshotFiles(), ReadDir(), RelationCacheInitFileRemove(), RelationCacheInitFileRemoveInDir(), RemovePgTempFiles(), RemovePgTempFilesInDir(), RemovePgTempRelationFiles(), RemovePgTempRelationFilesInDbspace(), ReorderBufferCleanupSerializedTXNs(), scan_directory_ci(), SyncDataDirectory(), and walkdir().
◆ ReleaseExternalFD()
void ReleaseExternalFD | ( | void | ) |
---|
◆ RemovePgTempFiles()
void RemovePgTempFiles | ( | void | ) |
---|
Definition at line 3338 of file fd.c.
3339{
3341 DIR *spc_dir;
3342 struct dirent *spc_de;
3343
3344
3345
3346
3350
3351
3352
3353
3355
3357 {
3358 if (strcmp(spc_de->d_name, ".") == 0 ||
3359 strcmp(spc_de->d_name, "..") == 0)
3360 continue;
3361
3362 snprintf(temp_path, sizeof(temp_path), "%s/%s/%s/%s",
3366
3367 snprintf(temp_path, sizeof(temp_path), "%s/%s/%s",
3370 }
3371
3373
3374
3375
3376
3377
3378
3379
3380}
static void RemovePgTempRelationFiles(const char *tsdirname)
void RemovePgTempFilesInDir(const char *tmpdirname, bool missing_ok, bool unlink_all)
DIR * AllocateDir(const char *dirname)
#define PG_TEMP_FILES_DIR
#define TABLESPACE_VERSION_DIRECTORY
References AllocateDir(), dirent::d_name, FreeDir(), LOG, MAXPGPATH, PG_TBLSPC_DIR, PG_TEMP_FILES_DIR, ReadDirExtended(), RemovePgTempFilesInDir(), RemovePgTempRelationFiles(), snprintf, and TABLESPACE_VERSION_DIRECTORY.
Referenced by PostmasterMain(), and PostmasterStateMachine().
◆ RemovePgTempFilesInDir()
void RemovePgTempFilesInDir | ( | const char * | tmpdirname, |
---|---|---|---|
bool | missing_ok, | ||
bool | unlink_all | ||
) |
Definition at line 3398 of file fd.c.
3399{
3400 DIR *temp_dir;
3401 struct dirent *temp_de;
3403
3405
3406 if (temp_dir == NULL && errno == ENOENT && missing_ok)
3407 return;
3408
3409 while ((temp_de = ReadDirExtended(temp_dir, tmpdirname, LOG)) != NULL)
3410 {
3411 if (strcmp(temp_de->d_name, ".") == 0 ||
3412 strcmp(temp_de->d_name, "..") == 0)
3413 continue;
3414
3415 snprintf(rm_path, sizeof(rm_path), "%s/%s",
3416 tmpdirname, temp_de->d_name);
3417
3418 if (unlink_all ||
3419 strncmp(temp_de->d_name,
3422 {
3424
3426 continue;
3428 {
3429
3431
3432 if (rmdir(rm_path) < 0)
3435 errmsg("could not remove directory \"%s\": %m",
3436 rm_path)));
3437 }
3438 else
3439 {
3440 if (unlink(rm_path) < 0)
3443 errmsg("could not remove file \"%s\": %m",
3444 rm_path)));
3445 }
3446 }
3447 else
3449 (errmsg("unexpected file found in temporary-files directory: \"%s\"",
3450 rm_path)));
3451 }
3452
3454}
PGFileType get_dirent_type(const char *path, const struct dirent *de, bool look_through_symlinks, int elevel)
#define PG_TEMP_FILE_PREFIX
References AllocateDir(), dirent::d_name, ereport, errcode_for_file_access(), errmsg(), FreeDir(), get_dirent_type(), LOG, MAXPGPATH, PG_TEMP_FILE_PREFIX, PGFILETYPE_DIR, PGFILETYPE_ERROR, ReadDirExtended(), RemovePgTempFilesInDir(), snprintf, and type.
Referenced by PostmasterMain(), RemovePgTempFiles(), and RemovePgTempFilesInDir().
◆ ReserveExternalFD()
void ReserveExternalFD | ( | void | ) |
---|
◆ set_max_safe_fds()
void set_max_safe_fds | ( | void | ) |
---|
Definition at line 1044 of file fd.c.
1045{
1046 int usable_fds;
1047 int already_open;
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1059 &usable_fds, &already_open);
1060
1062
1063
1064
1065
1067
1068
1069
1070
1073 (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
1074 errmsg("insufficient file descriptors available to start server process"),
1075 errdetail("System allows %d, server needs at least %d, %d files are already open.",
1078 already_open)));
1079
1080 elog(DEBUG2, "max_safe_fds = %d, usable_fds = %d, already_open = %d",
1082}
int errdetail(const char *fmt,...)
int max_files_per_process
static void count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
References count_usable_fds(), DEBUG2, elog, ereport, errcode(), errdetail(), errmsg(), FATAL, FD_MINFREE, max_files_per_process, max_safe_fds, Min, and NUM_RESERVED_FDS.
Referenced by BootstrapModeMain(), PostgresSingleUserMain(), and PostmasterMain().
◆ SetTempTablespaces()
void SetTempTablespaces | ( | Oid * | tableSpaces, |
---|---|---|---|
int | numSpaces | ||
) |
◆ SyncDataDirectory()
void SyncDataDirectory | ( | void | ) |
---|
Definition at line 3609 of file fd.c.
3610{
3611 bool xlog_is_symlink;
3612
3613
3615 return;
3616
3617
3618
3619
3620
3621 xlog_is_symlink = false;
3622
3623 {
3624 struct stat st;
3625
3626 if (lstat("pg_wal", &st) < 0)
3629 errmsg("could not stat file \"%s\": %m",
3630 "pg_wal")));
3631 else if (S_ISLNK(st.st_mode))
3632 xlog_is_symlink = true;
3633 }
3634
3635#ifdef HAVE_SYNCFS
3637 {
3638 DIR *dir;
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3651
3652
3653 do_syncfs(".");
3654
3657 {
3659
3660 if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)
3661 continue;
3662
3664 do_syncfs(path);
3665 }
3667
3668 if (xlog_is_symlink)
3669 do_syncfs("pg_wal");
3670 return;
3671 }
3672#endif
3673
3674#ifdef PG_FLUSH_DATA_WORKS
3675
3677
3678
3679
3680
3681
3682
3684 if (xlog_is_symlink)
3685 walkdir("pg_wal", pre_sync_fname, false, DEBUG1);
3687#endif
3688
3689
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3702 if (xlog_is_symlink)
3705}
void begin_startup_progress_phase(void)
int recovery_init_sync_method
static void datadir_fsync_fname(const char *fname, bool isdir, int elevel)
@ DATA_DIR_SYNC_METHOD_SYNCFS
References AllocateDir(), begin_startup_progress_phase(), dirent::d_name, DATA_DIR_SYNC_METHOD_SYNCFS, datadir_fsync_fname(), DEBUG1, enableFsync, ereport, errcode_for_file_access(), errmsg(), FreeDir(), LOG, lstat, MAXPGPATH, PG_TBLSPC_DIR, ReadDirExtended(), recovery_init_sync_method, S_ISLNK, snprintf, stat::st_mode, and walkdir().
Referenced by StartupXLOG().
◆ TempTablespacePath()
void TempTablespacePath | ( | char * | path, |
---|---|---|---|
Oid | tablespace | ||
) |
◆ TempTablespacesAreSet()
bool TempTablespacesAreSet | ( | void | ) |
---|
◆ data_sync_retry
◆ io_direct_flags
Definition at line 168 of file fd.c.
Referenced by _mdfd_open_flags(), assign_debug_io_direct(), get_sync_bit(), mdprefetch(), mdstartreadv(), mdwriteback(), PrefetchLocalBuffer(), PrefetchSharedBuffer(), read_stream_begin_impl(), ScheduleBufferTagForWriteback(), XLogFileClose(), XLogFileInitInternal(), and XLogPrefetcherNextBlock().