]> asedeno.scripts.mit.edu Git - linux.git/commit
ovl: hash non-dir by lower inode for fsnotify
authorAmir Goldstein <amir73il@gmail.com>
Sun, 4 Feb 2018 13:35:09 +0000 (15:35 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Fri, 16 Feb 2018 14:53:20 +0000 (15:53 +0100)
commit764baba80168ad3adafb521d2ab483ccbc49e344
treeef3d5d54c0732740a41f98604caee86c2e939be1
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2
ovl: hash non-dir by lower inode for fsnotify

Commit 31747eda41ef ("ovl: hash directory inodes for fsnotify")
fixed an issue of inotify watch on directory that stops getting
events after dropping dentry caches.

A similar issue exists for non-dir non-upper files, for example:

$ mkdir -p lower upper work merged
$ touch lower/foo
$ mount -t overlay -o
lowerdir=lower,workdir=work,upperdir=upper none merged
$ inotifywait merged/foo &
$ echo 2 > /proc/sys/vm/drop_caches
$ cat merged/foo

inotifywait doesn't get the OPEN event, because ovl_lookup() called
from 'cat' allocates a new overlay inode and does not reuse the
watched inode.

Fix this by hashing non-dir overlay inodes by lower real inode in
the following cases that were not hashed before this change:
 - A non-upper overlay mount
 - A lower non-hardlink when index=off

A helper ovl_hash_bylower() was added to put all the logic and
documentation about which real inode an overlay inode is hashed by
into one place.

The issue dates back to initial version of overlayfs, but this
patch depends on ovl_inode code that was introduced in kernel v4.13.

Cc: <stable@vger.kernel.org> #v4.13
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/inode.c