[PATCH] Clean up inotify delete race fix

This avoids the whole #ifdef mess by just getting a copy of
dentry->d_inode before d_delete is called - that makes the codepaths the
same for the INOTIFY/DNOTIFY cases as for the regular no-notify case.
I've been running this under a Gnome session for the last 10 minutes.
Inotify is being used extensively.

Signed-off-by: John McCutchan <ttb@tentacle.dhs.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by John McCutchan and committed by Linus Torvalds 0c3dba15 f10eff26

+3 -10
+2 -7
fs/namei.c
··· 1874 1875 /* We don't d_delete() NFS sillyrenamed files--they still exist. */ 1876 if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) { 1877 - #if defined(CONFIG_INOTIFY) || defined(CONFIG_DNOTIFY) 1878 - dget(dentry); 1879 d_delete(dentry); 1880 - fsnotify_unlink(dentry, dir); 1881 - dput(dentry); 1882 - #else 1883 - d_delete(dentry); 1884 - #endif 1885 } 1886 1887 return error;
··· 1874 1875 /* We don't d_delete() NFS sillyrenamed files--they still exist. */ 1876 if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) { 1877 + struct inode *inode = dentry->d_inode; 1878 d_delete(dentry); 1879 + fsnotify_unlink(dentry, inode, dir); 1880 } 1881 1882 return error;
+1 -3
include/linux/fsnotify.h
··· 46 /* 47 * fsnotify_unlink - file was unlinked 48 */ 49 - static inline void fsnotify_unlink(struct dentry *dentry, struct inode *dir) 50 { 51 - struct inode *inode = dentry->d_inode; 52 - 53 inode_dir_notify(dir, DN_DELETE); 54 inotify_inode_queue_event(dir, IN_DELETE, 0, dentry->d_name.name); 55 inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL);
··· 46 /* 47 * fsnotify_unlink - file was unlinked 48 */ 49 + static inline void fsnotify_unlink(struct dentry *dentry, struct inode *inode, struct inode *dir) 50 { 51 inode_dir_notify(dir, DN_DELETE); 52 inotify_inode_queue_event(dir, IN_DELETE, 0, dentry->d_name.name); 53 inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL);