Skip to content

Commit ede6b19

Browse files
committed
Tolerate EINVAL when calling fsync() on a directory.
Previously, we tolerated EBADF as a way for the operating system to indicate that it doesn't support fsync() on a directory. Tolerate EINVAL too, for older versions of Linux CIFS. Bug #15636. Back-patch all the way. Reported-by: John Klann Discussion: https://postgr.es/m/15636-d380890dafd78fc6@postgresql.org
1 parent 99a1554 commit ede6b19

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/backend/storage/file/fd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2944,7 +2944,7 @@ fsync_fname_ext(const char *fname, bool isdir, bool ignore_perm, int elevel)
29442944
* Some OSes don't allow us to fsync directories at all, so we can ignore
29452945
* those errors. Anything else needs to be logged.
29462946
*/
2947-
if (returncode != 0 && !(isdir && errno == EBADF))
2947+
if (returncode != 0 && !(isdir && (errno == EBADF || errno == EINVAL)))
29482948
{
29492949
int save_errno;
29502950

src/bin/initdb/initdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ fsync_fname_ext(const char *fname, bool isdir)
696696
* Some OSes don't allow us to fsync directories at all, so we can ignore
697697
* those errors. Anything else needs to be reported.
698698
*/
699-
if (returncode != 0 && !(isdir && errno == EBADF))
699+
if (returncode != 0 && !(isdir && (errno == EBADF || errno == EINVAL)))
700700
fprintf(stderr, _("%s: could not fsync file \"%s\": %s\n"),
701701
progname, fname, strerror(errno));
702702

0 commit comments

Comments
 (0)