aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@icloud.com>2018-02-25 00:39:09 -0500
committerIlya Dryomov <idryomov@gmail.com>2018-04-02 04:12:47 -0400
commitb517c1d87faafba0c33a38ffdd551e8b399f0a31 (patch)
tree3275c9411f51d5414a4712ac2add42cc3985f3c0
parente327ce068518e38c0182739e879b9dce477c8d85 (diff)
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>
-rw-r--r--fs/ceph/caps.c16
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:
254int ceph_unreserve_caps(struct ceph_mds_client *mdsc, 254int ceph_unreserve_caps(struct ceph_mds_client *mdsc,
255 struct ceph_cap_reservation *ctx) 255 struct ceph_cap_reservation *ctx)
256{ 256{
257 int i;
258 struct ceph_cap *cap;
259
257 dout("unreserve caps ctx=%p count=%d\n", ctx, ctx->count); 260 dout("unreserve caps ctx=%p count=%d\n", ctx, ctx->count);
258 if (ctx->count) { 261 if (ctx->count) {
259 spin_lock(&mdsc->caps_list_lock); 262 spin_lock(&mdsc->caps_list_lock);
260 BUG_ON(mdsc->caps_reserve_count < ctx->count); 263 BUG_ON(mdsc->caps_reserve_count < ctx->count);
261 mdsc->caps_reserve_count -= ctx->count; 264 mdsc->caps_reserve_count -= ctx->count;
262 mdsc->caps_avail_count += ctx->count; 265 if (mdsc->caps_avail_count >=
266 mdsc->caps_reserve_count + mdsc->caps_min_count) {
267 mdsc->caps_total_count -= ctx->count;
268 for (i = 0; i < ctx->count; i++) {
269 cap = list_first_entry(&mdsc->caps_list,
270 struct ceph_cap, caps_item);
271 list_del(&cap->caps_item);
272 kmem_cache_free(ceph_cap_cachep, cap);
273 }
274 } else {
275 mdsc->caps_avail_count += ctx->count;
276 }
263 ctx->count = 0; 277 ctx->count = 0;
264 dout("unreserve caps %d = %d used + %d resv + %d avail\n", 278 dout("unreserve caps %d = %d used + %d resv + %d avail\n",
265 mdsc->caps_total_count, mdsc->caps_use_count, 279 mdsc->caps_total_count, mdsc->caps_use_count,