nfs: emit a fsnotify_nameremove call in sillyrename codepath
Subsystems (2)
PATCH 1/1 nfs: emit a fsnotify_nameremove call in sillyrename codepath
If a file is sillyrenamed, then the generic vfs_unlink code will skip emitting fsnotify events for it.
This patch has the sillyrename code do that instead.
In truth this is a little bit odd since we aren't actually removing the dentry per-se, but renaming it. Still, this is probably the right thing to do since it's what userland apps expect to see when an unlink() occurs or some file is renamed on top of the dentry.
--- fs/nfs/dir.c | 1 + fs/nfs/unlink.c | 2 ++ 2 files changed, 3 insertions(+)
fs/nfs/dir.c +1 -0
@@ -37,6 +37,7 @@#include <linux/sched.h> #include <linux/kmemleak.h> #include <linux/xattr.h> +#include <linux/fsnotify.h> #include "delegation.h" #include "iostat.h"
fs/nfs/unlink.c +2 -0
@@ -355,6 +355,8 @@ static void nfs_async_rename_done(struct rpc_task *task, void *calldata)if (task->tk_status !=0 )nfs_cancel_async_unlink (old_dentry); +else if (old_dentry->d_flags &DCACHE_NFSFS_RENAMED ) +fsnotify_nameremove (old_dentry,S_ISDIR (old_dentry->d_inode->i_mode)); }/**
Signature · 1 line
1.8.5.3
Quoted 33 lines · Jeff Layton
If a file is sillyrenamed, then the generic
vfs_unlinkcode will skip emitting fsnotify events for it.This patch has the sillyrename code do that instead.
In truth this is a little bit odd since we aren't actually removing the dentry per-se, but renaming it. Still, this is probably the right thing to do since it's what userland apps expect to see when an
unlink()occurs or some file is renamed on top of the dentry.Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/dir.c| 1 +fs/nfs/unlink.c| 2 ++2 files changed, 3 insertions(+)fs/nfs/dir.c +1
-0@@ -37,6 +37,7 @@#include <linux/sched.h> #include <linux/kmemleak.h> #include <linux/xattr.h> +#include <linux/fsnotify.h> #include "delegation.h" #include "iostat.h" fs/nfs/unlink.c +0
-0
fs/nfs/unlink.c static void nfs_async_rename_done(struct rpc_task *task, void *calldata) · line 360
Quoted 6 lines
fs/nfs/unlink.c +2
-0@@ -355,6 +355,8 @@ static void nfs_async_rename_done(struct rpc_task *task, void *calldata)if (task->tk_status !=0 )nfs_cancel_async_unlink (old_dentry); +else if (old_dentry->d_flags &DCACHE_NFSFS_RENAMED ) +fsnotify_nameremove (old_dentry,S_ISDIR (old_dentry->d_inode->i_mode)); }
Any reason why we shouldn’t just do this in nfs_sillyrename() itself?
_________________________________
Trond Myklebust
Linux NFS client maintainer, PrimaryData [email protected]
Quoted 37 lines · On Thu, 13 Mar 2014 16:08:01 -0400 Trond Myklebust…
Quoted 34 lines · Jeff Layton
If a file is sillyrenamed, then the generic
vfs_unlinkcode will skip emitting fsnotify events for it.This patch has the sillyrename code do that instead.
In truth this is a little bit odd since we aren't actually removing the dentry per-se, but renaming it. Still, this is probably the right thing to do since it's what userland apps expect to see when an
unlink()occurs or some file is renamed on top of the dentry.Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/dir.c| 1 +fs/nfs/unlink.c| 2 ++2 files changed, 3 insertions(+)fs/nfs/dir.c +1
-0@@ -37,6 +37,7 @@#include <linux/sched.h> #include <linux/kmemleak.h> #include <linux/xattr.h> +#include <linux/fsnotify.h> #include "delegation.h" #include "iostat.h" fs/nfs/unlink.c +0
-0@@ -355,6 +355,8 @@ static void nfs_async_rename_done(struct rpc_task *task, void *calldata)
Quoted 8 lines
fs/nfs/unlink.c static void nfs_async_rename_done(struct rpc_task *task, void *calldata) · line 360
Quoted 5 lines
fs/nfs/unlink.c +2
-0if (task->tk_status !=0 )nfs_cancel_async_unlink (old_dentry); +else if (old_dentry->d_flags &DCACHE_NFSFS_RENAMED ) +fsnotify_nameremove (old_dentry,S_ISDIR (old_dentry->d_inode->i_mode)); }Any reason why we shouldn’t just do this in
nfs_sillyrename()itself?
We certainly could, but then you'd probably never get the event if the process waiting on the async sillyrename got killed while waiting on the reply.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 49 lines · Jeff Layton
Quoted 37 lines · On Thu, 13 Mar 2014 16:08:01 -0400 Trond Myklebust…
Quoted 34 lines · Jeff Layton
If a file is sillyrenamed, then the generic
vfs_unlinkcode will skip emitting fsnotify events for it.This patch has the sillyrename code do that instead.
In truth this is a little bit odd since we aren't actually removing the dentry per-se, but renaming it. Still, this is probably the right thing to do since it's what userland apps expect to see when an
unlink()occurs or some file is renamed on top of the dentry.Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/dir.c| 1 +fs/nfs/unlink.c| 2 ++2 files changed, 3 insertions(+)fs/nfs/dir.c +1
-0@@ -37,6 +37,7 @@#include <linux/sched.h> #include <linux/kmemleak.h> #include <linux/xattr.h> +#include <linux/fsnotify.h> #include "delegation.h" #include "iostat.h" fs/nfs/unlink.c +0
-0@@ -355,6 +355,8 @@ static void nfs_async_rename_done(struct rpc_task *task, void *calldata)Quoted 8 lines
fs/nfs/unlink.c static void nfs_async_rename_done(struct rpc_task *task, void *calldata) · line 360
Quoted 5 lines
fs/nfs/unlink.c +2
-0if (task->tk_status !=0 )nfs_cancel_async_unlink (old_dentry); +else if (old_dentry->d_flags &DCACHE_NFSFS_RENAMED ) +fsnotify_nameremove (old_dentry,S_ISDIR (old_dentry->d_inode->i_mode)); }Any reason why we shouldn’t just do this in
nfs_sillyrename()itself?
Quoted 3 lines
We certainly could, but then you'd probably never get the event if the process waiting on the async sillyrename got killed while waiting on the reply.
Just send it anyway. The dentry will have been scheduled to be unlinked no matter whether or not the process is killed.
_________________________________
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]
Quoted 52 lines · On Thu, 13 Mar 2014 16:47:49 -0400 Trond Myklebust…
Quoted 49 lines · Jeff Layton
Quoted 45 lines · On Thu, 13 Mar 2014 16:08:01 -0400 Trond Myklebust…
Quoted 33 lines · Jeff Layton
If a file is sillyrenamed, then the generic
vfs_unlinkcode will skip emitting fsnotify events for it.This patch has the sillyrename code do that instead.
In truth this is a little bit odd since we aren't actually removing the dentry per-se, but renaming it. Still, this is probably the right thing to do since it's what userland apps expect to see when an
unlink()occurs or some file is renamed on top of the dentry.Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/dir.c| 1 +fs/nfs/unlink.c| 2 ++2 files changed, 3 insertions(+)fs/nfs/dir.c +1
-0@@ -37,6 +37,7 @@#include <linux/sched.h> #include <linux/kmemleak.h> #include <linux/xattr.h> +#include <linux/fsnotify.h> #include "delegation.h" #include "iostat.h" fs/nfs/unlink.c +0
-0fs/nfs/unlink.c static void nfs_async_rename_done(struct rpc_task *task, void *calldata) · line 360
Quoted 6 lines
fs/nfs/unlink.c +2
-0@@ -355,6 +355,8 @@ static void nfs_async_rename_done(struct rpc_task *task, void *calldata)if (task->tk_status !=0 )nfs_cancel_async_unlink (old_dentry); +else if (old_dentry->d_flags &DCACHE_NFSFS_RENAMED ) +fsnotify_nameremove (old_dentry,S_ISDIR (old_dentry->d_inode->i_mode)); }Any reason why we shouldn’t just do this in
nfs_sillyrename()itself?
Quoted 6 lines
Quoted 3 lines
We certainly could, but then you'd probably never get the event if the process waiting on the async sillyrename got killed while waiting on the reply.
Just send it anyway. The dentry will have been scheduled to be unlinked no matter whether or not the process is killed.
Hrm, I dunno...
If we do that then we may end up sending the event before it has actually occurred. I'm not sure if that's a problem or not, but it seems iffy.
I don't get it though -- why not do this in the rpc_call_done handler? If we do it there then we know we'll only send the event if the rename succeeded.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 64 lines · Jeff Layton
Quoted 52 lines · On Thu, 13 Mar 2014 16:47:49 -0400 Trond Myklebust…
Quoted 49 lines · Jeff Layton
Quoted 45 lines · On Thu, 13 Mar 2014 16:08:01 -0400 Trond Myklebust…
Quoted 33 lines · Jeff Layton
If a file is sillyrenamed, then the generic
vfs_unlinkcode will skip emitting fsnotify events for it.This patch has the sillyrename code do that instead.
In truth this is a little bit odd since we aren't actually removing the dentry per-se, but renaming it. Still, this is probably the right thing to do since it's what userland apps expect to see when an
unlink()occurs or some file is renamed on top of the dentry.Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/dir.c| 1 +fs/nfs/unlink.c| 2 ++2 files changed, 3 insertions(+)fs/nfs/dir.c +1
-0@@ -37,6 +37,7 @@#include <linux/sched.h> #include <linux/kmemleak.h> #include <linux/xattr.h> +#include <linux/fsnotify.h> #include "delegation.h" #include "iostat.h" fs/nfs/unlink.c +0
-0fs/nfs/unlink.c static void nfs_async_rename_done(struct rpc_task *task, void *calldata) · line 360
Quoted 6 lines
fs/nfs/unlink.c +2
-0@@ -355,6 +355,8 @@ static void nfs_async_rename_done(struct rpc_task *task, void *calldata)if (task->tk_status !=0 )nfs_cancel_async_unlink (old_dentry); +else if (old_dentry->d_flags &DCACHE_NFSFS_RENAMED ) +fsnotify_nameremove (old_dentry,S_ISDIR (old_dentry->d_inode->i_mode)); }Any reason why we shouldn’t just do this in
nfs_sillyrename()itself?Quoted 6 lines
Quoted 3 lines
We certainly could, but then you'd probably never get the event if the process waiting on the async sillyrename got killed while waiting on the reply.
Just send it anyway. The dentry will have been scheduled to be unlinked no matter whether or not the process is killed.
Hrm, I dunno...
Quoted 7 lines
If we do that then we may end up sending the event before it has actually occurred. I'm not sure if that's a problem or not, but it seems iffy.
I don't get it though -- why not do this in the
rpc_call_donehandler? If we do it there then we know we'll only send the event if the rename succeeded.
While nfs_async_rename() may currently reside in fs/nfs/unlink.c, the function itself is completely independent of sillyrename. It doesn't even share any common structures. Why should we start adding stuff which has absolutely nothing to do with rename to it when we don't have to?
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, PrimaryData [email protected]
Quoted 69 lines · Trond Myklebust
Quoted 68 lines · Jeff Layton
Quoted 52 lines · On Thu, 13 Mar 2014 16:47:49 -0400 Trond Myklebust…
Quoted 49 lines · Jeff Layton
Quoted 45 lines · On Thu, 13 Mar 2014 16:08:01 -0400 Trond Myklebust…
Quoted 33 lines · Jeff Layton
If a file is sillyrenamed, then the generic
vfs_unlinkcode will skip emitting fsnotify events for it.This patch has the sillyrename code do that instead.
In truth this is a little bit odd since we aren't actually removing the dentry per-se, but renaming it. Still, this is probably the right thing to do since it's what userland apps expect to see when an
unlink()occurs or some file is renamed on top of the dentry.Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/dir.c| 1 +fs/nfs/unlink.c| 2 ++2 files changed, 3 insertions(+)fs/nfs/dir.c +1
-0@@ -37,6 +37,7 @@#include <linux/sched.h> #include <linux/kmemleak.h> #include <linux/xattr.h> +#include <linux/fsnotify.h> #include "delegation.h" #include "iostat.h" fs/nfs/unlink.c +0
-0fs/nfs/unlink.c static void nfs_async_rename_done(struct rpc_task *task, void *calldata) · line 360
Quoted 6 lines
fs/nfs/unlink.c +2
-0@@ -355,6 +355,8 @@ static void nfs_async_rename_done(struct rpc_task *task, void *calldata)if (task->tk_status !=0 )nfs_cancel_async_unlink (old_dentry); +else if (old_dentry->d_flags &DCACHE_NFSFS_RENAMED ) +fsnotify_nameremove (old_dentry,S_ISDIR (old_dentry->d_inode->i_mode)); }Any reason why we shouldn’t just do this in
nfs_sillyrename()itself?Quoted 6 lines
Quoted 3 lines
We certainly could, but then you'd probably never get the event if the process waiting on the async sillyrename got killed while waiting on the reply.
Just send it anyway. The dentry will have been scheduled to be unlinked no matter whether or not the process is killed.
Hrm, I dunno...
If we do that then we may end up sending the event before it has actually occurred. I'm not sure if that's a problem or not, but it seems iffy.
Quoted 8 lines
Quoted 3 lines
I don't get it though -- why not do this in the
rpc_call_donehandler? If we do it there then we know we'll only send the event if the rename succeeded.While
nfs_async_rename()may currently reside infs/nfs/unlink.c, the function itself is completely independent of sillyrename. It doesn't even share any common structures. Why should we start adding stuff which has absolutely nothing to do with rename to it when we don't have to?
Put differently: if anyone out there is looking for something to do, then reuniting nfs_async_rename() with its long lost synchronous cousins would be a nice little cleanup.
_________________________________
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]
Quoted 76 lines · On Thu, 13 Mar 2014 17:36:42 -0400 Trond Myklebust…
Quoted 73 lines · Trond Myklebust
Quoted 71 lines · Jeff Layton
Quoted 52 lines · On Thu, 13 Mar 2014 16:47:49 -0400 Trond Myklebust…
Quoted 49 lines · Jeff Layton
Quoted 45 lines · On Thu, 13 Mar 2014 16:08:01 -0400 Trond Myklebust…
Quoted 33 lines · Jeff Layton
If a file is sillyrenamed, then the generic
vfs_unlinkcode will skip emitting fsnotify events for it.This patch has the sillyrename code do that instead.
In truth this is a little bit odd since we aren't actually removing the dentry per-se, but renaming it. Still, this is probably the right thing to do since it's what userland apps expect to see when an
unlink()occurs or some file is renamed on top of the dentry.Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/dir.c| 1 +fs/nfs/unlink.c| 2 ++2 files changed, 3 insertions(+)fs/nfs/dir.c +1
-0@@ -37,6 +37,7 @@#include <linux/sched.h> #include <linux/kmemleak.h> #include <linux/xattr.h> +#include <linux/fsnotify.h> #include "delegation.h" #include "iostat.h" fs/nfs/unlink.c +0
-0fs/nfs/unlink.c static void nfs_async_rename_done(struct rpc_task *task, void *calldata) · line 360
Quoted 6 lines
fs/nfs/unlink.c +2
-0@@ -355,6 +355,8 @@ static void nfs_async_rename_done(struct rpc_task *task, void *calldata)if (task->tk_status !=0 )nfs_cancel_async_unlink (old_dentry); +else if (old_dentry->d_flags &DCACHE_NFSFS_RENAMED ) +fsnotify_nameremove (old_dentry,S_ISDIR (old_dentry->d_inode->i_mode)); }Any reason why we shouldn’t just do this in
nfs_sillyrename()itself?Quoted 6 lines
Quoted 3 lines
We certainly could, but then you'd probably never get the event if the process waiting on the async sillyrename got killed while waiting on the reply.
Just send it anyway. The dentry will have been scheduled to be unlinked no matter whether or not the process is killed.
Hrm, I dunno...
If we do that then we may end up sending the event before it has actually occurred. I'm not sure if that's a problem or not, but it seems iffy.
I don't get it though -- why not do this in the
rpc_call_donehandler? If we do it there then we know we'll only send the event if the rename succeeded.
Quoted 6 lines
Quoted 4 lines
While
nfs_async_rename()may currently reside infs/nfs/unlink.c, the function itself is completely independent of sillyrename. It doesn't even share any common structures. Why should we start adding stuff which has absolutely nothing to do with rename to it when we don't have to?Put differently: if anyone out there is looking for something to do, then reuniting
nfs_async_rename()with its long lost synchronous cousins would be a nice little cleanup.
Yeah, that's long overdue. I had originally meant to do that when I added the async rename stuff, but got sidetracked...
In that case, we also have a bit of a "layering violation" with nfs_cancel_async_unlink. It's probably not to hard to fix that with YAFP (yet another function pointer).
Let's just drop this patch for now, and I'll have a look at this in the near future and see if I can unify the rename code. Then we can add the fsnotify stuff on top of that.
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>