dCache / nfs4j

Pure Java NFSv3 and NFSv4.2 implementation
Other
234 stars 74 forks source link

Any plan to support inotify? #76

Open marxangels opened 5 years ago

marxangels commented 5 years ago

inotify with NFS

paulmillar commented 5 years ago

Short answer: no, because it's currently not possible and requires considerable work.

Longer answer: there are some big problems that would need to be solved.

First, inotify works in the Linux VFS layer. This means that the filesystem has no knowledge that a file or directory is being watched. If some code were to watch a directory within the mount-point then the linux kernel NFS client would be unaware of this. Fixing this is certainly possible; some ideas are already being explored for FUSE in the Fsnotify project; however, in general, this problem is a long way from being solved.

Second, (to the best of my knowledge) the NFS protocol currently does not provide support anything like the rich API of inotify. There's no concept of adding a watch or receiving inotify events. There are some useful concepts already within NFS 4 (e.g., callbacks) that I believe could be used to build an inotify-like protocol extension; however, there is currently no NFS extension that works out-of-the-box. The challenge is for that extension to provide platform agnostic notification that would work for different platforms (Linux, Windows, Mac, etc.) both as the client and as the server. Therefore, this NFS extension would very likely NOT be inotify, but hopefully something that provides broadly similar semantics.

Finally, even if the first and second problems are solved (both of which have remained unsolved for quite a while), there would need to be work done to update the Linux NFS client implementation so that it supported the NFS inotify extension, and supporting the Linux kernel's FS-level inotify.

Some other things to mention:

  1. dCache (a major project using nfs4j) does provides inotify support. This is only available via HTTP. dCache uses a (proprietary) REST API to manage the watches and Server-Sent Events (SSE) to deliver inotify events. Combined, this gives clients the equivalent functionality to inotify albeit with a somewhat non-standard transport.

  2. FAM is one cited solution to this problem. FAM provides its own network protocol, where the server (famd) accept watch requests for a client and relays the response. Apparently, the combination of famd and an NFS mount allows FAM clients to discover changes to the (remote) NFS filesystem. However, this solution is not ideal as it requires clients to link against FAM (i.e., the clients are not using inotify), and there are questions about the performance impact of FAM.