xref: /openbmc/linux/fs/notify/fsnotify.h (revision 35e481761cdc688dbee0ef552a13f49af8eba6cc)
190586523SEric Paris #ifndef __FS_NOTIFY_FSNOTIFY_H_
290586523SEric Paris #define __FS_NOTIFY_FSNOTIFY_H_
390586523SEric Paris 
490586523SEric Paris #include <linux/list.h>
590586523SEric Paris #include <linux/fsnotify.h>
690586523SEric Paris #include <linux/srcu.h>
790586523SEric Paris #include <linux/types.h>
890586523SEric Paris 
9925d1132SJan Kara #include "../mount.h"
10925d1132SJan Kara 
11a2d8bc6cSEric Paris /* destroy all events sitting in this groups notification queue */
12a2d8bc6cSEric Paris extern void fsnotify_flush_notify(struct fsnotify_group *group);
13a2d8bc6cSEric Paris 
1475c1be48SEric Paris /* protects reads of inode and vfsmount marks list */
1575c1be48SEric Paris extern struct srcu_struct fsnotify_mark_srcu;
1675c1be48SEric Paris 
170809ab69SJan Kara /* Calculate mask of events for a list of marks */
180809ab69SJan Kara extern u32 fsnotify_recalc_mask(struct hlist_head *head);
190809ab69SJan Kara 
208edc6e16SJan Kara /* compare two groups for sorting of marks lists */
218edc6e16SJan Kara extern int fsnotify_compare_groups(struct fsnotify_group *a,
228edc6e16SJan Kara 				   struct fsnotify_group *b);
238edc6e16SJan Kara 
2490b1e7a5SEric Paris extern void fsnotify_set_inode_mark_mask_locked(struct fsnotify_mark *fsn_mark,
2590b1e7a5SEric Paris 						__u32 mask);
260809ab69SJan Kara /* Add mark to a proper place in mark list */
270809ab69SJan Kara extern int fsnotify_add_mark_list(struct hlist_head *head,
280809ab69SJan Kara 				  struct fsnotify_mark *mark,
290809ab69SJan Kara 				  int allow_dups);
305444e298SEric Paris /* add a mark to an inode */
315444e298SEric Paris extern int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
325444e298SEric Paris 				   struct fsnotify_group *group, struct inode *inode,
335444e298SEric Paris 				   int allow_dups);
340d48b7f0SEric Paris /* add a mark to a vfsmount */
350d48b7f0SEric Paris extern int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark,
360d48b7f0SEric Paris 				      struct fsnotify_group *group, struct vfsmount *mnt,
370d48b7f0SEric Paris 				      int allow_dups);
385444e298SEric Paris 
390d48b7f0SEric Paris /* vfsmount specific destruction of a mark */
400d48b7f0SEric Paris extern void fsnotify_destroy_vfsmount_mark(struct fsnotify_mark *mark);
415444e298SEric Paris /* inode specific destruction of a mark */
425444e298SEric Paris extern void fsnotify_destroy_inode_mark(struct fsnotify_mark *mark);
430809ab69SJan Kara /* Find mark belonging to given group in the list of marks */
440809ab69SJan Kara extern struct fsnotify_mark *fsnotify_find_mark(struct hlist_head *head,
450809ab69SJan Kara 						struct fsnotify_group *group);
46925d1132SJan Kara /* Destroy all marks in the given list protected by 'lock' */
47925d1132SJan Kara extern void fsnotify_destroy_marks(struct hlist_head *head, spinlock_t *lock);
48925d1132SJan Kara /* run the list of all marks associated with inode and destroy them */
49925d1132SJan Kara static inline void fsnotify_clear_marks_by_inode(struct inode *inode)
50925d1132SJan Kara {
51925d1132SJan Kara 	fsnotify_destroy_marks(&inode->i_fsnotify_marks, &inode->i_lock);
52925d1132SJan Kara }
53925d1132SJan Kara /* run the list of all marks associated with vfsmount and destroy them */
54925d1132SJan Kara static inline void fsnotify_clear_marks_by_mount(struct vfsmount *mnt)
55925d1132SJan Kara {
56925d1132SJan Kara 	fsnotify_destroy_marks(&real_mount(mnt)->mnt_fsnotify_marks,
57925d1132SJan Kara 			       &mnt->mnt_root->d_lock);
58925d1132SJan Kara }
59*35e48176SJan Kara /* prepare for freeing all marks associated with given group */
60*35e48176SJan Kara extern void fsnotify_detach_group_marks(struct fsnotify_group *group);
61*35e48176SJan Kara /*
62*35e48176SJan Kara  * wait for fsnotify_mark_srcu period to end and free all marks in destroy_list
63*35e48176SJan Kara  */
64*35e48176SJan Kara extern void fsnotify_mark_destroy_list(void);
65*35e48176SJan Kara 
66c28f7e56SEric Paris /*
67c28f7e56SEric Paris  * update the dentry->d_flags of all of inode's children to indicate if inode cares
68c28f7e56SEric Paris  * about events that happen to its children.
69c28f7e56SEric Paris  */
70c28f7e56SEric Paris extern void __fsnotify_update_child_dentry_flags(struct inode *inode);
71a2d8bc6cSEric Paris 
72a2d8bc6cSEric Paris /* allocate and destroy and event holder to attach events to notification/access queues */
73a2d8bc6cSEric Paris extern struct fsnotify_event_holder *fsnotify_alloc_event_holder(void);
74a2d8bc6cSEric Paris extern void fsnotify_destroy_event_holder(struct fsnotify_event_holder *holder);
75a2d8bc6cSEric Paris 
7690586523SEric Paris #endif	/* __FS_NOTIFY_FSNOTIFY_H_ */
77