1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 290586523SEric Paris #ifndef __FS_NOTIFY_FSNOTIFY_H_ 390586523SEric Paris #define __FS_NOTIFY_FSNOTIFY_H_ 490586523SEric Paris 590586523SEric Paris #include <linux/list.h> 690586523SEric Paris #include <linux/fsnotify.h> 790586523SEric Paris #include <linux/srcu.h> 890586523SEric Paris #include <linux/types.h> 990586523SEric Paris 10925d1132SJan Kara #include "../mount.h" 11925d1132SJan Kara 1236f10f55SAmir Goldstein static inline struct inode *fsnotify_conn_inode( 1336f10f55SAmir Goldstein struct fsnotify_mark_connector *conn) 14b812a9f5SAmir Goldstein { 1536f10f55SAmir Goldstein return container_of(conn->obj, struct inode, i_fsnotify_marks); 16b812a9f5SAmir Goldstein } 17b812a9f5SAmir Goldstein 1836f10f55SAmir Goldstein static inline struct mount *fsnotify_conn_mount( 1936f10f55SAmir Goldstein struct fsnotify_mark_connector *conn) 20b812a9f5SAmir Goldstein { 2136f10f55SAmir Goldstein return container_of(conn->obj, struct mount, mnt_fsnotify_marks); 22b812a9f5SAmir Goldstein } 23b812a9f5SAmir Goldstein 24*1e6cb723SAmir Goldstein static inline struct super_block *fsnotify_conn_sb( 25*1e6cb723SAmir Goldstein struct fsnotify_mark_connector *conn) 26*1e6cb723SAmir Goldstein { 27*1e6cb723SAmir Goldstein return container_of(conn->obj, struct super_block, s_fsnotify_marks); 28*1e6cb723SAmir Goldstein } 29*1e6cb723SAmir Goldstein 30a2d8bc6cSEric Paris /* destroy all events sitting in this groups notification queue */ 31a2d8bc6cSEric Paris extern void fsnotify_flush_notify(struct fsnotify_group *group); 32a2d8bc6cSEric Paris 3375c1be48SEric Paris /* protects reads of inode and vfsmount marks list */ 3475c1be48SEric Paris extern struct srcu_struct fsnotify_mark_srcu; 3575c1be48SEric Paris 368edc6e16SJan Kara /* compare two groups for sorting of marks lists */ 378edc6e16SJan Kara extern int fsnotify_compare_groups(struct fsnotify_group *a, 388edc6e16SJan Kara struct fsnotify_group *b); 398edc6e16SJan Kara 409b6e5434SAmir Goldstein /* Destroy all marks attached to an object via connector */ 419b6e5434SAmir Goldstein extern void fsnotify_destroy_marks(fsnotify_connp_t *connp); 42925d1132SJan Kara /* run the list of all marks associated with inode and destroy them */ 43925d1132SJan Kara static inline void fsnotify_clear_marks_by_inode(struct inode *inode) 44925d1132SJan Kara { 4508991e83SJan Kara fsnotify_destroy_marks(&inode->i_fsnotify_marks); 46925d1132SJan Kara } 47925d1132SJan Kara /* run the list of all marks associated with vfsmount and destroy them */ 48925d1132SJan Kara static inline void fsnotify_clear_marks_by_mount(struct vfsmount *mnt) 49925d1132SJan Kara { 5008991e83SJan Kara fsnotify_destroy_marks(&real_mount(mnt)->mnt_fsnotify_marks); 51925d1132SJan Kara } 52*1e6cb723SAmir Goldstein /* run the list of all marks associated with sb and destroy them */ 53*1e6cb723SAmir Goldstein static inline void fsnotify_clear_marks_by_sb(struct super_block *sb) 54*1e6cb723SAmir Goldstein { 55*1e6cb723SAmir Goldstein fsnotify_destroy_marks(&sb->s_fsnotify_marks); 56*1e6cb723SAmir Goldstein } 57f09b04a0SJan Kara /* Wait until all marks queued for destruction are destroyed */ 58f09b04a0SJan Kara extern void fsnotify_wait_marks_destroyed(void); 5935e48176SJan Kara 60c28f7e56SEric Paris /* 61c28f7e56SEric Paris * update the dentry->d_flags of all of inode's children to indicate if inode cares 62c28f7e56SEric Paris * about events that happen to its children. 63c28f7e56SEric Paris */ 64c28f7e56SEric Paris extern void __fsnotify_update_child_dentry_flags(struct inode *inode); 65a2d8bc6cSEric Paris 66a2d8bc6cSEric Paris /* allocate and destroy and event holder to attach events to notification/access queues */ 67a2d8bc6cSEric Paris extern struct fsnotify_event_holder *fsnotify_alloc_event_holder(void); 68a2d8bc6cSEric Paris extern void fsnotify_destroy_event_holder(struct fsnotify_event_holder *holder); 69a2d8bc6cSEric Paris 7090586523SEric Paris #endif /* __FS_NOTIFY_FSNOTIFY_H_ */ 71