From: Amir Goldstein <amir73il@gmail.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jan Kara <jack@suse.cz>, Eric Paris <eparis@redhat.com>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/4] fsnotify: pass dentry instead of inode when available
Date: Sat, 17 Dec 2016 16:20:31 +0200 [thread overview]
Message-ID: <1481984434-13293-2-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1481984434-13293-1-git-send-email-amir73il@gmail.com>
Define a new data type to pass for event FSNOTIFY_EVENT_DENTRY
and use it whenever a dentry is available instead of passing
it's ->d_inode as data type FSNOTIFY_EVENT_INODE.
None of the current fsnotify backends make use of the inode data
with data type FSNOTIFY_EVENT_INODE - only the data of type
FSNOTIFY_EVENT_PATH is ever used, so this change has no immediate
consequences.
Soon, we are going to use the dentry data type to support more
events with fanotify backend.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/notify/fsnotify.c | 2 +-
include/linux/fsnotify.h | 15 +++++++--------
include/linux/fsnotify_backend.h | 3 ++-
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index b41515d..768f334 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -112,7 +112,7 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
dentry->d_name.name, 0);
else
- ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
+ ret = fsnotify(p_inode, mask, dentry, FSNOTIFY_EVENT_DENTRY,
dentry->d_name.name, 0);
}
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index b43d3f5..86244c5 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -86,14 +86,14 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
fsnotify(old_dir, old_dir_mask, source, FSNOTIFY_EVENT_INODE, old_name,
fs_cookie);
- fsnotify(new_dir, new_dir_mask, source, FSNOTIFY_EVENT_INODE, new_name,
+ fsnotify(new_dir, new_dir_mask, moved, FSNOTIFY_EVENT_DENTRY, new_name,
fs_cookie);
if (target)
fsnotify_link_count(target);
if (source)
- fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0);
+ fsnotify(source, FS_MOVE_SELF, moved, FSNOTIFY_EVENT_DENTRY, NULL, 0);
audit_inode_child(new_dir, moved, AUDIT_TYPE_CHILD_CREATE);
}
@@ -142,7 +142,7 @@ static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
{
audit_inode_child(inode, dentry, AUDIT_TYPE_CHILD_CREATE);
- fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0);
+ fsnotify(inode, FS_CREATE, dentry, FSNOTIFY_EVENT_DENTRY, dentry->d_name.name, 0);
}
/*
@@ -155,7 +155,7 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct
fsnotify_link_count(inode);
audit_inode_child(dir, new_dentry, AUDIT_TYPE_CHILD_CREATE);
- fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0);
+ fsnotify(dir, FS_CREATE, new_dentry, FSNOTIFY_EVENT_DENTRY, new_dentry->d_name.name, 0);
}
/*
@@ -164,11 +164,10 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct
static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
{
__u32 mask = (FS_CREATE | FS_ISDIR);
- struct inode *d_inode = dentry->d_inode;
audit_inode_child(inode, dentry, AUDIT_TYPE_CHILD_CREATE);
- fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0);
+ fsnotify(inode, mask, dentry, FSNOTIFY_EVENT_DENTRY, dentry->d_name.name, 0);
}
/*
@@ -254,7 +253,7 @@ static inline void fsnotify_xattr(struct dentry *dentry)
mask |= FS_ISDIR;
fsnotify_parent(NULL, dentry, mask);
- fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
+ fsnotify(inode, mask, dentry, FSNOTIFY_EVENT_DENTRY, NULL, 0);
}
/*
@@ -289,7 +288,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
mask |= FS_ISDIR;
fsnotify_parent(NULL, dentry, mask);
- fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0);
+ fsnotify(inode, mask, dentry, FSNOTIFY_EVENT_DENTRY, NULL, 0);
}
}
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 0cf34d6..e8a5791 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -188,10 +188,11 @@ struct fsnotify_group {
};
};
-/* when calling fsnotify tell it if the data is a path or inode */
+/* when calling fsnotify tell it if the data is a path or inode or dentry */
#define FSNOTIFY_EVENT_NONE 0
#define FSNOTIFY_EVENT_PATH 1
#define FSNOTIFY_EVENT_INODE 2
+#define FSNOTIFY_EVENT_DENTRY 3
/*
* A mark is simply an object attached to an in core inode which allows an
--
2.7.4
next prev parent reply other threads:[~2016-12-17 14:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-17 14:20 [PATCH 0/4] fsnotify: misc cleanups Amir Goldstein
2016-12-17 14:20 ` Amir Goldstein [this message]
2016-12-17 14:20 ` [PATCH 2/4] fsnotify: annotate filename events Amir Goldstein
2016-12-17 14:20 ` [PATCH 3/4] fsnotify: simplify API for " Amir Goldstein
2016-12-17 14:20 ` [PATCH 4/4] fsnotify: make MOVED_FROM a dentry event Amir Goldstein
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=1481984434-13293-2-git-send-email-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=eparis@redhat.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).