Skip to content

Commit ca9c726

Browse files
Andreas Gruenbachereparis
authored andcommitted
fsnotify: Infrastructure for per-mount watches
Per-mount watches allow groups to listen to fsnotify events on an entire mount. This patch simply adds and initializes the fields needed in the vfsmount struct to make this happen. Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent 0d48b7f commit ca9c726

5 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎fs/namespace.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ static inline void __mntput(struct vfsmount *mnt)
614614
* provides barriers, so count_mnt_writers() below is safe. AV
615615
*/
616616
WARN_ON(count_mnt_writers(mnt));
617+
fsnotify_vfsmount_delete(mnt);
617618
dput(mnt->mnt_root);
618619
free_vfsmnt(mnt);
619620
deactivate_super(sb);

‎fs/notify/fsnotify.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ void __fsnotify_inode_delete(struct inode *inode)
3636
}
3737
EXPORT_SYMBOL_GPL(__fsnotify_inode_delete);
3838

39+
void __fsnotify_vfsmount_delete(struct vfsmount *mnt)
40+
{
41+
fsnotify_clear_marks_by_mount(mnt);
42+
}
43+
3944
/*
4045
* Given an inode, first check if we care what happens to our children. Inotify
4146
* and dnotify both tell their parents about events. If we care about any event

‎fs/notify/fsnotify.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ extern void fsnotify_destroy_vfsmount_mark(struct fsnotify_mark *mark);
4242
extern void fsnotify_destroy_inode_mark(struct fsnotify_mark *mark);
4343
/* run the list of all marks associated with inode and flag them to be freed */
4444
extern void fsnotify_clear_marks_by_inode(struct inode *inode);
45+
/* run the list of all marks associated with vfsmount and flag them to be freed */
46+
extern void fsnotify_clear_marks_by_mount(struct vfsmount *mnt);
4547
/*
4648
* update the dentry->d_flags of all of inode's children to indicate if inode cares
4749
* about events that happen to its children.

‎include/linux/fsnotify.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ static inline void fsnotify_inode_delete(struct inode *inode)
9595
__fsnotify_inode_delete(inode);
9696
}
9797

98+
/*
99+
* fsnotify_vfsmount_delete - a vfsmount is being destroyed, clean up is needed
100+
*/
101+
static inline void fsnotify_vfsmount_delete(struct vfsmount *mnt)
102+
{
103+
__fsnotify_vfsmount_delete(mnt);
104+
}
105+
98106
/*
99107
* fsnotify_nameremove - a filename was removed from a directory
100108
*/

‎include/linux/fsnotify_backend.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ extern void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
282282
const char *name, u32 cookie);
283283
extern void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask);
284284
extern void __fsnotify_inode_delete(struct inode *inode);
285+
extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
285286
extern u32 fsnotify_get_cookie(void);
286287

287288
static inline int fsnotify_inode_watches_children(struct inode *inode)
@@ -402,6 +403,9 @@ static inline void __fsnotify_parent(struct path *path, struct dentry *dentry, _
402403
static inline void __fsnotify_inode_delete(struct inode *inode)
403404
{}
404405

406+
static inline void __fsnotify_vfsmount_delete(struct vfsmount *mnt)
407+
{}
408+
405409
static inline void __fsnotify_update_dcache_flags(struct dentry *dentry)
406410
{}
407411

0 commit comments

Comments
 (0)