fsnotify: allow adding an inode mark without pinning inode
authorAmir Goldstein <amir73il@gmail.com>
Fri, 22 Apr 2022 12:03:22 +0000 (15:03 +0300)
committerJan Kara <jack@suse.cz>
Mon, 25 Apr 2022 12:42:45 +0000 (14:42 +0200)
commitc3638b5b13740fa31762d414bbce8b7a694e582a
treeb09af564485d7f9dd3b960747076c69a19356d4b
parentaabb45fdcb31f00f1e7cae2bce83e83474a87c03
fsnotify: allow adding an inode mark without pinning inode

fsnotify_add_mark() and variants implicitly take a reference on inode
when attaching a mark to an inode.

Make that behavior opt-out with the mark flag FSNOTIFY_MARK_FLAG_NO_IREF.

Instead of taking the inode reference when attaching connector to inode
and dropping the inode reference when detaching connector from inode,
take the inode reference on attach of the first mark that wants to hold
an inode reference and drop the inode reference on detach of the last
mark that wants to hold an inode reference.

Backends can "upgrade" an existing mark to take an inode reference, but
cannot "downgrade" a mark with inode reference to release the refernce.

This leaves the choice to the backend whether or not to pin the inode
when adding an inode mark.

This is intended to be used when adding a mark with ignored mask that is
used for optimization in cases where group can afford getting unneeded
events and reinstate the mark with ignored mask when inode is accessed
again after being evicted.

Link: https://lore.kernel.org/r/20220422120327.3459282-12-amir73il@gmail.com
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/notify/mark.c
include/linux/fsnotify_backend.h