I never understood why Linux has to have the NFS server inside the kernel. There are a couple userspace servers but they don't seem widely used or maintained.
Performance, as a bonus they're now adding a kernel SMB server (that has already been exploited iirc).
No idea about NFS today, but an argument for SMB is that it apparently supports RDMA transfers and no idea if there's any "generic" interface good enough as sendfile that can be extracted yet.
It would probably be awkward to add userspace APIs to get access to the low-level mappings and metadata that an NFS server needs.
In particular, NFS filehandles are essentially inodes with a generation number, and it requires root to read a file via the inode number. Then you need generation numbers for each inode, which I think is not accessible in userspace even with root (I don't see st_gen in struct stat).
There are userspace nfsd implementations, Ganesha is probably the most fully-featured one these days and it works on several *nix systems.
File handles (unique identifiers for inodes that can be used to reopen a file later) have been exposed to userspace for a long time with name_to_handle_at(2) and open_by_handle_at(2) -- these were originally exposed precisely for userspace nfsd.
The topic of i_version semantics has been discussed recently[1,2]. The kernel's nfsd lies about filesystems that don't support i_version so it's not a hard requirement for a replacement, and as the articles I linked note you can retrieve i_generation via ioctl(FS_IOC_GETVERSION).
And it's important to note that most (if not all) of these are related to optimisations.
> Ganesha is probably the most fully-featured one these days and it works on
> several *nix systems.
Yes, including MacOS as a result of my contributions :)
I was using Ganesha at work because FUSE on macOS had been deprecated, and we were trying to serve the filesystem locally via NFS. We emulated filehandles with an LRU cache.
I know ganesha and tried to use it. However it is not straightforward to setup, in particular on a container, at least not with the little patience I had when I did it. In the end I used sshfs which was enough for my use case.
That is only if you require that what is seen through NFS matches the actual underlying file system. If you lift that restriction it becomes possible. After all, what a client sees is just bytes sent through TCP/UDP. The same goes for authentication and users. There is no reason to tie the served UIDs to UIDs in the server system and a userspace server could implement any arbitrary mapping.
Replies (3)
No idea about NFS today, but an argument for SMB is that it apparently supports RDMA transfers and no idea if there's any "generic" interface good enough as sendfile that can be extracted yet.
In particular, NFS filehandles are essentially inodes with a generation number, and it requires root to read a file via the inode number. Then you need generation numbers for each inode, which I think is not accessible in userspace even with root (I don't see st_gen in struct stat).
Replies (2)
File handles (unique identifiers for inodes that can be used to reopen a file later) have been exposed to userspace for a long time with name_to_handle_at(2) and open_by_handle_at(2) -- these were originally exposed precisely for userspace nfsd.
The topic of i_version semantics has been discussed recently[1,2]. The kernel's nfsd lies about filesystems that don't support i_version so it's not a hard requirement for a replacement, and as the articles I linked note you can retrieve i_generation via ioctl(FS_IOC_GETVERSION).
And it's important to note that most (if not all) of these are related to optimisations.
[1]: https://lwn.net/Articles/905931/ [2]: https://lwn.net/Articles/937247/
Replies (2)
I was using Ganesha at work because FUSE on macOS had been deprecated, and we were trying to serve the filesystem locally via NFS. We emulated filehandles with an LRU cache.