mirror of https://gitee.com/openkylin/linux.git
quota: Cleanup list iteration in dqcache_shrink_scan()
Use list_first_entry() and list_empty() instead of opencoded variants. Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
9560ba306d
commit
1822193b5d
|
@ -711,21 +711,18 @@ EXPORT_SYMBOL(dquot_quota_sync);
|
||||||
static unsigned long
|
static unsigned long
|
||||||
dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
|
dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
|
||||||
{
|
{
|
||||||
struct list_head *head;
|
|
||||||
struct dquot *dquot;
|
struct dquot *dquot;
|
||||||
unsigned long freed = 0;
|
unsigned long freed = 0;
|
||||||
|
|
||||||
spin_lock(&dq_list_lock);
|
spin_lock(&dq_list_lock);
|
||||||
head = free_dquots.next;
|
while (!list_empty(&free_dquots) && sc->nr_to_scan) {
|
||||||
while (head != &free_dquots && sc->nr_to_scan) {
|
dquot = list_first_entry(&free_dquots, struct dquot, dq_free);
|
||||||
dquot = list_entry(head, struct dquot, dq_free);
|
|
||||||
remove_dquot_hash(dquot);
|
remove_dquot_hash(dquot);
|
||||||
remove_free_dquot(dquot);
|
remove_free_dquot(dquot);
|
||||||
remove_inuse(dquot);
|
remove_inuse(dquot);
|
||||||
do_destroy_dquot(dquot);
|
do_destroy_dquot(dquot);
|
||||||
sc->nr_to_scan--;
|
sc->nr_to_scan--;
|
||||||
freed++;
|
freed++;
|
||||||
head = free_dquots.next;
|
|
||||||
}
|
}
|
||||||
spin_unlock(&dq_list_lock);
|
spin_unlock(&dq_list_lock);
|
||||||
return freed;
|
return freed;
|
||||||
|
|
Loading…
Reference in New Issue