11

Some time ago I noticed that the events reported by inotify are different when the file is saved to an NFS mount vs. a local file system.

Shouldn't the underlying VFS provide a uniform view of file operations?

The following is the trace of VIM saving a file in Debian 7.1 (Linux 3.2)

On an NFS mount:

wd=1 mask = 32 (IN_OPEN)
wd=1 mask = 16 (IN_CLOSE_NOWRITE)
wd=1 mask = 2048 (IN_MOVE_SELF)
wd=1 mask = 4 (IN_ATTRIB)
wd=1 mask = 1024 (IN_DELETE_SELF)
wd=1 mask = 32768 )

On a local file system

wd=1 mask = 32 (IN_OPEN)
wd=1 mask = 16 (IN_CLOSE_NOWRITE)
wd=1 mask = 2 (IN_MODIFY)
wd=1 mask = 32 (IN_OPEN)
wd=1 mask = 8 (IN_CLOSE_WRITE)
wd=1 mask = 4 (IN_ATTRIB)

Saving a file with EMACS also reveals different beahvior

On an NFS mount:

wd=1 mask = 32 (IN_OPEN)
wd=1 mask = 16 (IN_CLOSE_NOWRITE)
wd=1 mask = 2048 (IN_MOVE_SELF)

On a local file system:

wd=1 mask = 32 (IN_OPEN)
wd=1 mask = 16 (IN_CLOSE_NOWRITE)
wd=1 mask = 2 (IN_MODIFY)
wd=1 mask = 32 (IN_OPEN)
wd=1 mask = 2 (IN_MODIFY)
wd=1 mask = 8 (IN_CLOSE_WRITE)

These tests werer run with inotify-touch.c

1 Answer 1

4

inotify NFS support?

Looking around the net it would appear that inotify may support NFS but in a very limited fashion.

exhibit #1

The reason is explained in this StackOverflow Q&A titled: inotify with NFS.

excerpt from the accepted answer

inotify requires support from the kernel to work. When an application tracks a directory, it asks the kernel to inform it when those changes occur. When the change occurs, in addition to writing those changes to disk, the kernel also notifies the watching process.

On a remote NFS machine, the change is not visible to the kernel; it happens entirely remotely. NFS predates inotify and there is no network level support for it in NFS, or anything equivalent.

exhibit #2

Researching a bit more if you look in the inotify FAQ

Q: Can I watch sysfs (procfs, nfs...)?

Simply spoken: yes, but with some limitations. These limitations vary between kernel versions and tend to get smaller. Please read information about particular filesystems.

So is it supported?

I think ultimately what you're experiencing is that NFS does not provide an apples to apples equivalent of all the same features as the locally mounted filesystems.

For example from a nfs linux thread:

  • CIFS has notification capabilities built in (oplocks)
  • NFS provides "leases" for notification

The point here is that alternate filesystem such as CIFS and NFS offer very basic, if any support directly to inotify.

NFS v4 state

excerpt from IBM article on NFS v4 state

NFS version 4 provides a protocol for the client to establish or reestablish state, and associates ownership of subsequent server stateful operations to previously established states. To resolve the absent client problem, the NFS version 4 client must routinely refresh the state within the server-specified lease time. Upon lease time-out, the server may release resources for the client and make them available to other applications.

  • A client obtains the server-specified lease time-out attribute by issuing a getattr operation. getattr is not a stateful operation, thus it does not require prior state to be established. A getattr operation may precede a setclientid or setclientid_confirm operation.
  • Refer to the NFS server's leasetime site attribute for setting and tuning lease time periods. *
1
  • 3
    The OP appears to be seeing events on NFS, they're just different than the ones seen on local filesystem. The linked question and answer seem to indicate an absence of inotify events on NFS.
    – iruvar
    Jul 3, 2013 at 21:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .