From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Al Viro <viro@zeniv.linux.org.uk>, linux-fsdevel@vger.kernel.org
Subject: [RFC][PATCH 2/4] fsnotify: add empty fsnotify_remove() hook
Date: Wed, 15 May 2019 01:18:59 +0300 [thread overview]
Message-ID: <20190514221901.29125-3-amir73il@gmail.com> (raw)
In-Reply-To: <20190514221901.29125-1-amir73il@gmail.com>
We would like to move fsnotify_nameremove() calls from d_delete()
into a higher layer where the hook makes more sense and so we can
consider every d_delete() call site individually.
Start by creating an empty hook called fsnotify_remove() and place
it in the proper VFS call sites. After all d_delete() call sites
will be converted to use the new hook, it will replace the old
fsnotify_nameremove() hook in d_delete().
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/libfs.c | 5 ++++-
fs/namei.c | 2 ++
include/linux/fsnotify.h | 13 +++++++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/fs/libfs.c b/fs/libfs.c
index 030e67c52b5f..0dd676fc9272 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -10,6 +10,7 @@
#include <linux/cred.h>
#include <linux/mount.h>
#include <linux/vfs.h>
+#include <linux/fsnotify.h>
#include <linux/quotaops.h>
#include <linux/mutex.h>
#include <linux/namei.h>
@@ -367,8 +368,10 @@ int simple_remove(struct inode *dir, struct dentry *dentry)
else
ret = simple_unlink(dir, dentry);
- if (!ret)
+ if (!ret) {
+ fsnotify_remove(dir, dentry);
d_delete(dentry);
+ }
dput(dentry);
return ret;
diff --git a/fs/namei.c b/fs/namei.c
index 20831c2fbb34..c9eda9cc5d43 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3883,6 +3883,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
dentry->d_inode->i_flags |= S_DEAD;
dont_mount(dentry);
detach_mounts(dentry);
+ fsnotify_remove(dir, dentry);
out:
inode_unlock(dentry->d_inode);
@@ -3999,6 +4000,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegate
if (!error) {
dont_mount(dentry);
detach_mounts(dentry);
+ fsnotify_remove(dir, dentry);
}
}
}
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 94972e8eb6d1..455dff82595e 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -151,6 +151,19 @@ static inline void fsnotify_vfsmount_delete(struct vfsmount *mnt)
__fsnotify_vfsmount_delete(mnt);
}
+/*
+ * fsnotify_remove - a filename was removed from a directory
+ *
+ * Caller must make sure that dentry->d_name is stable.
+ */
+static inline void fsnotify_remove(struct inode *dir, struct dentry *dentry)
+{
+ /* Expected to be called before d_delete() */
+ WARN_ON_ONCE(d_is_negative(dentry));
+
+ /* TODO: call fsnotify_dirent() */
+}
+
/*
* fsnotify_inoderemove - an inode is going away
*/
--
2.17.1
next prev parent reply other threads:[~2019-05-14 22:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-14 22:18 [RFC][PATCH 0/4] Sort out fsnotify_nameremove() mess Amir Goldstein
2019-05-14 22:18 ` [RFC][PATCH 1/4] fs: create simple_remove() helper Amir Goldstein
2019-05-15 7:51 ` Jan Kara
2019-05-14 22:18 ` Amir Goldstein [this message]
2019-05-15 7:57 ` [RFC][PATCH 2/4] fsnotify: add empty fsnotify_remove() hook Jan Kara
2019-05-14 22:19 ` [RFC][PATCH 3/4] fs: convert filesystems to use simple_remove() helper Amir Goldstein
2019-05-14 22:19 ` [RFC][PATCH 4/4] fsnotify: move fsnotify_nameremove() hook out of d_delete() Amir Goldstein
2019-05-15 8:24 ` Jan Kara
2019-05-15 10:56 ` Amir Goldstein
2019-05-15 11:45 ` Jan Kara
2019-05-15 8:36 ` [RFC][PATCH 0/4] Sort out fsnotify_nameremove() mess Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190514221901.29125-3-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).