Revert "Don't open lock files for writing (#17956)"
This reverts commit 75aadf23310597eebdc6b78f010fdf572139f24c (introduced
by #17956).
This fixes #18061.
On NFS `flock` implicitly falls back to `lockf` which requires the file
be open for writing when taking an exclusive lock.