/* Given an inode, first check if we care what happens to our children. Inotify and dnotify both tell their parents about events. If we care about any event on a child we run all of our children and set a dentry flag saying that the parent cares. Thus when an event happens on a child it can quickly tell if if there is a need to find a parent and send the event to the parent.  */
void __fsnotify_update_child_dentry_flags(struct inode *inode)
/* Given an inode, first check if we care what happens to our children. Inotify and dnotify both tell their parents about events. If we care about any event on a child we run all of our children and set a dentry flag saying that the parent cares. Thus when an event happens on a child it can quickly tell if if there is a need to find a parent and send the event to the parent.  */
void __fsnotify_update_child_dentry_flags(struct inode *inode)
{
	struct dentry *alias;
	int watched;
	if (!S_ISDIR(inode->i_mode))
		return;
	watched = fsnotify_inode_watches_children(inode);
	spin_lock(&dcache_lock);
	list_for_each_entry(alias, &inode->i_dentry, d_alias) {
		struct dentry *child;
		list_for_each_entry(child, &alias->d_subdirs, d_u.d_child) {
			if (!child->d_inode)
				continue;
			spin_lock(&child->d_lock);
			if (watched)
				child->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED;
			else
				child->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED;
			spin_unlock(&child->d_lock);
		}
	}
	spin_unlock(&dcache_lock);
}