From: Thomas Munro Date: Sun, 24 Feb 2019 10:48:52 +0000 (+1300) Subject: Tolerate EINVAL when calling fsync() on a directory. X-Git-Tag: REL_11_3~111 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4d67357dbf5016836dc9ea9a8789cc539dfa3b60;p=postgresql 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 --- diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 747eb3c537..8d2b8aacfe 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -3538,7 +3538,7 @@ fsync_fname_ext(const char *fname, bool isdir, bool ignore_perm, int elevel) * Some OSes don't allow us to fsync directories at all, so we can ignore * those errors. Anything else needs to be logged. */ - if (returncode != 0 && !(isdir && errno == EBADF)) + if (returncode != 0 && !(isdir && (errno == EBADF || errno == EINVAL))) { int save_errno; diff --git a/src/common/file_utils.c b/src/common/file_utils.c index 48876061c3..af8746fc70 100644 --- a/src/common/file_utils.c +++ b/src/common/file_utils.c @@ -299,7 +299,7 @@ fsync_fname(const char *fname, bool isdir, const char *progname) * Some OSes don't allow us to fsync directories at all, so we can ignore * those errors. Anything else needs to be reported. */ - if (returncode != 0 && !(isdir && errno == EBADF)) + if (returncode != 0 && !(isdir && (errno == EBADF || errno == EINVAL))) { fprintf(stderr, _("%s: could not fsync file \"%s\": %s\n"), progname, fname, strerror(errno));