February 1st, 2011

NFS: The Cobol of Filesystems.

So I broke down and downloaded the current RFC collection to my laptop because I keep disconnecting from the internet to avoid distraction, and then needing to reconnect because I need check some RFC. There are now over 5000 RFCs. Most of them seem either concerned with obsoleting each other, or proposing things nobody ever used and many of which nobody ever actually bothered to implement an example of. Sturgeon's Law applies to the IETF, go figure.

The NFS code is evil. The need for "struct nfs_fh" is conceptually disgusting. Two files with the same i_ino is conceptually disgusting. struct nfs_server starts with a struct nfs_client pointer, and struct nfs_client contains a list of superblock structures (cl_superblocks).

Backing up to that last bit: in include/linux/nfs_fs_sb.h there's a "struct nfs_server" which seems kind of important. (Its first entry is a pointer to struct nfs_client, and that has a linked list of struct nfs_server entries. This is horrible and incestuous, but that's a side issue.) Meanwhile, the function nfs_validate_mount_data also mentions nfs_server. This function's job is actually to fill out an nfs_parsed_mount_data structure (so it's really parse, not validate, although said structure gets _allocated_ elsewhere and passed in to this thing, just to keep the control flow fragmented and incomprehensible)... anyway, one of the fields it's filling out from struct nfs_parsed_mount_data is "nfs_server.address".

Note: struct nfs_server does not have an address field. The parsed->nfs_server entry is not a struct nfs_server. No, that's a locally defined anonymous struct in nfs_parsed_mount_data, which is in fs/nfs/internal.h. It's just _named_ nfs_server. As far as I can tell, none of this has anything to do with fs/nfsd (which is not a filesystem, it's the in-kernel nfs server).

So the NFS developers went out of their way to make sure that if you grep for "nfs_server" in the filesystem (client) code, it shows up a lot for purposes totally unrelated to each other. They went out of their way to sabotage grep.

When people talk about the quality of open source code, and all the review it gets, point them at NFS. And laugh.

I think I'm making progress. It's by PROCESS OF ELIMINATION, but there's a finite amount of this crap...