Skip to content

Commit 3fcf535

Browse files
author
Al Viro
committed
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>
1 parent da549bd commit 3fcf535

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

fs/dcache.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,10 +1174,18 @@ static bool shrink_lock_dentry(struct dentry *dentry)
11741174
return false;
11751175
}
11761176

1177+
static inline void shrink_kill(struct dentry *victim, struct list_head *list)
1178+
{
1179+
struct dentry *parent = victim->d_parent;
1180+
if (parent != victim)
1181+
__dput_to_list(parent, list);
1182+
__dentry_kill(victim);
1183+
}
1184+
11771185
void shrink_dentry_list(struct list_head *list)
11781186
{
11791187
while (!list_empty(list)) {
1180-
struct dentry *dentry, *parent;
1188+
struct dentry *dentry;
11811189

11821190
dentry = list_entry(list->prev, struct dentry, d_lru);
11831191
spin_lock(&dentry->d_lock);
@@ -1195,10 +1203,7 @@ void shrink_dentry_list(struct list_head *list)
11951203
}
11961204
rcu_read_unlock();
11971205
d_shrink_del(dentry);
1198-
parent = dentry->d_parent;
1199-
if (parent != dentry)
1200-
__dput_to_list(parent, list);
1201-
__dentry_kill(dentry);
1206+
shrink_kill(dentry, list);
12021207
}
12031208
}
12041209

@@ -1629,17 +1634,13 @@ void shrink_dcache_parent(struct dentry *parent)
16291634
data.victim = NULL;
16301635
d_walk(parent, &data, select_collect2);
16311636
if (data.victim) {
1632-
struct dentry *parent;
16331637
spin_lock(&data.victim->d_lock);
16341638
if (!shrink_lock_dentry(data.victim)) {
16351639
spin_unlock(&data.victim->d_lock);
16361640
rcu_read_unlock();
16371641
} else {
16381642
rcu_read_unlock();
1639-
parent = data.victim->d_parent;
1640-
if (parent != data.victim)
1641-
__dput_to_list(parent, &data.dispose);
1642-
__dentry_kill(data.victim);
1643+
shrink_kill(data.victim, &data.dispose);
16431644
}
16441645
}
16451646
if (!list_empty(&data.dispose))

0 commit comments

Comments
 (0)