dnotify: use fsnotify group lock helpers
authorAmir Goldstein <amir73il@gmail.com>
Fri, 22 Apr 2022 12:03:21 +0000 (15:03 +0300)
committerJan Kara <jack@suse.cz>
Mon, 25 Apr 2022 12:37:34 +0000 (14:37 +0200)
commitaabb45fdcb31f00f1e7cae2bce83e83474a87c03
tree04304237758daf38a68582bea664430e2a90bdf2
parentb8962a9d8cc2d8c93362e2f684091c79f702f6f3
dnotify: use fsnotify group lock helpers

Before commit 9542e6a643fc6 ("nfsd: Containerise filecache laundrette")
nfsd would close open files in direct reclaim context.  There is no
guarantee that others memory shrinkers don't do the same and no
guarantee that future shrinkers won't do that.

For example, if overlayfs implements inode cache of fscache would
keep open files to cached objects, inode shrinkers could end up closing
open files to underlying fs.

Direct reclaim from dnotify mark allocation context may try to close
open files that have dnotify marks of the same group and hit a deadlock
on mark_mutex.

Set the FSNOTIFY_GROUP_NOFS flag to prevent going into direct reclaim
from allocations under dnotify group lock and use the safe group lock
helpers.

Link: https://lore.kernel.org/r/20220422120327.3459282-11-amir73il@gmail.com
Suggested-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20220321112310.vpr7oxro2xkz5llh@quack3.lan/
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/notify/dnotify/dnotify.c