Commit b517c1d8 authored by Chengguang Xu's avatar Chengguang Xu Committed by Ilya Dryomov

ceph: release unreserved caps if having enough available caps

When unreserving caps check if there is too mamy available caps
in the ->caps_list, if so release unreserved caps.
Signed-off-by: default avatarChengguang Xu <cgxu519@icloud.com>
Reviewed-by: default avatar"Yan, Zheng" <zyan@redhat.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent e327ce06
...@@ -254,12 +254,26 @@ int ceph_reserve_caps(struct ceph_mds_client *mdsc, ...@@ -254,12 +254,26 @@ int ceph_reserve_caps(struct ceph_mds_client *mdsc,
int ceph_unreserve_caps(struct ceph_mds_client *mdsc, int ceph_unreserve_caps(struct ceph_mds_client *mdsc,
struct ceph_cap_reservation *ctx) struct ceph_cap_reservation *ctx)
{ {
int i;
struct ceph_cap *cap;
dout("unreserve caps ctx=%p count=%d\n", ctx, ctx->count); dout("unreserve caps ctx=%p count=%d\n", ctx, ctx->count);
if (ctx->count) { if (ctx->count) {
spin_lock(&mdsc->caps_list_lock); spin_lock(&mdsc->caps_list_lock);
BUG_ON(mdsc->caps_reserve_count < ctx->count); BUG_ON(mdsc->caps_reserve_count < ctx->count);
mdsc->caps_reserve_count -= ctx->count; mdsc->caps_reserve_count -= ctx->count;
mdsc->caps_avail_count += ctx->count; if (mdsc->caps_avail_count >=
mdsc->caps_reserve_count + mdsc->caps_min_count) {
mdsc->caps_total_count -= ctx->count;
for (i = 0; i < ctx->count; i++) {
cap = list_first_entry(&mdsc->caps_list,
struct ceph_cap, caps_item);
list_del(&cap->caps_item);
kmem_cache_free(ceph_cap_cachep, cap);
}
} else {
mdsc->caps_avail_count += ctx->count;
}
ctx->count = 0; ctx->count = 0;
dout("unreserve caps %d = %d used + %d resv + %d avail\n", dout("unreserve caps %d = %d used + %d resv + %d avail\n",
mdsc->caps_total_count, mdsc->caps_use_count, mdsc->caps_total_count, mdsc->caps_use_count,
......
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