static inline void fsnotify_dirent(struct inode *dir, struct dentry *dentry,
                                   __u32 mask)
 {
-       fsnotify_name(mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
-                     dir, &dentry->d_name, 0);
+       fsnotify_name(mask, dentry, FSNOTIFY_EVENT_DENTRY, dir, &dentry->d_name, 0);
 }
 
 static inline void fsnotify_inode(struct inode *inode, __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, dentry, FSNOTIFY_EVENT_DENTRY);
 }
 
 static inline int fsnotify_file(struct file *file, __u32 mask)
 
        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)
        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:
        }
 }
 
+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)
 {