Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fsnotify: move fsnotify_nameremove() hook out of d_delete()

d_delete() was piggy backed for the fsnotify_nameremove() hook when
in fact not all callers of d_delete() care about fsnotify events.

For all callers of d_delete() that may be interested in fsnotify events,
we made sure to call one of fsnotify_{unlink,rmdir}() hooks before
calling d_delete().

Now we can move the fsnotify_nameremove() call from d_delete() to the
fsnotify_{unlink,rmdir}() hooks.

Two explicit calls to fsnotify_nameremove() from nfs/afs sillyrename
are also removed. This will cause a change of behavior - nfs/afs will
NOT generate an fsnotify delete event when renaming over a positive
dentry. This change is desirable, because it is consistent with the
behavior of all other filesystems.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Amir Goldstein and committed by
Jan Kara
49246466 6146e78c

+2 -13
-5
fs/afs/dir_silly.c
··· 60 60 if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) 61 61 afs_edit_dir_add(dvnode, &new->d_name, 62 62 &vnode->fid, afs_edit_dir_for_silly_1); 63 - 64 - /* vfs_unlink and the like do not issue this when a file is 65 - * sillyrenamed, so do it here. 66 - */ 67 - fsnotify_nameremove(old, 0); 68 63 } 69 64 70 65 kfree(scb);
-2
fs/dcache.c
··· 2372 2372 void d_delete(struct dentry * dentry) 2373 2373 { 2374 2374 struct inode *inode = dentry->d_inode; 2375 - int isdir = d_is_dir(dentry); 2376 2375 2377 2376 spin_lock(&inode->i_lock); 2378 2377 spin_lock(&dentry->d_lock); ··· 2386 2387 spin_unlock(&dentry->d_lock); 2387 2388 spin_unlock(&inode->i_lock); 2388 2389 } 2389 - fsnotify_nameremove(dentry, isdir); 2390 2390 } 2391 2391 EXPORT_SYMBOL(d_delete); 2392 2392
-6
fs/nfs/unlink.c
··· 396 396 nfs_cancel_async_unlink(dentry); 397 397 return; 398 398 } 399 - 400 - /* 401 - * vfs_unlink and the like do not issue this when a file is 402 - * sillyrenamed, so do it here. 403 - */ 404 - fsnotify_nameremove(dentry, 0); 405 399 } 406 400 407 401 #define SILLYNAME_PREFIX ".nfs"
+2
include/linux/fsnotify.h
··· 199 199 WARN_ON_ONCE(d_is_negative(dentry)); 200 200 201 201 /* TODO: call fsnotify_dirent() */ 202 + fsnotify_nameremove(dentry, 0); 202 203 } 203 204 204 205 /* ··· 223 222 WARN_ON_ONCE(d_is_negative(dentry)); 224 223 225 224 /* TODO: call fsnotify_dirent() */ 225 + fsnotify_nameremove(dentry, 1); 226 226 } 227 227 228 228 /*