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: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
parent
961fe3422e
commit
faada74a90
@ -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_sbd *sdp = qd->qd_sbd;
|
||||
|
||||
spin_lock(&qd_lock);
|
||||
list_del(&qd->qd_list);
|
||||
spin_unlock(&qd_lock);
|
||||
|
||||
spin_lock_bucket(qd->qd_hash);
|
||||
hlist_bl_del_rcu(&qd->qd_hlist);
|
||||
spin_unlock_bucket(qd->qd_hash);
|
||||
|
||||
gfs2_assert_warn(sdp, !qd->qd_change);
|
||||
gfs2_assert_warn(sdp, !qd->qd_slot_count);
|
||||
gfs2_assert_warn(sdp, !qd->qd_bh_count);
|
||||
|
||||
gfs2_glock_put(qd->qd_gl);
|
||||
call_rcu(&qd->qd_rcu, gfs2_qd_dealloc);
|
||||
}
|
||||
|
||||
static void gfs2_qd_list_dispose(struct list_head *list)
|
||||
{
|
||||
struct gfs2_quota_data *qd;
|
||||
struct gfs2_sbd *sdp;
|
||||
|
||||
while (!list_empty(list)) {
|
||||
qd = list_first_entry(list, struct gfs2_quota_data, qd_lru);
|
||||
sdp = qd->qd_sbd;
|
||||
|
||||
list_del(&qd->qd_lru);
|
||||
|
||||
/* Free from the filesystem-specific list */
|
||||
spin_lock(&qd_lock);
|
||||
list_del(&qd->qd_list);
|
||||
spin_unlock(&qd_lock);
|
||||
|
||||
spin_lock_bucket(qd->qd_hash);
|
||||
hlist_bl_del_rcu(&qd->qd_hlist);
|
||||
spin_unlock_bucket(qd->qd_hash);
|
||||
|
||||
gfs2_assert_warn(sdp, !qd->qd_change);
|
||||
gfs2_assert_warn(sdp, !qd->qd_slot_count);
|
||||
gfs2_assert_warn(sdp, !qd->qd_bh_count);
|
||||
|
||||
gfs2_glock_put(qd->qd_gl);
|
||||
gfs2_qd_dispose(qd);
|
||||
atomic_dec(&sdp->sd_quota_count);
|
||||
|
||||
/* Delete it from the common reclaim list */
|
||||
call_rcu(&qd->qd_rcu, gfs2_qd_dealloc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user