[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#7682) LMDB: [PATCH] mdb_env_copy should retry open() if O_DIRECT fails

On 2013-09-13 23:09, sog@msg.com.mx wrote:
> If the call fails because O_DIRECT, in a "tmpfs" in my Fedora 19 
> '/tmp',
> the file is left created anyway! so the retry fails because 

Also on RHEL 6.4 (2.6.32-358.18.1.el6.x86_64) with
/dev/shm/nosuch.  I'll report it to RedHat and see what they say.

> I propose the following:
> (...)
> +     * Fortunately seems that other errors are reported before EINVAL
> +     * So, we need to remove it before retry open.
>        */
>       if (newfd == INVALID_HANDLE_VALUE && ErrCode() == EINVAL)
> +        (void)unlink(lpath)  ,

No unlink(). EINVAL does not say whether the file existed
before the call. Not on another OS, nor on another Linux
version or filesystem where Linux may work differently.

Somewhat better: #ifdef <buggy Linux>, replace O_EXCL with
O_TRUNC in the 2nd call. Or add paranoia like taking an
exclusive lock, but ignore "locking not supported" errors.

>   #endif
>       newfd = open(lpath, O_WRONLY|O_CREAT|O_EXCL, 0666);
>   #endif