Commit faada74a authored by Andreas Gruenbacher's avatar Andreas Gruenbacher

gfs2: Factor out duplicate quota data disposal code

Rename gfs2_qd_dispose() to gfs2_qd_dispose_list().  Move some code
duplicated in gfs2_qd_dispose_list() and gfs2_quota_cleanup() into a
new gfs2_qd_dispose() function.
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
parent 961fe342
...@@ -112,35 +112,36 @@ static void gfs2_qd_dealloc(struct rcu_head *rcu) ...@@ -112,35 +112,36 @@ static void gfs2_qd_dealloc(struct rcu_head *rcu)
kmem_cache_free(gfs2_quotad_cachep, qd); kmem_cache_free(gfs2_quotad_cachep, qd);
} }
static void gfs2_qd_dispose(struct list_head *list) static void gfs2_qd_dispose(struct gfs2_quota_data *qd)
{ {
struct gfs2_quota_data *qd; struct gfs2_sbd *sdp = qd->qd_sbd;
struct gfs2_sbd *sdp;
while (!list_empty(list)) { spin_lock(&qd_lock);
qd = list_first_entry(list, struct gfs2_quota_data, qd_lru); list_del(&qd->qd_list);
sdp = qd->qd_sbd; spin_unlock(&qd_lock);
list_del(&qd->qd_lru); spin_lock_bucket(qd->qd_hash);
hlist_bl_del_rcu(&qd->qd_hlist);
spin_unlock_bucket(qd->qd_hash);
/* Free from the filesystem-specific list */ gfs2_assert_warn(sdp, !qd->qd_change);
spin_lock(&qd_lock); gfs2_assert_warn(sdp, !qd->qd_slot_count);
list_del(&qd->qd_list); gfs2_assert_warn(sdp, !qd->qd_bh_count);
spin_unlock(&qd_lock);
spin_lock_bucket(qd->qd_hash); gfs2_glock_put(qd->qd_gl);
hlist_bl_del_rcu(&qd->qd_hlist); call_rcu(&qd->qd_rcu, gfs2_qd_dealloc);
spin_unlock_bucket(qd->qd_hash); }
gfs2_assert_warn(sdp, !qd->qd_change); static void gfs2_qd_list_dispose(struct list_head *list)
gfs2_assert_warn(sdp, !qd->qd_slot_count); {
gfs2_assert_warn(sdp, !qd->qd_bh_count); struct gfs2_quota_data *qd;
gfs2_glock_put(qd->qd_gl); while (!list_empty(list)) {
atomic_dec(&sdp->sd_quota_count); qd = list_first_entry(list, struct gfs2_quota_data, qd_lru);
list_del(&qd->qd_lru);
/* Delete it from the common reclaim list */ gfs2_qd_dispose(qd);
call_rcu(&qd->qd_rcu, gfs2_qd_dealloc); atomic_dec(&sdp->sd_quota_count);
} }
} }
...@@ -179,7 +180,7 @@ static unsigned long gfs2_qd_shrink_scan(struct shrinker *shrink, ...@@ -179,7 +180,7 @@ static unsigned long gfs2_qd_shrink_scan(struct shrinker *shrink,
freed = list_lru_shrink_walk(&gfs2_qd_lru, sc, freed = list_lru_shrink_walk(&gfs2_qd_lru, sc,
gfs2_qd_isolate, &dispose); gfs2_qd_isolate, &dispose);
gfs2_qd_dispose(&dispose); gfs2_qd_list_dispose(&dispose);
return freed; return freed;
} }
...@@ -1469,7 +1470,7 @@ void gfs2_quota_cleanup(struct gfs2_sbd *sdp) ...@@ -1469,7 +1470,7 @@ void gfs2_quota_cleanup(struct gfs2_sbd *sdp)
} }
spin_unlock(&qd_lock); spin_unlock(&qd_lock);
gfs2_qd_dispose(&dispose); gfs2_qd_list_dispose(&dispose);
gfs2_assert_warn(sdp, !atomic_read(&sdp->sd_quota_count)); gfs2_assert_warn(sdp, !atomic_read(&sdp->sd_quota_count));
kvfree(sdp->sd_quota_bitmap); kvfree(sdp->sd_quota_bitmap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment