From 26dc3d2bff623768cbbd0c8053ddd6390fd828d2 Mon Sep 17 00:00:00 2001 From: Amir Goldstein Date: Tue, 21 Jul 2020 18:52:18 +0300 Subject: [PATCH] fsnotify: pass inode to fsnotify_parent() We can get inode by dereferenceing dentry->d_inode, but that may have performance impact in the fast path of non watched file. Kernel test robot reported a performance regression in concurrent open workload, so maybe that can fix it. Reported-by: kernel test robot Fixes: c738fbabb0ff ("fsnotify: fold fsnotify() call into fsnotify_parent()") Signed-off-by: Amir Goldstein --- include/linux/fsnotify.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 316c9b820517..d49e5318aad9 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -46,10 +46,9 @@ static inline void fsnotify_dirent(struct inode *dir, struct dentry *dentry, /* Notify this dentry's parent about a child's events. */ static inline int fsnotify_parent(struct dentry *dentry, __u32 mask, - const void *data, int data_type) + const void *data, int data_type, + struct inode *inode) { - struct inode *inode = d_inode(dentry); - if (S_ISDIR(inode->i_mode)) mask |= FS_ISDIR; @@ -68,7 +67,8 @@ static inline int fsnotify_parent(struct dentry *dentry, __u32 mask, */ static inline void fsnotify_dentry(struct dentry *dentry, __u32 mask) { - fsnotify_parent(dentry, mask, d_inode(dentry), FSNOTIFY_EVENT_INODE); + fsnotify_parent(dentry, mask, d_inode(dentry), FSNOTIFY_EVENT_INODE, + d_inode(dentry)); } static inline int fsnotify_file(struct file *file, __u32 mask) @@ -78,7 +78,8 @@ static inline int fsnotify_file(struct file *file, __u32 mask) if (file->f_mode & FMODE_NONOTIFY) return 0; - return fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH); + return fsnotify_parent(path->dentry, mask, path, FSNOTIFY_EVENT_PATH, + file_inode(file)); } /* Simple call site for access decisions */ -- 2.17.1