Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
cc52d5b3
Commit
cc52d5b3
authored
Sep 04, 2013
by
Robert Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose fsync_fname as a public API.
Andres Freund
parent
0c66a223
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
59 deletions
+57
-59
src/backend/storage/file/copydir.c
src/backend/storage/file/copydir.c
+0
-59
src/backend/storage/file/fd.c
src/backend/storage/file/fd.c
+56
-0
src/include/storage/fd.h
src/include/storage/fd.h
+1
-0
No files found.
src/backend/storage/file/copydir.c
View file @
cc52d5b3
...
@@ -27,9 +27,6 @@
...
@@ -27,9 +27,6 @@
#include "miscadmin.h"
#include "miscadmin.h"
static
void
fsync_fname
(
char
*
fname
,
bool
isdir
);
/*
/*
* copydir: copy a directory
* copydir: copy a directory
*
*
...
@@ -207,59 +204,3 @@ copy_file(char *fromfile, char *tofile)
...
@@ -207,59 +204,3 @@ copy_file(char *fromfile, char *tofile)
pfree
(
buffer
);
pfree
(
buffer
);
}
}
/*
* fsync a file
*
* Try to fsync directories but ignore errors that indicate the OS
* just doesn't allow/require fsyncing directories.
*/
static
void
fsync_fname
(
char
*
fname
,
bool
isdir
)
{
int
fd
;
int
returncode
;
/*
* Some OSs require directories to be opened read-only whereas other
* systems don't allow us to fsync files opened read-only; so we need both
* cases here
*/
if
(
!
isdir
)
fd
=
OpenTransientFile
(
fname
,
O_RDWR
|
PG_BINARY
,
S_IRUSR
|
S_IWUSR
);
else
fd
=
OpenTransientFile
(
fname
,
O_RDONLY
|
PG_BINARY
,
S_IRUSR
|
S_IWUSR
);
/*
* Some OSs don't allow us to open directories at all (Windows returns
* EACCES)
*/
if
(
fd
<
0
&&
isdir
&&
(
errno
==
EISDIR
||
errno
==
EACCES
))
return
;
else
if
(
fd
<
0
)
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not open file
\"
%s
\"
: %m"
,
fname
)));
returncode
=
pg_fsync
(
fd
);
/* Some OSs don't allow us to fsync directories at all */
if
(
returncode
!=
0
&&
isdir
&&
errno
==
EBADF
)
{
CloseTransientFile
(
fd
);
return
;
}
if
(
returncode
!=
0
)
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not fsync file
\"
%s
\"
: %m"
,
fname
)));
CloseTransientFile
(
fd
);
}
src/backend/storage/file/fd.c
View file @
cc52d5b3
...
@@ -384,6 +384,62 @@ pg_flush_data(int fd, off_t offset, off_t amount)
...
@@ -384,6 +384,62 @@ pg_flush_data(int fd, off_t offset, off_t amount)
}
}
/*
* fsync_fname -- fsync a file or directory, handling errors properly
*
* Try to fsync a file or directory. When doing the latter, ignore errors that
* indicate the OS just doesn't allow/require fsyncing directories.
*/
void
fsync_fname
(
char
*
fname
,
bool
isdir
)
{
int
fd
;
int
returncode
;
/*
* Some OSs require directories to be opened read-only whereas other
* systems don't allow us to fsync files opened read-only; so we need both
* cases here
*/
if
(
!
isdir
)
fd
=
OpenTransientFile
(
fname
,
O_RDWR
|
PG_BINARY
,
S_IRUSR
|
S_IWUSR
);
else
fd
=
OpenTransientFile
(
fname
,
O_RDONLY
|
PG_BINARY
,
S_IRUSR
|
S_IWUSR
);
/*
* Some OSs don't allow us to open directories at all (Windows returns
* EACCES)
*/
if
(
fd
<
0
&&
isdir
&&
(
errno
==
EISDIR
||
errno
==
EACCES
))
return
;
else
if
(
fd
<
0
)
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not open file
\"
%s
\"
: %m"
,
fname
)));
returncode
=
pg_fsync
(
fd
);
/* Some OSs don't allow us to fsync directories at all */
if
(
returncode
!=
0
&&
isdir
&&
errno
==
EBADF
)
{
CloseTransientFile
(
fd
);
return
;
}
if
(
returncode
!=
0
)
ereport
(
ERROR
,
(
errcode_for_file_access
(),
errmsg
(
"could not fsync file
\"
%s
\"
: %m"
,
fname
)));
CloseTransientFile
(
fd
);
}
/*
/*
* InitFileAccess --- initialize this module during backend startup
* InitFileAccess --- initialize this module during backend startup
*
*
...
...
src/include/storage/fd.h
View file @
cc52d5b3
...
@@ -113,6 +113,7 @@ extern int pg_fsync_no_writethrough(int fd);
...
@@ -113,6 +113,7 @@ extern int pg_fsync_no_writethrough(int fd);
extern
int
pg_fsync_writethrough
(
int
fd
);
extern
int
pg_fsync_writethrough
(
int
fd
);
extern
int
pg_fdatasync
(
int
fd
);
extern
int
pg_fdatasync
(
int
fd
);
extern
int
pg_flush_data
(
int
fd
,
off_t
offset
,
off_t
amount
);
extern
int
pg_flush_data
(
int
fd
,
off_t
offset
,
off_t
amount
);
extern
void
fsync_fname
(
char
*
fname
,
bool
isdir
);
/* Filename components for OpenTemporaryFile */
/* Filename components for OpenTemporaryFile */
#define PG_TEMP_FILES_DIR "pgsql_tmp"
#define PG_TEMP_FILES_DIR "pgsql_tmp"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment