Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Tolerate EINVAL when calling fsync() on a directory.
authorThomas Munro <tmunro@postgresql.org>
Sun, 24 Feb 2019 10:59:26 +0000 (23:59 +1300)
committerThomas Munro <tmunro@postgresql.org>
Sun, 24 Feb 2019 11:02:56 +0000 (00:02 +1300)
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

src/backend/storage/file/fd.c
src/bin/initdb/initdb.c

index df13a3e367c8d68a98ea83dfbe5f8944ef567e6a..1fa83274fb34425176e057079ecb42337e1ffde1 100644 (file)
@@ -2944,7 +2944,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;
 
index 1d4546eeafb3a202d6bc3abc1a15eea625e3f537..2948e73af0e1789b3d2a9cd2e48411f60e6c453f 100644 (file)
@@ -696,7 +696,7 @@ fsync_fname_ext(const char *fname, bool isdir)
     * 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));