in reply to Is getting locks on files with NFS broken on CygPerl?

I'm using CygPerl v5.40.3 (5.040003), on Windows 11. I am testing File::NFSLock 1.29.

NFS is a Unix thing. Are you sure Win11 does support NFS? Out of the box?

Answering my questions: Yes, it does support NFS, since at least Windows 7, but not out of the box, and not for all versions. You have to actively install the NFS client, according to a quick Google search. (See https://www.reddit.com/r/Winsides/comments/1ioxr0d/how_to_create_an_nfs_share_on_windows_11/.)

Is it possible that the lock operations are breaking because I have the build directories for these modules on a FAT32 filesystem, rather than NTFS? Wild guess.

NFS locks obviously can only work on NFS. The tests will need an NFS export mounted somewhere to properly test.

At least the tests 120_single.t, 130_taint.t, 200_bl_ex.t, and 300_bl_sh.t seem to lock a temp file generated by File::Temp, which will very likely NOT be on an NFS share, neither on Linux Unix nor on Windows. Also, at least 200_bl_ex.t and 300_bl_sh.t are completely skipped on Windows, because Windows does not support fork().

Looking at the description in the POD, this sounds very fishy to me:

Program based of concept of hard linking of files being atomic across NFS. This concept was mentioned in Mail::Box::Locker (which was originally presented in Mail::Folder::Maildir). Some routine flow is taken from there -- particularly the idea of creating a random local file, hard linking a common file to the local file, and then checking the nlink status. Some ideologies were not complete (uncache mechanism, shared locking) and some coding was even incorrect (wrong stat index). File::NFSLock was written to be light, generic, and fast.

First, you don't need any locks for mailboxes on NFS, especially not for maildir mailboxes: Quoting the specification page https://cr.yp.to/proto/maildir.html:

Using maildir format

Why should I use maildir?

Two words: no locks. [...] The maildir format is reliable even over NFS.

(Emphasis in the original.)

Second, creating hardlinks does not work across filesystems. You can not create a hardlink on an NFS export to a file on a local filesystem. The trick might work if you create the hardlink on the NFS export to another file on the NFS export, but NFS may cache stat() information on the client, so it might not work. I don't know.

Maildir does not need locks, and it does not need hardlinks.

Also, this module has not been updated since November 2018, seven years ago. At that time, Windows 11 did not exist.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re: Is getting locks on files with NFS broken on CygPerl?