Skip to content

Commit b26d4cd

Browse files
author
Al Viro
committed
consolidate simple ->d_delete() instances
Rename simple_delete_dentry() to always_delete_dentry() and export it. Export simple_dentry_operations, while we are at it, and get rid of their duplicates Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 951b4bd commit b26d4cd

11 files changed

Lines changed: 18 additions & 101 deletions

File tree

‎arch/ia64/kernel/perfmon.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,20 +2166,14 @@ static const struct file_operations pfm_file_ops = {
21662166
.flush = pfm_flush
21672167
};
21682168

2169-
static int
2170-
pfmfs_delete_dentry(const struct dentry *dentry)
2171-
{
2172-
return 1;
2173-
}
2174-
21752169
static char *pfmfs_dname(struct dentry *dentry, char *buffer, int buflen)
21762170
{
21772171
return dynamic_dname(dentry, buffer, buflen, "pfm:[%lu]",
21782172
dentry->d_inode->i_ino);
21792173
}
21802174

21812175
static const struct dentry_operations pfmfs_dentry_operations = {
2182-
.d_delete = pfmfs_delete_dentry,
2176+
.d_delete = always_delete_dentry,
21832177
.d_dname = pfmfs_dname,
21842178
};
21852179

‎fs/9p/vfs_dentry.c‎

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,6 @@
4242
#include "v9fs_vfs.h"
4343
#include "fid.h"
4444

45-
/**
46-
* v9fs_dentry_delete - called when dentry refcount equals 0
47-
* @dentry: dentry in question
48-
*
49-
* By returning 1 here we should remove cacheing of unused
50-
* dentry components.
51-
*
52-
*/
53-
54-
static int v9fs_dentry_delete(const struct dentry *dentry)
55-
{
56-
p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n",
57-
dentry->d_name.name, dentry);
58-
59-
return 1;
60-
}
61-
6245
/**
6346
* v9fs_cached_dentry_delete - called when dentry refcount equals 0
6447
* @dentry: dentry in question
@@ -134,6 +117,6 @@ const struct dentry_operations v9fs_cached_dentry_operations = {
134117
};
135118

136119
const struct dentry_operations v9fs_dentry_operations = {
137-
.d_delete = v9fs_dentry_delete,
120+
.d_delete = always_delete_dentry,
138121
.d_release = v9fs_dentry_release,
139122
};

‎fs/configfs/dir.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,9 @@ static void configfs_d_iput(struct dentry * dentry,
6666
iput(inode);
6767
}
6868

69-
/*
70-
* We _must_ delete our dentries on last dput, as the chain-to-parent
71-
* behavior is required to clear the parents of default_groups.
72-
*/
73-
static int configfs_d_delete(const struct dentry *dentry)
74-
{
75-
return 1;
76-
}
77-
7869
const struct dentry_operations configfs_dentry_ops = {
7970
.d_iput = configfs_d_iput,
80-
/* simple_delete_dentry() isn't exported */
81-
.d_delete = configfs_d_delete,
71+
.d_delete = always_delete_dentry,
8272
};
8373

8474
#ifdef CONFIG_LOCKDEP

‎fs/efivarfs/super.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,10 @@ static int efivarfs_d_hash(const struct dentry *dentry, struct qstr *qstr)
8383
return 0;
8484
}
8585

86-
/*
87-
* Retaining negative dentries for an in-memory filesystem just wastes
88-
* memory and lookup time: arrange for them to be deleted immediately.
89-
*/
90-
static int efivarfs_delete_dentry(const struct dentry *dentry)
91-
{
92-
return 1;
93-
}
94-
9586
static struct dentry_operations efivarfs_d_ops = {
9687
.d_compare = efivarfs_d_compare,
9788
.d_hash = efivarfs_d_hash,
98-
.d_delete = efivarfs_delete_dentry,
89+
.d_delete = always_delete_dentry,
9990
};
10091

10192
static struct dentry *efivarfs_alloc_dentry(struct dentry *parent, char *name)

‎fs/hostfs/hostfs_kern.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode)
3333

3434
#define FILE_HOSTFS_I(file) HOSTFS_I(file_inode(file))
3535

36-
static int hostfs_d_delete(const struct dentry *dentry)
37-
{
38-
return 1;
39-
}
40-
41-
static const struct dentry_operations hostfs_dentry_ops = {
42-
.d_delete = hostfs_d_delete,
43-
};
44-
4536
/* Changed in hostfs_args before the kernel starts running */
4637
static char *root_ino = "";
4738
static int append = 0;
@@ -925,7 +916,7 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
925916
sb->s_blocksize_bits = 10;
926917
sb->s_magic = HOSTFS_SUPER_MAGIC;
927918
sb->s_op = &hostfs_sbops;
928-
sb->s_d_op = &hostfs_dentry_ops;
919+
sb->s_d_op = &simple_dentry_operations;
929920
sb->s_maxbytes = MAX_LFS_FILESIZE;
930921

