fsnotify: tree-watching support
Subsystems (3)
PATCH 1/3 fsnotify: tree-watching support
Add tree-watching support to fsnotify.
Hope mail works now...
--- fs/debugfs/inode.c | 8 - fs/namei.c | 8 - fs/notify/fsnotify.c | 188 +++++++++++++++++++++++------ fs/notify/fsnotify.h | 1 fs/notify/inode_mark.c | 46 ++++++- include/linux/dcache.h | 3 include/linux/fsnotify.h | 55 +++++--- include/linux/fsnotify_backend.h | 51 +++++-- 8 files changed, 279 insertions(+), 81 deletions(-)
fs/debugfs/inode.c +5 -3
@@ -472,6 +472,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,int error;struct dentry *dentry =NULL , *trap;const char *old_name; +int old_len; trap =lock_rename (new_dir, old_dir);/* Source or destination directories don't exist? */
@@ -487,6 +488,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, goto exit; old_name =fsnotify_oldname_init (old_dentry->d_name.name); + old_len = old_dentry->d_name.len; error =simple_rename (old_dir->d_inode, old_dentry, new_dir->d_inode, dentry);
@@ -495,9 +497,9 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, goto exit; }d_move (old_dentry, dentry); -fsnotify_move (old_dir->d_inode, new_dir->d_inode, old_name, - old_dentry->d_name.name,S_ISDIR (old_dentry->d_inode->i_mode), -NULL , old_dentry); +fsnotify_move (old_dir->d_inode, old_name, old_len, + new_dir->d_inode, old_dentry->d_name.name, old_dentry->d_name.len, +S_ISDIR (old_dentry->d_inode->i_mode),NULL , old_dentry);fsnotify_oldname_free (old_name);unlock_rename (new_dir, old_dir);dput (dentry);
fs/namei.c +6 -2
@@ -2634,6 +2634,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,int error;int is_dir =S_ISDIR (old_dentry->d_inode->i_mode);const char *old_name; +int old_len;if (old_dentry->d_inode == new_dentry->d_inode)return 0 ;
@@ -2656,6 +2657,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,vfs_dq_init (new_dir); old_name =fsnotify_oldname_init (old_dentry->d_name.name); + old_len = old_dentry->d_name.len;if (is_dir) error =vfs_rename_dir (old_dir,old_dentry,new_dir,new_dentry);
@@ -2663,8 +2665,10 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, error =vfs_rename_other (old_dir,old_dentry,new_dir,new_dentry);if (!error) {const char *new_name = old_dentry->d_name.name; -fsnotify_move (old_dir, new_dir, old_name, new_name, is_dir, - new_dentry->d_inode, old_dentry); +int new_len = old_dentry->d_name.len; +fsnotify_move (old_dir, old_name, old_len, + new_dir, new_name, new_len, + is_dir, new_dentry->d_inode, old_dentry); }fsnotify_oldname_free (old_name);
fs/notify/fsnotify.c +150 -38
220 lines not on this page · raw message
fs/notify/fsnotify.h +1 -0
@@ -26,6 +26,7 @@ extern void fsnotify_clear_marks_by_inode(struct inode *inode);* about events that happen to its children. */ extern void __fsnotify_update_child_dentry_flags (struct inode *inode); +/* same here for tree watches */ /* allocate and destroy and event holder to attach events to notification/access queues */ extern struct fsnotify_event_holder *fsnotify_alloc_event_holder (void );
fs/notify/inode_mark.c +40 -6
89 lines not on this page · raw message
include/linux/dcache.h +2 -1
@@ -184,7 +184,8 @@ d_iput: no no no yes#define DCACHE_COOKIE 0x0040/* For use by dcookie subsystem */ -#define DCACHE_FSNOTIFY_PARENT_WATCHED 0x0080/* Parent inode is watched by some fsnotify listener */ +#define DCACHE_FSNOTIFY_PARENT_WATCHED 0x0080/* Parent inode is watched by some fsnotify listener */ +#define DCACHE_FSNOTIFY_ANCESTOR_WATCHED 0x0100/* Ancestor inode is watched by some tree-watching fsnotify listener */ extern spinlock_t dcache_lock;extern seqlock_t rename_lock;
include/linux/fsnotify.h +38 -17
155 lines not on this page · raw message
include/linux/fsnotify_backend.h +37 -14
94 lines not on this page · raw message
Quoted 2 lines · Joris Dolderer
Add tree-watching support to fsnotify.
Hope mail works now...
Yes, much better, thanks.
The following review just concerns documentation...
Quoted 17 lines
Signed-off-by Joris Dolderer <[email protected]>--- fs/debugfs/inode.c | 8 - fs/namei.c | 8 - fs/notify/fsnotify.c | 188 +++++++++++++++++++++++------ fs/notify/fsnotify.h | 1 fs/notify/inode_mark.c | 46 ++++++- include/linux/dcache.h | 3 include/linux/fsnotify.h | 55 +++++--- include/linux/fsnotify_backend.h | 51 +++++-- 8 files changed, 279 insertions(+), 81 deletions(-)fs/notify/fsnotify.c +0
-0
[snip]
Quoted 14 lines
fs/notify/fsnotify.c +13
-0+/* Notify this dentry's ancestors about a child's events. */ +void __fsnotify_ancestors (struct dentry *dentry,__u32 mask) +{ +if (dentry->d_flags &DCACHE_FSNOTIFY_PARENT_WATCHED ) { +struct dentry *parent; +struct inode *p_inode; +bool should_update_children = false; +bool send = false; + +spin_lock (&dentry->d_lock); + + parent = dentry->d_parent; + p_inode = parent->d_inode;
fs/notify/fsnotify.c void __fsnotify_update_child_dentry_flags(struct inode *inode) · line 153
Quoted 10 lines
fs/notify/fsnotify.c +8
-2-if (fsnotify_inode_watches_children (p_inode)) { -if (p_inode->i_fsnotify_mask & mask) { +if (fsnotify_inode_watches_children (p_inode)) { +if (p_inode->i_fsnotify_mask & mask) { +dget (parent); + send = true; + } + }else { +/* +* The parent doesn't care about events on it's children but
its
(yes, it's just moved, but please correct it)
("it's" means "it is", not possessive)
Quoted 8 lines
fs/notify/fsnotify.c +5
-1+* at least one child thought it did. We need to run all the +* children and update their d_flags to let them know p_inode +* doesn't care about them any more. +*/ dget (parent); - send = true; + should_update_children = true; }
[snip]
fs/notify/fsnotify.c void __fsnotify_update_child_dentry_flags(struct inode *inode) · line 187
Quoted 9 lines
fs/notify/fsnotify.c +9
-0+} +EXPORT_SYMBOL_GPL (__fsnotify_ancestors); + +/* +* notify tree-watching ancestors +* @dentry: The dentry the walkup should start with +* @file_name: The string that should be appended to this dentries' path +* @file_len: The length of this string +*/
Please use kernel-doc notation for this and other exported symbols. See Documentation/kernel-doc-nano-HOWTO.txt for details, or ask me if you have questions about it.
E.g.:
/**
* fsnotify_far_ancestors - notify tree-watching ancestors
* @dentry: The dentry the walkup should start with
* @file_name: The string that should be appended to this dentries' path
* @file_len: The length of this string
* @mask: <description>
*/
Quoted 2 lines
fs/notify/fsnotify.c +2
-0+void fsnotify_far_ancestors (struct dentry *dentry,const unsigned char *file_name,int file_len,__u32 mask) +{
...
Quoted 12 lines
}
fs/notify/fsnotify.c +1
-1-EXPORT_SYMBOL_GPL (__fsnotify_parent); +EXPORT_SYMBOL_GPL (fsnotify_far_ancestors);/* * This is the main call to fsnotify. The VFS calls into hook specific functions fs/notify/inode_mark.c +0
-0
fs/notify/inode_mark.c void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry) · line 224
Quoted 9 lines
fs/notify/inode_mark.c +1
-0@@ -195,14 +216,16 @@ void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry)/* * __fsnotify_update_child_dentry_flags(inode); +* or __fsnotify_update_descents; * * I really want to call that, but we can't, we have no idea if the inode * still exists the second we drop the entry->lock. * * The next time an event arrive to this inode from one of it's children
arrives its
fs/notify/inode_mark.c void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry) · line 225
Quoted 4 lines
fs/notify/inode_mark.c +1
-3-* __fsnotify_parent will see that the inode doesn't care about it's -* children and will update all of these flags then. So really this -* is just a lazy update (and could be a perf win...) +* __fsnotify_ancestors resp. fsnotify_far_ancestors will see that the
What is "resp." ?
fs/notify/inode_mark.c void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry) · line 226
Quoted 1 line
fs/notify/inode_mark.c +1
-0+* inode doesn't care about it's children and will update all of these
its
Quoted 8 lines
fs/notify/inode_mark.c +2
-0+* flags then. So really this is just a lazy update (and could be a +* perf win...) */ include/linux/fsnotify_backend.h +0
-0
[snip]
include/linux/fsnotify_backend.h struct fsnotify_mark_entry { · line 271
Quoted 8 lines
include/linux/fsnotify_backend.h +3
-3-static inline int fsnotify_inode_watches_children (struct inode *inode) +static inline bool fsnotify_inode_watches_something (struct inode *inode,u32 what) { -/* FS_EVENT_ON_CHILD is set if the inode may care */ -if (!(inode->i_fsnotify_mask &FS_EVENT_ON_CHILD )) +/* what is set if the inode may care */ +if (!(inode->i_fsnotify_mask & what))return 0 ;
return false;
Quoted 4 lines
include/linux/fsnotify_backend.h +0
-0/* this inode might care about child events, does it care about the * specific set of events that can happen on a child? */ return inode->i_fsnotify_mask &FS_EVENTS_POSS_ON_CHILD ; }
Signature · 1 line
~Randy
Shall I, now, resubmit immediately or wait for other reviews?
Quoted 162 lines · On Sat, 13 Feb 2010 11:12:15 -0800 Randy Dunlap <[email protected]> wrote:
Quoted 2 lines · Joris Dolderer
Add tree-watching support to fsnotify.
Hope mail works now...Yes, much better, thanks.
The following review just concerns documentation...
Quoted 17 lines
Signed-off-by Joris Dolderer <[email protected]>--- fs/debugfs/inode.c | 8 - fs/namei.c | 8 - fs/notify/fsnotify.c | 188 +++++++++++++++++++++++------ fs/notify/fsnotify.h | 1 fs/notify/inode_mark.c | 46 ++++++- include/linux/dcache.h | 3 include/linux/fsnotify.h | 55 +++++--- include/linux/fsnotify_backend.h | 51 +++++-- 8 files changed, 279 insertions(+), 81 deletions(-)fs/notify/fsnotify.c +0
-0[snip]
Quoted 14 lines
fs/notify/fsnotify.c +13
-0+/* Notify this dentry's ancestors about a child's events. */ +void __fsnotify_ancestors (struct dentry *dentry,__u32 mask) +{ +if (dentry->d_flags &DCACHE_FSNOTIFY_PARENT_WATCHED ) { +struct dentry *parent; +struct inode *p_inode; +bool should_update_children = false; +bool send = false; + +spin_lock (&dentry->d_lock); + + parent = dentry->d_parent; + p_inode = parent->d_inode;fs/notify/fsnotify.c void __fsnotify_update_child_dentry_flags(struct inode *inode) · line 153
Quoted 10 lines
fs/notify/fsnotify.c +8
-2-if (fsnotify_inode_watches_children (p_inode)) { -if (p_inode->i_fsnotify_mask & mask) { +if (fsnotify_inode_watches_children (p_inode)) { +if (p_inode->i_fsnotify_mask & mask) { +dget (parent); + send = true; + } + }else { +/* +* The parent doesn't care about events on it's children but its
(yes, it's just moved, but please correct it)
("it's" means "it is", not possessive)Quoted 8 lines
fs/notify/fsnotify.c +5
-1+* at least one child thought it did. We need to run all the +* children and update their d_flags to let them know p_inode +* doesn't care about them any more. +*/ dget (parent); - send = true; + should_update_children = true; }[snip]
fs/notify/fsnotify.c void __fsnotify_update_child_dentry_flags(struct inode *inode) · line 187
Quoted 9 lines
fs/notify/fsnotify.c +9
-0+} +EXPORT_SYMBOL_GPL (__fsnotify_ancestors); + +/* +* notify tree-watching ancestors +* @dentry: The dentry the walkup should start with +* @file_name: The string that should be appended to this dentries' path +* @file_len: The length of this string +*/ Please use kernel-doc notation for this and other exported symbols. See
Documentation/kernel-doc-nano-HOWTO.txtfor details, or ask me if you have questions about it.E.g.:
/**
*fsnotify_far_ancestors- notify tree-watching ancestors
* @dentry: The dentry the walkup should start with
* @file_name: The string that should be appended to this dentries' path
* @file_len: The length of this string
* @mask: <description>
*/Quoted 2 lines
fs/notify/fsnotify.c +2
-0+void fsnotify_far_ancestors (struct dentry *dentry,const unsigned char *file_name,int file_len,__u32 mask) +{...
Quoted 12 lines
}
fs/notify/fsnotify.c +1
-1-EXPORT_SYMBOL_GPL (__fsnotify_parent); +EXPORT_SYMBOL_GPL (fsnotify_far_ancestors);/* * This is the main call to fsnotify. The VFS calls into hook specific functions fs/notify/inode_mark.c +0
-0fs/notify/inode_mark.c void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry) · line 224
Quoted 9 lines
fs/notify/inode_mark.c +1
-0@@ -195,14 +216,16 @@ void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry)/* * __fsnotify_update_child_dentry_flags(inode); +* or __fsnotify_update_descents; * * I really want to call that, but we can't, we have no idea if the inode * still exists the second we drop the entry->lock. * * The next time an event arrive to this inode from one of it's children arrives its
fs/notify/inode_mark.c void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry) · line 225
Quoted 4 lines
fs/notify/inode_mark.c +1
-3-* __fsnotify_parent will see that the inode doesn't care about it's -* children and will update all of these flags then. So really this -* is just a lazy update (and could be a perf win...) +* __fsnotify_ancestors resp. fsnotify_far_ancestors will see that the What is "resp." ?
fs/notify/inode_mark.c void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry) · line 226
Quoted 1 line
fs/notify/inode_mark.c +1
-0+* inode doesn't care about it's children and will update all of these its
Quoted 8 lines
fs/notify/inode_mark.c +2
-0+* flags then. So really this is just a lazy update (and could be a +* perf win...) */ include/linux/fsnotify_backend.h +0
-0[snip]
include/linux/fsnotify_backend.h struct fsnotify_mark_entry { · line 271
Quoted 8 lines
include/linux/fsnotify_backend.h +3
-3-static inline int fsnotify_inode_watches_children (struct inode *inode) +static inline bool fsnotify_inode_watches_something (struct inode *inode,u32 what) { -/* FS_EVENT_ON_CHILD is set if the inode may care */ -if (!(inode->i_fsnotify_mask &FS_EVENT_ON_CHILD )) +/* what is set if the inode may care */ +if (!(inode->i_fsnotify_mask & what))return 0 ;return false;Quoted 4 lines
include/linux/fsnotify_backend.h +0
-0/* this inode might care about child events, does it care about the * specific set of events that can happen on a child? */ return inode->i_fsnotify_mask &FS_EVENTS_POSS_ON_CHILD ; }Signature · 1 line
~Randy
Quoted 1 line · Joris Dolderer
Shall I, now, resubmit immediately or wait for other reviews?
I would wait 2-3 days for other reviews.
Signature · 1 line
~Randy