mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
fsnotify: pass dentry instead of inode data
Define a new data type to pass for event - FSNOTIFY_EVENT_DENTRY. Use it to pass the dentry instead of it's ->d_inode where available. This is needed in preparation to the refactor to retrieve the super block from the data field. In some cases (i.e. mkdir in kernfs), the data inode comes from a negative dentry, such that no super block information would be available. By receiving the dentry itself, instead of the inode, fsnotify can derive the super block even on these cases. Link: https://lore.kernel.org/r/20211025192746.66445-3-krisman@collabora.com Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Amir Goldstein <amir73il@gmail.com> [Expand explanation in commit message] Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
9baf93d68b
commit
fd5a3ff49a
2 changed files with 18 additions and 3 deletions
|
@ -248,6 +248,7 @@ enum fsnotify_data_type {
|
|||
FSNOTIFY_EVENT_NONE,
|
||||
FSNOTIFY_EVENT_PATH,
|
||||
FSNOTIFY_EVENT_INODE,
|
||||
FSNOTIFY_EVENT_DENTRY,
|
||||
};
|
||||
|
||||
static inline struct inode *fsnotify_data_inode(const void *data, int data_type)
|
||||
|
@ -255,6 +256,8 @@ static inline struct inode *fsnotify_data_inode(const void *data, int data_type)
|
|||
switch (data_type) {
|
||||
case FSNOTIFY_EVENT_INODE:
|
||||
return (struct inode *)data;
|
||||
case FSNOTIFY_EVENT_DENTRY:
|
||||
return d_inode(data);
|
||||
case FSNOTIFY_EVENT_PATH:
|
||||
return d_inode(((const struct path *)data)->dentry);
|
||||
default:
|
||||
|
@ -262,6 +265,19 @@ static inline struct inode *fsnotify_data_inode(const void *data, int data_type)
|
|||
}
|
||||
}
|
||||
|
||||
static inline struct dentry *fsnotify_data_dentry(const void *data, int data_type)
|
||||
{
|
||||
switch (data_type) {
|
||||
case FSNOTIFY_EVENT_DENTRY:
|
||||
/* Non const is needed for dget() */
|
||||
return (struct dentry *)data;
|
||||
case FSNOTIFY_EVENT_PATH:
|
||||
return ((const struct path *)data)->dentry;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline const struct path *fsnotify_data_path(const void *data,
|
||||
int data_type)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue