fsnotify: kill FSNOTIFY_EVENT_FILE
Some fsnotify operations send a struct file. This is more information than we technically need. We instead send a struct path in all cases instead of sometimes a path and sometimes a file. Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
Родитель
098cf2fc77
Коммит
72acc85442
|
@ -79,15 +79,15 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notify this dentry's parent about a child's events. */
|
/* Notify this dentry's parent about a child's events. */
|
||||||
void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
|
void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
|
||||||
{
|
{
|
||||||
struct dentry *parent;
|
struct dentry *parent;
|
||||||
struct inode *p_inode;
|
struct inode *p_inode;
|
||||||
bool send = false;
|
bool send = false;
|
||||||
bool should_update_children = false;
|
bool should_update_children = false;
|
||||||
|
|
||||||
if (file)
|
if (!dentry)
|
||||||
dentry = file->f_path.dentry;
|
dentry = path->dentry;
|
||||||
|
|
||||||
if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED))
|
if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED))
|
||||||
return;
|
return;
|
||||||
|
@ -119,8 +119,8 @@ void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
|
||||||
* specifies these are events which came from a child. */
|
* specifies these are events which came from a child. */
|
||||||
mask |= FS_EVENT_ON_CHILD;
|
mask |= FS_EVENT_ON_CHILD;
|
||||||
|
|
||||||
if (file)
|
if (path)
|
||||||
fsnotify(p_inode, mask, file, FSNOTIFY_EVENT_FILE,
|
fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
|
||||||
dentry->d_name.name, 0);
|
dentry->d_name.name, 0);
|
||||||
else
|
else
|
||||||
fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
|
fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
|
||||||
|
@ -194,8 +194,6 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const
|
||||||
|
|
||||||
if (data_is == FSNOTIFY_EVENT_PATH)
|
if (data_is == FSNOTIFY_EVENT_PATH)
|
||||||
mnt = ((struct path *)data)->mnt;
|
mnt = ((struct path *)data)->mnt;
|
||||||
else if (data_is == FSNOTIFY_EVENT_FILE)
|
|
||||||
mnt = ((struct file *)data)->f_path.mnt;
|
|
||||||
|
|
||||||
/* if this inode's directed listeners don't care and nothing on the vfsmount
|
/* if this inode's directed listeners don't care and nothing on the vfsmount
|
||||||
* listeners list cares, nothing to do */
|
* listeners list cares, nothing to do */
|
||||||
|
|
|
@ -390,15 +390,6 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
|
||||||
event->data_type = data_type;
|
event->data_type = data_type;
|
||||||
|
|
||||||
switch (data_type) {
|
switch (data_type) {
|
||||||
case FSNOTIFY_EVENT_FILE: {
|
|
||||||
struct file *file = data;
|
|
||||||
struct path *path = &file->f_path;
|
|
||||||
event->path.dentry = path->dentry;
|
|
||||||
event->path.mnt = path->mnt;
|
|
||||||
path_get(&event->path);
|
|
||||||
event->data_type = FSNOTIFY_EVENT_PATH;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FSNOTIFY_EVENT_PATH: {
|
case FSNOTIFY_EVENT_PATH: {
|
||||||
struct path *path = data;
|
struct path *path = data;
|
||||||
event->path.dentry = path->dentry;
|
event->path.dentry = path->dentry;
|
||||||
|
|
|
@ -26,14 +26,12 @@ static inline void fsnotify_d_instantiate(struct dentry *entry,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notify this dentry's parent about a child's events. */
|
/* Notify this dentry's parent about a child's events. */
|
||||||
static inline void fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
|
static inline void fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
|
||||||
{
|
{
|
||||||
BUG_ON(file && dentry);
|
if (!dentry)
|
||||||
|
dentry = path->dentry;
|
||||||
|
|
||||||
if (file)
|
__fsnotify_parent(path, dentry, mask);
|
||||||
dentry = file->f_path.dentry;
|
|
||||||
|
|
||||||
__fsnotify_parent(file, dentry, mask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -160,14 +158,15 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
|
||||||
*/
|
*/
|
||||||
static inline void fsnotify_access(struct file *file)
|
static inline void fsnotify_access(struct file *file)
|
||||||
{
|
{
|
||||||
struct inode *inode = file->f_path.dentry->d_inode;
|
struct path *path = &file->f_path;
|
||||||
|
struct inode *inode = path->dentry->d_inode;
|
||||||
__u32 mask = FS_ACCESS;
|
__u32 mask = FS_ACCESS;
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode))
|
if (S_ISDIR(inode->i_mode))
|
||||||
mask |= FS_IN_ISDIR;
|
mask |= FS_IN_ISDIR;
|
||||||
|
|
||||||
fsnotify_parent(file, NULL, mask);
|
fsnotify_parent(path, NULL, mask);
|
||||||
fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
|
fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -175,14 +174,15 @@ static inline void fsnotify_access(struct file *file)
|
||||||
*/
|
*/
|
||||||
static inline void fsnotify_modify(struct file *file)
|
static inline void fsnotify_modify(struct file *file)
|
||||||
{
|
{
|
||||||
struct inode *inode = file->f_path.dentry->d_inode;
|
struct path *path = &file->f_path;
|
||||||
|
struct inode *inode = path->dentry->d_inode;
|
||||||
__u32 mask = FS_MODIFY;
|
__u32 mask = FS_MODIFY;
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode))
|
if (S_ISDIR(inode->i_mode))
|
||||||
mask |= FS_IN_ISDIR;
|
mask |= FS_IN_ISDIR;
|
||||||
|
|
||||||
fsnotify_parent(file, NULL, mask);
|
fsnotify_parent(path, NULL, mask);
|
||||||
fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
|
fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -190,14 +190,15 @@ static inline void fsnotify_modify(struct file *file)
|
||||||
*/
|
*/
|
||||||
static inline void fsnotify_open(struct file *file)
|
static inline void fsnotify_open(struct file *file)
|
||||||
{
|
{
|
||||||
struct inode *inode = file->f_path.dentry->d_inode;
|
struct path *path = &file->f_path;
|
||||||
|
struct inode *inode = path->dentry->d_inode;
|
||||||
__u32 mask = FS_OPEN;
|
__u32 mask = FS_OPEN;
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode))
|
if (S_ISDIR(inode->i_mode))
|
||||||
mask |= FS_IN_ISDIR;
|
mask |= FS_IN_ISDIR;
|
||||||
|
|
||||||
fsnotify_parent(file, NULL, mask);
|
fsnotify_parent(path, NULL, mask);
|
||||||
fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
|
fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -205,6 +206,7 @@ static inline void fsnotify_open(struct file *file)
|
||||||
*/
|
*/
|
||||||
static inline void fsnotify_close(struct file *file)
|
static inline void fsnotify_close(struct file *file)
|
||||||
{
|
{
|
||||||
|
struct path *path = &file->f_path;
|
||||||
struct inode *inode = file->f_path.dentry->d_inode;
|
struct inode *inode = file->f_path.dentry->d_inode;
|
||||||
fmode_t mode = file->f_mode;
|
fmode_t mode = file->f_mode;
|
||||||
__u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE;
|
__u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE;
|
||||||
|
@ -212,8 +214,8 @@ static inline void fsnotify_close(struct file *file)
|
||||||
if (S_ISDIR(inode->i_mode))
|
if (S_ISDIR(inode->i_mode))
|
||||||
mask |= FS_IN_ISDIR;
|
mask |= FS_IN_ISDIR;
|
||||||
|
|
||||||
fsnotify_parent(file, NULL, mask);
|
fsnotify_parent(path, NULL, mask);
|
||||||
fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
|
fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -214,7 +214,6 @@ struct fsnotify_event {
|
||||||
#define FSNOTIFY_EVENT_NONE 0
|
#define FSNOTIFY_EVENT_NONE 0
|
||||||
#define FSNOTIFY_EVENT_PATH 1
|
#define FSNOTIFY_EVENT_PATH 1
|
||||||
#define FSNOTIFY_EVENT_INODE 2
|
#define FSNOTIFY_EVENT_INODE 2
|
||||||
#define FSNOTIFY_EVENT_FILE 3
|
|
||||||
int data_type; /* which of the above union we have */
|
int data_type; /* which of the above union we have */
|
||||||
atomic_t refcnt; /* how many groups still are using/need to send this event */
|
atomic_t refcnt; /* how many groups still are using/need to send this event */
|
||||||
__u32 mask; /* the type of access, bitwise OR for FS_* event types */
|
__u32 mask; /* the type of access, bitwise OR for FS_* event types */
|
||||||
|
@ -280,7 +279,7 @@ struct fsnotify_mark_entry {
|
||||||
/* main fsnotify call to send events */
|
/* main fsnotify call to send events */
|
||||||
extern void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
|
extern void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
|
||||||
const char *name, u32 cookie);
|
const char *name, u32 cookie);
|
||||||
extern void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask);
|
extern void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask);
|
||||||
extern void __fsnotify_inode_delete(struct inode *inode);
|
extern void __fsnotify_inode_delete(struct inode *inode);
|
||||||
extern u32 fsnotify_get_cookie(void);
|
extern u32 fsnotify_get_cookie(void);
|
||||||
|
|
||||||
|
@ -393,7 +392,7 @@ static inline void fsnotify(struct inode *to_tell, __u32 mask, void *data, int d
|
||||||
const char *name, u32 cookie)
|
const char *name, u32 cookie)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
static inline void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask)
|
static inline void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
static inline void __fsnotify_inode_delete(struct inode *inode)
|
static inline void __fsnotify_inode_delete(struct inode *inode)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче