Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,15 @@ struct dentry *d_find_alias_rcu(struct inode *inode)
return de;
}

void d_dispose_if_unused(struct dentry *dentry, struct list_head *dispose)
{
spin_lock(&dentry->d_lock);
if (!dentry->d_lockref.count)
to_shrink_list(dentry, dispose);
spin_unlock(&dentry->d_lock);
}
EXPORT_SYMBOL(d_dispose_if_unused);

/*
* Try to kill dentries associated with this inode.
* WARNING: you must own a reference to inode.
Expand All @@ -1042,12 +1051,8 @@ void d_prune_aliases(struct inode *inode)
struct dentry *dentry;

spin_lock(&inode->i_lock);
hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
spin_lock(&dentry->d_lock);
if (!dentry->d_lockref.count)
to_shrink_list(dentry, &dispose);
spin_unlock(&dentry->d_lock);
}
hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias)
d_dispose_if_unused(dentry, &dispose);
spin_unlock(&inode->i_lock);
shrink_dentry_list(&dispose);
}
Expand Down Expand Up @@ -1087,6 +1092,7 @@ void shrink_dentry_list(struct list_head *list)
shrink_kill(dentry);
}
}
EXPORT_SYMBOL(shrink_dentry_list);

static enum lru_status dentry_lru_isolate(struct list_head *item,
struct list_lru_one *lru, void *arg)
Expand Down
2 changes: 2 additions & 0 deletions include/linux/dcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ extern void d_tmpfile(struct file *, struct inode *);

extern struct dentry *d_find_alias(struct inode *);
extern void d_prune_aliases(struct inode *);
extern void d_dispose_if_unused(struct dentry *, struct list_head *);
extern void shrink_dentry_list(struct list_head *);

extern struct dentry *d_find_alias_rcu(struct inode *);

Expand Down