Skip to content

Commit 395b955

Browse files
luis-henrixMiklos Szeredi
authored andcommitted
dcache: export shrink_dentry_list() and add new helper d_dispose_if_unused()
Add and export a new helper d_dispose_if_unused() which is simply a wrapper around to_shrink_list(), to add an entry to a dispose list if it's not used anymore. Also export shrink_dentry_list() to kill all dentries in a dispose list. Suggested-by: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Luis Henriques <luis@igalia.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 66c6a77 commit 395b955

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

fs/dcache.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,15 @@ struct dentry *d_find_alias_rcu(struct inode *inode)
10861086
return de;
10871087
}
10881088

1089+
void d_dispose_if_unused(struct dentry *dentry, struct list_head *dispose)
1090+
{
1091+
spin_lock(&dentry->d_lock);
1092+
if (!dentry->d_lockref.count)
1093+
to_shrink_list(dentry, dispose);
1094+
spin_unlock(&dentry->d_lock);
1095+
}
1096+
EXPORT_SYMBOL(d_dispose_if_unused);
1097+
10891098
/*
10901099
* Try to kill dentries associated with this inode.
10911100
* WARNING: you must own a reference to inode.
@@ -1096,12 +1105,8 @@ void d_prune_aliases(struct inode *inode)
10961105
struct dentry *dentry;
10971106

10981107
spin_lock(&inode->i_lock);
1099-
hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
1100-
spin_lock(&dentry->d_lock);
1101-
if (!dentry->d_lockref.count)
1102-
to_shrink_list(dentry, &dispose);
1103-
spin_unlock(&dentry->d_lock);
1104-
}
1108+
hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias)
1109+
d_dispose_if_unused(dentry, &dispose);
11051110
spin_unlock(&inode->i_lock);
11061111
shrink_dentry_list(&dispose);
11071112
}
@@ -1141,6 +1146,7 @@ void shrink_dentry_list(struct list_head *list)
11411146
shrink_kill(dentry);
11421147
}
11431148
}
1149+
EXPORT_SYMBOL(shrink_dentry_list);
11441150

11451151
static enum lru_status dentry_lru_isolate(struct list_head *item,
11461152
struct list_lru_one *lru, void *arg)

include/linux/dcache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ extern void d_tmpfile(struct file *, struct inode *);
268268

269269
extern struct dentry *d_find_alias(struct inode *);
270270
extern void d_prune_aliases(struct inode *);
271+
extern void d_dispose_if_unused(struct dentry *, struct list_head *);
272+
extern void shrink_dentry_list(struct list_head *);
271273

272274
extern struct dentry *d_find_alias_rcu(struct inode *);
273275

0 commit comments

Comments
 (0)