mdbx: backport - ITS#7682 F_NOCACHE: Allow error, skip any O_DIRECT.

We can run without F_NOCACHE if it fails. And we do not know
what combining it with O_DIRECT means, if a system has both.

Change-Id: Iec12b7097f4ed9f3ea5beae4a2deb874e4118131
This commit is contained in:
Hallvard Furuseth 2016-09-06 17:41:02 +02:00 committed by Leo Yuriev
parent f3b99004d1
commit 9a8270f427

11
mdb.c
View File

@ -9550,17 +9550,12 @@ mdb_env_copy2(MDB_env *env, const char *path, unsigned flags)
}
if (env->me_psize >= env->me_os_psize) {
#ifdef O_DIRECT
#ifdef F_NOCACHE /* __APPLE__ */
(void) fcntl(newfd, F_NOCACHE, 1);
#elif defined O_DIRECT
/* Set O_DIRECT if the file system supports it */
if ((rc = fcntl(newfd, F_GETFL)) != -1)
(void) fcntl(newfd, F_SETFL, rc | O_DIRECT);
#endif
#ifdef F_NOCACHE /* __APPLE__ */
rc = fcntl(newfd, F_NOCACHE, 1);
if (rc) {
rc = errno;
goto leave;
}
#endif
}