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)
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;
struct gfs2_sbd *sdp = qd->qd_sbd;
while (!list_empty(list)) {
qd = list_first_entry(list, struct gfs2_quota_data, qd_lru);
sdp = qd->qd_sbd;
spin_lock(&qd_lock);
list_del(&qd->qd_list);
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 */
spin_lock(&qd_lock);
list_del(&qd->qd_list);
spin_unlock(&qd_lock);
gfs2_assert_warn(sdp, !qd->qd_change);
gfs2_assert_warn(sdp, !qd->qd_slot_count);
gfs2_assert_warn(sdp, !qd->qd_bh_count);
spin_lock_bucket(qd->qd_hash);
hlist_bl_del_rcu(&qd->qd_hlist);
spin_unlock_bucket(qd->qd_hash);
gfs2_glock_put(qd->qd_gl);
call_rcu(&qd->qd_rcu, gfs2_qd_dealloc);
}
gfs2_assert_warn(sdp, !qd->qd_change);
gfs2_assert_warn(sdp, !qd->qd_slot_count);
gfs2_assert_warn(sdp, !qd->qd_bh_count);
static void gfs2_qd_list_dispose(struct list_head *list)
{
struct gfs2_quota_data *qd;
gfs2_glock_put(qd->qd_gl);
atomic_dec(&sdp->sd_quota_count);
while (!list_empty(list)) {
qd = list_first_entry(list, struct gfs2_quota_data, qd_lru);
list_del(&qd->qd_lru);
/* Delete it from the common reclaim list */
call_rcu(&qd->qd_rcu, gfs2_qd_dealloc);
gfs2_qd_dispose(qd);
atomic_dec(&sdp->sd_quota_count);
}
}
......@@ -179,7 +180,7 @@ static unsigned long gfs2_qd_shrink_scan(struct shrinker *shrink,
freed = list_lru_shrink_walk(&gfs2_qd_lru, sc,
gfs2_qd_isolate, &dispose);
gfs2_qd_dispose(&dispose);
gfs2_qd_list_dispose(&dispose);
return freed;
}
......@@ -1469,7 +1470,7 @@ void gfs2_quota_cleanup(struct gfs2_sbd *sdp)
}
spin_unlock(&qd_lock);
gfs2_qd_dispose(&dispose);
gfs2_qd_list_dispose(&dispose);
gfs2_assert_warn(sdp, !atomic_read(&sdp->sd_quota_count));
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