aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2016-06-28 11:47:32 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2016-07-24 16:36:29 -0400
commit285b102d3b745f3c2c110c9c327741d87e64aacc (patch)
treec0d13e12f96b7730a1db2633f8e3743fbc267ade /fs/dcache.c
parentMerge branch 'test.d_iput' into work.misc (diff)
downloadwireguard-linux-285b102d3b745f3c2c110c9c327741d87e64aacc.tar.xz
wireguard-linux-285b102d3b745f3c2c110c9c327741d87e64aacc.zip
vfs: new d_init method
Allow filesystem to initialize dentry at allocation time. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index d5beef01cdfc..6d60a764c848 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1569,6 +1569,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
{
struct dentry *dentry;
char *dname;
+ int err;
dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
if (!dentry)
@@ -1627,6 +1628,16 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
INIT_LIST_HEAD(&dentry->d_child);
d_set_d_op(dentry, dentry->d_sb->s_d_op);
+ if (dentry->d_op && dentry->d_op->d_init) {
+ err = dentry->d_op->d_init(dentry);
+ if (err) {
+ if (dname_external(dentry))
+ kfree(external_name(dentry));
+ kmem_cache_free(dentry_cache, dentry);
+ return NULL;
+ }
+ }
+
this_cpu_inc(nr_dentry);
return dentry;