From: Roman Pen <r.peniaev@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Roman Pen <r.peniaev@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH 2/3] debugfs: put private data to i_private for automount inode
Date: Thu, 10 Dec 2015 13:47:13 +0100 [thread overview]
Message-ID: <1449751634-7887-3-git-send-email-r.peniaev@gmail.com> (raw)
In-Reply-To: <1449751634-7887-1-git-send-email-r.peniaev@gmail.com>
I will need dentry->d_fsdata in the next patch.
Keep 'd_fsdata' for debugfs needs.
Signed-off-by: Roman Pen <r.peniaev@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
---
fs/debugfs/inode.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 7bd7e19..a1d077a 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -170,6 +170,8 @@ static void debugfs_evict_inode(struct inode *inode)
clear_inode(inode);
if (S_ISLNK(inode->i_mode))
kfree(inode->i_link);
+ else if (S_ISDIR(inode->i_mode) && IS_AUTOMOUNT(inode))
+ kfree(inode->i_private);
}
static const struct super_operations debugfs_super_operations = {
@@ -179,11 +181,16 @@ static const struct super_operations debugfs_super_operations = {
.evict_inode = debugfs_evict_inode,
};
+struct automount_priv {
+ struct vfsmount *(*func)(void *);
+ void *data;
+};
+
static struct vfsmount *debugfs_automount(struct path *path)
{
- struct vfsmount *(*f)(void *);
- f = (struct vfsmount *(*)(void *))path->dentry->d_fsdata;
- return f(d_inode(path->dentry)->i_private);
+ struct automount_priv *p = d_inode(path->dentry)->i_private;
+
+ return p->func(p->data);
}
static const struct dentry_operations debugfs_dops = {
@@ -448,19 +455,28 @@ struct dentry *debugfs_create_automount(const char *name,
void *data)
{
struct dentry *dentry = start_creating(name, parent);
+ struct automount_priv *p;
struct inode *inode;
if (IS_ERR(dentry))
return NULL;
+ p = kmalloc(sizeof(*p), GFP_KERNEL);
+ if (unlikely(!p))
+ return failed_creating(dentry);
+
+ p->func = f;
+ p->data = data;
+
inode = debugfs_get_inode(dentry->d_sb);
- if (unlikely(!inode))
+ if (unlikely(!inode)) {
+ kfree(p);
return failed_creating(dentry);
+ }
inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
inode->i_flags |= S_AUTOMOUNT;
- inode->i_private = data;
- dentry->d_fsdata = (void *)f;
+ inode->i_private = p;
/* directory inodes start off with i_nlink == 2 (for "." entry) */
inc_nlink(inode);
d_instantiate(dentry, inode);
--
2.6.2
next prev parent reply other threads:[~2015-12-10 12:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-10 12:47 [RFC PATCH 0/3] debugfs: make __debugfs_remove wait for dentry release Roman Pen
2015-12-10 12:47 ` [RFC PATCH 1/3] debugfs: fix automount inode i_nlink references Roman Pen
2016-02-08 6:38 ` Greg Kroah-Hartman
2016-02-08 10:28 ` Roman Peniaev
2016-02-08 16:35 ` Greg Kroah-Hartman
2016-02-09 10:34 ` Roman Peniaev
2015-12-10 12:47 ` Roman Pen [this message]
2015-12-10 12:47 ` [RFC PATCH 3/3] debugfs: make __debugfs_remove wait for dentry release Roman Pen
2016-02-08 6:39 ` Greg Kroah-Hartman
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=1449751634-7887-3-git-send-email-r.peniaev@gmail.com \
--to=r.peniaev@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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