931922
/* NULL is printed as <NULL> by sprintf: avoid that. */

‎fs/libfs.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,23 @@ EXPORT_SYMBOL(simple_statfs);
4747
* Retaining negative dentries for an in-memory filesystem just wastes
4848
* memory and lookup time: arrange for them to be deleted immediately.
4949
*/
50-
static int simple_delete_dentry(const struct dentry *dentry)
50+
int always_delete_dentry(const struct dentry *dentry)
5151
{
5252
return 1;
5353
}
54+
EXPORT_SYMBOL(always_delete_dentry);
55+
56+
const struct dentry_operations simple_dentry_operations = {
57+
.d_delete = always_delete_dentry,
58+
};
59+
EXPORT_SYMBOL(simple_dentry_operations);
5460

5561
/*
5662
* Lookup the data. This is trivial - if the dentry didn't already
5763
* exist, we know it is negative. Set d_op to delete negative dentries.
5864
*/
5965
struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
6066
{
61-
static const struct dentry_operations simple_dentry_operations = {
62-
.d_delete = simple_delete_dentry,
63-
};
64-
6567
if (dentry->d_name.len > NAME_MAX)
6668
return ERR_PTR(-ENAMETOOLONG);
6769
if (!dentry->d_sb->s_d_op)

‎fs/proc/generic.c‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,6 @@ static const struct inode_operations proc_link_inode_operations = {
174174
.follow_link = proc_follow_link,
175175
};
176176

177-
/*
178-
* As some entries in /proc are volatile, we want to
179-
* get rid of unused dentries. This could be made
180-
* smarter: we could keep a "volatile" flag in the
181-
* inode to indicate which ones to keep.
182-
*/
183-
static int proc_delete_dentry(const struct dentry * dentry)
184-
{
185-
return 1;
186-
}
187-
188-
static const struct dentry_operations proc_dentry_operations =
189-
{
190-
.d_delete = proc_delete_dentry,
191-
};
192-
193177
/*
194178
* Don't create negative dentries here, return -ENOENT by hand
195179
* instead.
@@ -209,7 +193,7 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
209193
inode = proc_get_inode(dir->i_sb, de);
210194
if (!inode)
211195
return ERR_PTR(-ENOMEM);
212-
d_set_d_op(dentry, &proc_dentry_operations);
196+
d_set_d_op(dentry, &simple_dentry_operations);
213197
d_add(dentry, inode);
214198
return NULL;
215199
}

‎fs/proc/namespaces.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ static const struct inode_operations ns_inode_operations = {
4242
.setattr = proc_setattr,
4343
};
4444

45-
static int ns_delete_dentry(const struct dentry *dentry)
46-
{
47-
/* Don't cache namespace inodes when not in use */
48-
return 1;
49-
}
50-
5145
static char *ns_dname(struct dentry *dentry, char *buffer, int buflen)
5246
{
5347
struct inode *inode = dentry->d_inode;
@@ -59,7 +53,7 @@ static char *ns_dname(struct dentry *dentry, char *buffer, int buflen)
5953

6054
const struct dentry_operations ns_dentry_operations =
6155
{
62-
.d_delete = ns_delete_dentry,
56+
.d_delete = always_delete_dentry,
6357
.d_dname = ns_dname,
6458
};
6559

‎include/linux/fs.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,7 +2622,9 @@ extern int simple_write_begin(struct file *file, struct address_space *mapping,
26222622
extern int simple_write_end(struct file *file, struct address_space *mapping,
26232623
loff_t pos, unsigned len, unsigned copied,
26242624
struct page *page, void *fsdata);
2625+
extern int always_delete_dentry(const struct dentry *);
26252626
extern struct inode *alloc_anon_inode(struct super_block *);
2627+
extern const struct dentry_operations simple_dentry_operations;
26262628

26272629
extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags);
26282630
extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *);

‎kernel/cgroup.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -895,11 +895,6 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
895895
iput(inode);
896896
}
897897

898-
static int cgroup_delete(const struct dentry *d)
899-
{
900-
return 1;
901-
}
902-
903898
static void remove_dir(struct dentry *d)
904899
{
905900
struct dentry *parent = dget(d->d_parent);
@@ -1486,7 +1481,7 @@ static int cgroup_get_rootdir(struct super_block *sb)
14861481
{
14871482
static const struct dentry_operations cgroup_dops = {
14881483
.d_iput = cgroup_diput,
1489-
.d_delete = cgroup_delete,
1484+
.d_delete = always_delete_dentry,
14901485
};
14911486

14921487
struct inode *inode =

0 commit comments

Comments
 (0)