From patchwork Sat Jul 28 15:15:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10548003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8A3A139A for ; Sat, 28 Jul 2018 15:16:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B98C22B20D for ; Sat, 28 Jul 2018 15:16:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD6452B555; Sat, 28 Jul 2018 15:16:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D42E2B20D for ; Sat, 28 Jul 2018 15:16:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729072AbeG1Qns (ORCPT ); Sat, 28 Jul 2018 12:43:48 -0400 Received: from mout.gmx.net ([212.227.15.19]:43285 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729017AbeG1Qns (ORCPT ); Sat, 28 Jul 2018 12:43:48 -0400 Received: from localhost.localdomain ([113.87.89.132]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0M8ehf-1fxPPj3nbn-00wETf; Sat, 28 Jul 2018 17:16:53 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH 5/6] ceph: let ceph_trim_caps() return trimmed cap number Date: Sat, 28 Jul 2018 23:15:39 +0800 Message-Id: <20180728151540.11253-6-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180728151540.11253-1-cgxu519@gmx.com> References: <20180728151540.11253-1-cgxu519@gmx.com> X-Provags-ID: V03:K1:epbSht+ZvG8qJmOWUIR7dI0IBVd40NuchqCRzNtXymuh4NPGHbX W/xfBG4Uu3zn1PhbuF4zreXrD1P180buG2/e4wcCTOtmusqpBd6NDHNhyad6PzrN+1QiQmx /JtYNlUE04aH+dQTHnbBvxiFr+rVEFli5eZpX+7UJTjTZVIHHS7tDEeMhG5W3MNiXrOISBN s6n9s7NhT5JgcoUfM73WA== X-UI-Out-Filterresults: notjunk:1;V01:K0:8fAxLqSonws=:h0+wPHzQXxL1cvMi/fb9Iq W6K5EaJDQb284BBJp9C8b6/XA5ODKGNS1so3SPXRfWY49iWcN6xvHjOYS+4+cAd/y8bnLjJwv eIipVLcC62bgzfQA2K64Bt/BNIfowHJ9TNmbqqquwgcYIjoYyk53VOVCiytC1gAA+URZBuZCG RPZatFBebMkax2H7zR566kzK9RBv/ptoJ4B+0nldAm9D/756nkd1Q5Y/54WrdjwUPZO9Ld2Rl F3DCJdnzbazFeqBiwdj0SS0bA7zWid7DLrJMEwQmo23rp8DxJMKLGRT1mpp/Q1evn76iuwjxE DzP5+Z6WXOmdp/5zEPqsIytktrUK+UJmroQOEAcd25hvxAc4qdM6J/kpObmy6URaOyhXrOthI L+Tjd5C/kGwqX0bgYGtRGnsQs9tE8jol83XYp2271H9J1hbaggNvjMY8GDnueZ0wRL5MrNmXu 1oH4IPWwfRNfPjgF0mC8qklQEyayVq9256CHyDD8e5vp6wSxNrv0HnxnboAdsjZWxDF5HbQ0U HLBKw3V4jvNwlDy9ffdFxmjSSJQUiSs7smTxRvrjRwRHRgvHzKJu+38PTXx/khZF0fKhmD0xU DXi07aJhKElLIdPWikD6lse5IbfcXl2sLvdYmr4541ufFWL86pkVH1EXAI0Q1Qx7lqd9N0LXO oX76HZfywPtdKt2Kagm2lH1qgPfYBI6uo6n1EC17AqMm2r3B8yloK9fF0QtoCX/40vCYtTLSo IS0WnZ4TQWqHoYsWxUHBlLOA35+18itp21WqShas54NJRY5Tc/ATNcGQ5C8= Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When we failed allocating new cap in ceph_reserve_caps(), then try to trim existing caps from every session and try to reserve caps again. However, if we do not return trimmed cap number from ceph_trim_caps(), we cannot know how many caps released by one session, so we have to wait until trimming finish on all sessions. Sometimes, maybe a few of sessions (not all) can release enough caps so that we can do reservation more effectively. This patch let ceph_trim_caps() return trimmed cap number, so ceph_reserve_caps() can use this for optimization. Signed-off-by: Chengguang Xu --- fs/ceph/mds_client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index d01a262ba691..edccf2353912 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -1611,20 +1611,22 @@ int ceph_trim_caps(struct ceph_mds_client *mdsc, int max_caps) { int trim_caps = session->s_nr_caps - max_caps; + int trimmed_caps = 0; dout("trim_caps mds%d start: %d / %d, trim %d\n", session->s_mds, session->s_nr_caps, max_caps, trim_caps); if (trim_caps > 0) { session->s_trim_caps = trim_caps; iterate_session_caps(session, trim_caps_cb, session); + trimmed_caps = trim_caps - session->s_trim_caps; dout("trim_caps mds%d done: %d / %d, trimmed %d\n", session->s_mds, session->s_nr_caps, max_caps, - trim_caps - session->s_trim_caps); + trimmed_caps); session->s_trim_caps = 0; } ceph_send_cap_releases(mdsc, session); - return 0; + return trimmed_caps; } static int check_caps_flush(struct ceph_mds_client *mdsc,