mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-06 05:06:29 +00:00
centralize killing dentry from shrink list
new helper unifying identical bits of shrink_dentry_list() and shring_dcache_for_umount() Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
da549bdd15
commit
3fcf535626
21
fs/dcache.c
21
fs/dcache.c
@ -1174,10 +1174,18 @@ static bool shrink_lock_dentry(struct dentry *dentry)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void shrink_kill(struct dentry *victim, struct list_head *list)
|
||||||
|
{
|
||||||
|
struct dentry *parent = victim->d_parent;
|
||||||
|
if (parent != victim)
|
||||||
|
__dput_to_list(parent, list);
|
||||||
|
__dentry_kill(victim);
|
||||||
|
}
|
||||||
|
|
||||||
void shrink_dentry_list(struct list_head *list)
|
void shrink_dentry_list(struct list_head *list)
|
||||||
{
|
{
|
||||||
while (!list_empty(list)) {
|
while (!list_empty(list)) {
|
||||||
struct dentry *dentry, *parent;
|
struct dentry *dentry;
|
||||||
|
|
||||||
dentry = list_entry(list->prev, struct dentry, d_lru);
|
dentry = list_entry(list->prev, struct dentry, d_lru);
|
||||||
spin_lock(&dentry->d_lock);
|
spin_lock(&dentry->d_lock);
|
||||||
@ -1195,10 +1203,7 @@ void shrink_dentry_list(struct list_head *list)
|
|||||||
}
|
}
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
d_shrink_del(dentry);
|
d_shrink_del(dentry);
|
||||||
parent = dentry->d_parent;
|
shrink_kill(dentry, list);
|
||||||
if (parent != dentry)
|
|
||||||
__dput_to_list(parent, list);
|
|
||||||
__dentry_kill(dentry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1629,17 +1634,13 @@ void shrink_dcache_parent(struct dentry *parent)
|
|||||||
data.victim = NULL;
|
data.victim = NULL;
|
||||||
d_walk(parent, &data, select_collect2);
|
d_walk(parent, &data, select_collect2);
|
||||||
if (data.victim) {
|
if (data.victim) {
|
||||||
struct dentry *parent;
|
|
||||||
spin_lock(&data.victim->d_lock);
|
spin_lock(&data.victim->d_lock);
|
||||||
if (!shrink_lock_dentry(data.victim)) {
|
if (!shrink_lock_dentry(data.victim)) {
|
||||||
spin_unlock(&data.victim->d_lock);
|
spin_unlock(&data.victim->d_lock);
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
} else {
|
} else {
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
parent = data.victim->d_parent;
|
shrink_kill(data.victim, &data.dispose);
|
||||||
if (parent != data.victim)
|
|
||||||
__dput_to_list(parent, &data.dispose);
|
|
||||||
__dentry_kill(data.victim);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!list_empty(&data.dispose))
|
if (!list_empty(&data.dispose))
|
||||||
|
Loading…
Reference in New Issue
Block a user