]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Tolerate EINVAL when calling fsync() on a directory.
authorThomas Munro <tmunro@postgresql.org>
Sun, 24 Feb 2019 10:48:52 +0000 (23:48 +1300)
committerThomas Munro <tmunro@postgresql.org>
Sun, 24 Feb 2019 10:52:20 +0000 (23:52 +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/common/file_utils.c

index 96fe1827b20a5bfe8d295b0199e471e9179141a1..19d4e20415135e70f9900a76e88a7be4b07e891c 100644 (file)
@@ -3225,7 +3225,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 4304058acb23f2c8fc40cf654f06aa6c4da46fb9..5f934a14c110323a3257de18009af377860a56c8 100644 (file)
@@ -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));