]> granicus.if.org Git - postgresql/commitdiff
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:15 +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 c255583026f5dd506602eb22855d3513fd827cb5..ba7f3d96ae0e81ac5fecae6e0e6db03f0c4c3e8e 100644 (file)
@@ -2945,7 +2945,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 485a4024d507c49f7c41fb28a95cedd2bce6a08a..a4d2184ff8c55dc4aa99ffd1179ad12f918147c8 100644 (file)
@@ -688,7 +688,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));