We spent two weeks hunting an NFS bug in the Linux kernel (2018)
about.gitlab.com
about.gitlab.com
The NFS maintainer seems to agree that this was a bug worth fixing. But I think I'm missing something - doesn't the specification say that the observed behavior (the file handle having gone stale) is acceptable, based on this snippet:
> A filehandle may or may not become stale or expire on a rename. However, server implementors are strongly encouraged to attempt to keep file handles from becoming stale or expiring in this fashion.
So, is it more of a 'the specification isn't sufficient for real world usage' kind of fix, or was something actually broken?
And yes, this is an excellent writeup.
I think that sums up NFS reasonably well. “Let’s make the API connectionless and stateless; that simplifies things” is true, but implementing Unix semantics, where files can be opened or closed, file deletes change state, file deletes aren’t seen by open file handles, programs want to do record locking, etc. on top of it? Maybe not the best of ideas.
There’s a reason S3 isn’t a file system.
(See also The UNIX Haters Handbook chapter on the Nightmare File System)
But yes, being stateless has the advantage that the server won’t lose connections, open file state, etc. across client or server restarts.
That’s useful, but if you assume you have a file system (which NFS claims to be), and want to use those features, you’re asking for problems. NFS is aan example of “worse is better”.
There was a remote fs before NFS which closely mimicked Unix file system semantic (AT&T's RFS). There's a reason you don't read much about it.
NFS is in the category of works well enough, but the edge cases are a mile wide!
People sometimes (ignorantly and irresponsibly) recommend (or have recommended -- NFS is squarely in the legacy corner of technology) soft mounts in an attempt to deal with unreliable servers, i.e. prevent clients from 'hanging' if the server doesn't respond. The real solution is of course to fix the darn server / the network.
I hacked up a deliberately slow NFS server [1], but it's awkward to deploy, and I don't think it's representative of real-world, so it's not part of any automated suite.
To paraphrase Macbeth -
"Is this a GOTO I see before me?
Come, let me hold you.
I don’t have you but I can still see you. Fateful apparition, isn’t it possible to touch you as well as see you?
Or are you nothing more than a GOTO created by the mind, a hallucination from my fevered brain?
I can still see you, and you look as real as this other GOTO that I’m pulling out now ..."
The problem is the code forgot to check for a particular situation: https://marc.info/?l=linux-nfs&m=153807208928650&w=2
I think that can't be generalized to "The authorization scheme sucks" any more than if you run sshd on a public IP address and permit root logins with a password and pick a guessable password you can conclude that SSH's authorization scheme sucks. There's a number of stronger things you could do and they're perfectly normal.
Maybe it's because I'm used to password-based or key-based authentication methods and when I had met NFS I became scared of that host-based authentication.
Of course I agree that IP whitelisting is a good practice that solves and prevents many issues.
All of the options I looked in to would fail when a program expects to be able to set permissions on things in the remote directory.
r.e. old: nfsv4 is a different beast than nfs3;
r.e. secure: these things don't hold true with krb5 auth.
sftp gives you really good key based authentication and encryption over the network. I wouldn't trust NFS for anything other than a highly secure internal network.
https://wiki.debian.org/NFS/Kerberos
krb5p is pretty secure. You just need a Kerberos implementation. The alternative is to run NFS over Stunnel, which is what Amazon does for EFS.
One of the first things that come to my mind when I hear "networked filesystem" is the typical setup at most companies I worked at in the past (those with more than a dozen or so people; plus of course schools and university I attended), where you have log on authentication via LDAP/AD/... and the system would mount network shares with your user files, files from the teams/projects you were on, etc.
I would have a desktop PC in the office, but could also just walk over to the lab, login with the same credentials at a PC there and have all my files. Meeting rooms would also have permanently installed PCs and you wouldn't have to fidget with the projector connections/settings, you just log on and are good to go.
On top of that, none of those systems would be my personal property and I wouldn't take them home with me, or bother installing/updating software. Other people would be paid full time to make sure everything works and I have access to all the files and software I need (and only those I need). Sounds crazy, right?
I'm eager to hear your recommended redesign.
Scalability is a great point. With 13.0 we have added Gitaly clusters removing the dependency on NFS, whilst also improving high availability. Gitaly is the backend daemon for accessing Git repositories where GitLab communicates with.
https://about.gitlab.com/releases/2020/05/22/gitlab-13-0-rel...
NFS support in Gitaly has been deprecated and will be removed in 14.0 next year. https://about.gitlab.com/releases/2020/05/22/gitlab-13-0-rel...
There are environments and use cases for NFS which are being discussed in this epic: https://gitlab.com/groups/gitlab-org/-/epics/1489
Also you can avoid a SPOF in NFS with Isilon's commercial offering (which worked great in my experience, at least back when they were using an implementation based on FreeBSD's kernel NFS server), or potential Red Hat's HA setup.
Also, CephFS is an option too and avoids a SPOF by design. I've only run Ceph block storage but it's absolutely a real distributed system and works well.
You pretty much have NFSv4 and SMB.
I adapt. And if they're using NFS, I want to make sure I can use NFS too. That's why fixing this bug was important.
So I just nfs mounted my source tree and compiled on the remote machine.
I also tried cifs. compiles took like 3x the time.
There's also the fact that macOS, Linux and Windows all have official support for NFS while SMB is achieved through analysing and reverse engineering Windows' protocols. There's no stability guarantee from Microsoft that SAMBA will keep working with the next update of Windows 10 while the NFS standard does maintain a minimum level of compatibility.
I can't think of another way to share files over the network outside of NFS and SMB with cross-OS support. Perhaps you know a file sharing mechanism that has similar small file performance with similar OS support?
SMB2 protocol is documented here explicitly for interoperability purpose: https://docs.microsoft.com/en-us/openspecs/windows_protocols...
> There's no stability guarantee from Microsoft that SAMBA will keep working with the next update of Windows 10 while the NFS standard does maintain a minimum level of compatibility.
I don't think there is any difference between SMB and NFS in this regard. There is no guarantee that next version of Windows will work with any NFS implementation either
I use it a lot because the Linux kernel can mount it as rootfs during boot with little more than a few boot commend line flags. This IMO comes in very handy when working on embedded systems (at least when they have Ethernet and a sane boot loader).
My development setup looks pretty much like this: My workstation is connected to the board and has DHCP, DNS, TFTP & NFS servers running on that port. Outbound traffic from the board is routed across the workstation and possibly passed through tcpdump or Wireshark.
The boot loader on the board would get an IP from my box, then load the kernel & device tree from the TFTP server. The kernel would then do the DHCP dance again and mount the NFS rootfs from my box.
I can simply recompile the kernel, power cycle the board and have it boot into the new one with all the new/changed modules available in the rootfs; or recompile some user space software I'm working on, install it into the rootfs and have it available on the board immediately.
The only other options I can think of would be 9pfs and SMB. Support for SMB as rootfs was only quite recently and 9pfs would require some initrd trickery.
Sometimes NFS is your only option. When you have legacy applications which nobody is going to rewrite, and you need to scale some operations on a set of files over many nodes, NFS works. Its failure nodes are well documented, so you can plan for and work around them.
It's also supported by most vendors as the default networked filesystem. Whether you're using a desktop PC, a million dollar NAS, or cloud storage, it supports NFS.
It's also acceptable when time is of the essence and you just need to get something working now and don't have time to build something better. I rather like "good enough solutions" as a way to get teams "shipping", with an agreed-upon plan to replace it later.
But as someone who's used it for nearly 20 years, internally I start screaming and throwing things whenever someone suggests using it. Externally I propose redesigning for a more efficient solution :)
Only a person can beg the question, and then only if they are either very confused or are trying to deceive you.
(this was a quote from the Britannica)