diff options
author | Chengguang Xu <cgxu519@icloud.com> | 2018-02-25 13:39:09 +0800 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2018-04-02 10:12:47 +0200 |
commit | b517c1d87faafba0c33a38ffdd551e8b399f0a31 (patch) | |
tree | 3275c9411f51d5414a4712ac2add42cc3985f3c0 /fs/ceph | |
parent | e327ce068518e38c0182739e879b9dce477c8d85 (diff) | |
download | talos-op-linux-b517c1d87faafba0c33a38ffdd551e8b399f0a31.tar.gz talos-op-linux-b517c1d87faafba0c33a38ffdd551e8b399f0a31.zip |
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: Chengguang Xu <cgxu519@icloud.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/caps.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 421cdce71fb0..b9b5c47efd06 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -254,12 +254,26 @@ out_nomem: int ceph_unreserve_caps(struct ceph_mds_client *mdsc, struct ceph_cap_reservation *ctx) { + int i; + struct ceph_cap *cap; + dout("unreserve caps ctx=%p count=%d\n", ctx, ctx->count); if (ctx->count) { spin_lock(&mdsc->caps_list_lock); BUG_ON(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; dout("unreserve caps %d = %d used + %d resv + %d avail\n", mdsc->caps_total_count, mdsc->caps_use_count, |