From patchwork Wed Jun 26 03:15:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: majianpeng X-Patchwork-Id: 2782591 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 819BCC0AB1 for ; Wed, 26 Jun 2013 03:15:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 041CC201FC for ; Wed, 26 Jun 2013 03:15:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AB0B201FA for ; Wed, 26 Jun 2013 03:15:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751445Ab3FZDPf (ORCPT ); Tue, 25 Jun 2013 23:15:35 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:39008 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751314Ab3FZDPe (ORCPT ); Tue, 25 Jun 2013 23:15:34 -0400 Received: by mail-pb0-f46.google.com with SMTP id rq2so13453465pbb.5 for ; Tue, 25 Jun 2013 20:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:reply-to:subject:x-priority:x-guid:x-has-attach :x-mailer:mime-version:message-id:content-type :content-transfer-encoding; bh=S6IUTS6OD0yyfmkUoFCNaB3jf47RBsq2cojWWmQhEow=; b=G/4iaTuHIM9eek64130jyet9x4IKtECcPpd3UkzRPX0nsVFK8YpUGR2aHpq+PSv/Ys NtlEnE9jEcOLQv4zV7qihYqYRsuN3aj+lYnh42WvbHu0ex5ktxX3eWZoRB7BYXJivAEh sUI7mjw11iQgM6UQuvU3cTStk8u6wcJEO/P04EkHA+7zgvGN91xhwMrWfKqClCEXpVAP /g3Atg1HP86+4WlDAfxj6yY3vWKqc8OhtAF0DsBfjodgCTg7qaEvNsy4YA2wSwfwRMMr cO6H7ycad7HK8HV/8UQ9k6g8thBkNbIxlGYNxhR8lA9rpZDMGCEswrge+J9zO8AQClfi kVCw== X-Received: by 10.66.222.226 with SMTP id qp2mr2723411pac.102.1372216532748; Tue, 25 Jun 2013 20:15:32 -0700 (PDT) Received: from majianpeng ([218.242.10.182]) by mx.google.com with ESMTPSA id vu5sm28148203pab.10.2013.06.25.20.15.24 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 25 Jun 2013 20:15:31 -0700 (PDT) Date: Wed, 26 Jun 2013 11:15:27 +0800 From: majianpeng To: sage Cc: ceph-devel , linux-kernel Reply-To: majianpeng Subject: [PATCH] ceph: Reconstruct the func ceph_reserve_caps. X-Priority: 3 X-GUID: F902CAEB-0E08-4FD8-B02E-87353B707EB6 X-Has-Attach: no X-Mailer: Foxmail 7.0.1.90[en] Mime-Version: 1.0 Message-ID: <201306261115191951258@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jianpeng Ma --- fs/ceph/caps.c | 21 +++++++-------------- fs/ceph/super.h | 2 +- 2 files changed, 8 insertions(+), 15 deletions(-) -- 1.8.1.2 diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index da0f9b8..6d2655c 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -147,7 +147,7 @@ void ceph_adjust_min_caps(struct ceph_mds_client *mdsc, int delta) spin_unlock(&mdsc->caps_list_lock); } -int ceph_reserve_caps(struct ceph_mds_client *mdsc, +void ceph_reserve_caps(struct ceph_mds_client *mdsc, struct ceph_cap_reservation *ctx, int need) { int i; @@ -155,7 +155,6 @@ int ceph_reserve_caps(struct ceph_mds_client *mdsc, int have; int alloc = 0; LIST_HEAD(newcaps); - int ret = 0; dout("reserve caps ctx=%p need=%d\n", ctx, need); @@ -174,14 +173,15 @@ int ceph_reserve_caps(struct ceph_mds_client *mdsc, for (i = have; i < need; i++) { cap = kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS); - if (!cap) { - ret = -ENOMEM; - goto out_alloc_count; - } + if (!cap) + break; list_add(&cap->caps_item, &newcaps); alloc++; } - BUG_ON(have + alloc != need); + /* we didn't manage to reserve as much as we needed */ + if (have + alloc != need) + pr_warn("reserve caps ctx=%p ENOMEM need=%d got=%d\n", + ctx, need, have + alloc); spin_lock(&mdsc->caps_list_lock); mdsc->caps_total_count += alloc; @@ -197,13 +197,6 @@ int ceph_reserve_caps(struct ceph_mds_client *mdsc, dout("reserve caps ctx=%p %d = %d used + %d resv + %d avail\n", ctx, mdsc->caps_total_count, mdsc->caps_use_count, mdsc->caps_reserve_count, mdsc->caps_avail_count); - return 0; - -out_alloc_count: - /* we didn't manage to reserve as much as we needed */ - pr_warning("reserve caps ctx=%p ENOMEM need=%d got=%d\n", - ctx, need, have); - return ret; } int ceph_unreserve_caps(struct ceph_mds_client *mdsc, diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 7ccfdb4..dfbb729 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -534,7 +534,7 @@ extern int __ceph_caps_mds_wanted(struct ceph_inode_info *ci); extern void ceph_caps_init(struct ceph_mds_client *mdsc); extern void ceph_caps_finalize(struct ceph_mds_client *mdsc); extern void ceph_adjust_min_caps(struct ceph_mds_client *mdsc, int delta); -extern int ceph_reserve_caps(struct ceph_mds_client *mdsc, +extern void ceph_reserve_caps(struct ceph_mds_client *mdsc, struct ceph_cap_reservation *ctx, int need); extern int ceph_unreserve_caps(struct ceph_mds_client *mdsc, struct ceph_cap_reservation *ctx);