diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-09-26 13:42:53 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-09-26 13:43:07 -0400 |
commit | 12ac252f9014a96c0b7159912659fa4d0f9cbc07 (patch) | |
tree | c9fb2f88c3850452a72f6cb82f08f055c2b5b509 | |
parent | 1750612224704043218fac81e29c05d866e866ce (diff) | |
download | postgresql-12ac252f9014a96c0b7159912659fa4d0f9cbc07.tar.gz postgresql-12ac252f9014a96c0b7159912659fa4d0f9cbc07.zip |
Fix failure-to-read-man-page in commit 899bd785c.
posix_fallocate() is not quite a drop-in replacement for fallocate(),
because it is defined to return the error code as its function result,
not in "errno". I (tgl) missed this because RHEL6's version seems
to set errno as well. That is not the case on more modern Linuxen,
though, as per buildfarm results.
Aside from fixing the return-convention confusion, remove the test
for ENOSYS; we expect that glibc will mask that for posix_fallocate,
though it does not for fallocate. Keep the test for EINTR, because
POSIX specifies that as a possible result, and buildfarm results
suggest that it can happen in practice.
Back-patch to 9.4, like the previous commit.
Thomas Munro
Discussion: https://postgr.es/m/1002664500.12301802.1471008223422.JavaMail.yahoo@mail.yahoo.com
-rw-r--r-- | src/backend/storage/ipc/dsm_impl.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/backend/storage/ipc/dsm_impl.c b/src/backend/storage/ipc/dsm_impl.c index fce6044a3d1..1a11d21df0c 100644 --- a/src/backend/storage/ipc/dsm_impl.c +++ b/src/backend/storage/ipc/dsm_impl.c @@ -425,17 +425,14 @@ dsm_impl_posix_resize(int fd, off_t size) do { rc = posix_fallocate(fd, 0, size); - } while (rc == -1 && errno == EINTR); + } while (rc == EINTR); - if (rc != 0 && errno == ENOSYS) - { - /* - * Kernel too old (< 2.6.23). Rather than fail, just trust that - * we won't hit the problem (it typically doesn't show up without - * many-GB-sized requests, anyway). - */ - rc = 0; - } + /* + * The caller expects errno to be set, but posix_fallocate() doesn't + * set it. Instead it returns error numbers directly. So set errno, + * even though we'll also return rc to indicate success or failure. + */ + errno = rc; } #endif /* HAVE_POSIX_FALLOCATE && __linux__ */ |