Commit 285b102d authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Al Viro

vfs: new d_init method

Allow filesystem to initialize dentry at allocation time.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 17648b87
...@@ -15,6 +15,7 @@ prototypes: ...@@ -15,6 +15,7 @@ prototypes:
int (*d_compare)(const struct dentry *, const struct dentry *, int (*d_compare)(const struct dentry *, const struct dentry *,
unsigned int, const char *, const struct qstr *); unsigned int, const char *, const struct qstr *);
int (*d_delete)(struct dentry *); int (*d_delete)(struct dentry *);
int (*d_init)(struct dentry *);
void (*d_release)(struct dentry *); void (*d_release)(struct dentry *);
void (*d_iput)(struct dentry *, struct inode *); void (*d_iput)(struct dentry *, struct inode *);
char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen); char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen);
...@@ -30,6 +31,7 @@ d_weak_revalidate:no no yes no ...@@ -30,6 +31,7 @@ d_weak_revalidate:no no yes no
d_hash no no no maybe d_hash no no no maybe
d_compare: yes no no maybe d_compare: yes no no maybe
d_delete: no yes no no d_delete: no yes no no
d_init: no no yes no
d_release: no no yes no d_release: no no yes no
d_prune: no yes no no d_prune: no yes no no
d_iput: no no yes no d_iput: no no yes no
......
...@@ -923,6 +923,7 @@ struct dentry_operations { ...@@ -923,6 +923,7 @@ struct dentry_operations {
int (*d_compare)(const struct dentry *, const struct dentry *, int (*d_compare)(const struct dentry *, const struct dentry *,
unsigned int, const char *, const struct qstr *); unsigned int, const char *, const struct qstr *);
int (*d_delete)(const struct dentry *); int (*d_delete)(const struct dentry *);
int (*d_init)(struct dentry *);
void (*d_release)(struct dentry *); void (*d_release)(struct dentry *);
void (*d_iput)(struct dentry *, struct inode *); void (*d_iput)(struct dentry *, struct inode *);
char *(*d_dname)(struct dentry *, char *, int); char *(*d_dname)(struct dentry *, char *, int);
...@@ -995,6 +996,8 @@ struct dentry_operations { ...@@ -995,6 +996,8 @@ struct dentry_operations {
always cache a reachable dentry. d_delete must be constant and always cache a reachable dentry. d_delete must be constant and
idempotent. idempotent.
d_init: called when a dentry is allocated
d_release: called when a dentry is really deallocated d_release: called when a dentry is really deallocated
d_iput: called when a dentry loses its inode (just prior to its d_iput: called when a dentry loses its inode (just prior to its
......
...@@ -1569,6 +1569,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) ...@@ -1569,6 +1569,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
{ {
struct dentry *dentry; struct dentry *dentry;
char *dname; char *dname;
int err;
dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL); dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
if (!dentry) if (!dentry)
...@@ -1627,6 +1628,16 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) ...@@ -1627,6 +1628,16 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
INIT_LIST_HEAD(&dentry->d_child); INIT_LIST_HEAD(&dentry->d_child);
d_set_d_op(dentry, dentry->d_sb->s_d_op); 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); this_cpu_inc(nr_dentry);
return dentry; return dentry;
......
...@@ -133,6 +133,7 @@ struct dentry_operations { ...@@ -133,6 +133,7 @@ struct dentry_operations {
int (*d_compare)(const struct dentry *, const struct dentry *, int (*d_compare)(const struct dentry *, const struct dentry *,
unsigned int, const char *, const struct qstr *); unsigned int, const char *, const struct qstr *);
int (*d_delete)(const struct dentry *); int (*d_delete)(const struct dentry *);
int (*d_init)(struct dentry *);
void (*d_release)(struct dentry *); void (*d_release)(struct dentry *);
void (*d_prune)(struct dentry *); void (*d_prune)(struct dentry *);
void (*d_iput)(struct dentry *, struct inode *); void (*d_iput)(struct dentry *, struct inode *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment