[PATCH] inotify delete race fix

The included patch fixes a problem where a inotify client would receive a
delete event before the file was actually deleted. The bug affects both
dnotify & inotify.

Signed-off-by: John McCutchan <ttb@tentacle.dhs.org>
Signed-off-by: Robert Love <rml@novell.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by John McCutchan and committed by Linus Torvalds e234f35c 3de11748

+8 -2
+8 -2
fs/namei.c
··· 1801 1801 } 1802 1802 up(&dentry->d_inode->i_sem); 1803 1803 if (!error) { 1804 - fsnotify_rmdir(dentry, dentry->d_inode, dir); 1805 1804 d_delete(dentry); 1805 + fsnotify_rmdir(dentry, dentry->d_inode, dir); 1806 1806 } 1807 1807 dput(dentry); 1808 1808 ··· 1874 1874 1875 1875 /* We don't d_delete() NFS sillyrenamed files--they still exist. */ 1876 1876 if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) { 1877 - fsnotify_unlink(dentry, dir); 1877 + #if defined(CONFIG_INOTIFY) || defined(CONFIG_DNOTIFY) 1878 + dget(dentry); 1878 1879 d_delete(dentry); 1880 + fsnotify_unlink(dentry, dir); 1881 + dput(dentry); 1882 + #else 1883 + d_delete(dentry); 1884 + #endif 1879 1885 } 1880 1886 1881 1887 return error;