From patchwork Wed Jun 25 17:16:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 4422341 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6B6119F1D6 for ; Wed, 25 Jun 2014 17:17:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9BFCE20394 for ; Wed, 25 Jun 2014 17:16:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C2F132038D for ; Wed, 25 Jun 2014 17:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757520AbaFYRQ5 (ORCPT ); Wed, 25 Jun 2014 13:16:57 -0400 Received: from mail-lb0-f177.google.com ([209.85.217.177]:50119 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757311AbaFYRQ4 (ORCPT ); Wed, 25 Jun 2014 13:16:56 -0400 Received: by mail-lb0-f177.google.com with SMTP id u10so2031043lbd.8 for ; Wed, 25 Jun 2014 10:16:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=20Rcl+eL7kmX8gRz1kzUbs5+MupPV0X3AWSwqFDEbUQ=; b=eTMdjmciIASN11PdDbEN09nD7sosU45K9YNuML01BTwab972EpMrnzbyv38LQ1f1V6 Um/4IeLJeoH4sEck9N47tcWOiXpu/OnpnlSCtwLrH0FaPDQuURXJG/0npmjjTemQiPS6 OmRyggYTW7vxIPgO2L6B491AVs82v40ALqLWAM0dHRfUvy5OACqdloHLmMaayOKggdRt 85gQns0J3Ml1VQxKTf8HSnvLud0GusFlvYMUVCLpp7sy/0o+LnDyWFgnhYUZk8dpNg04 v8N4KUZsQQi3VDBg7i4j3TbDiYnf8tO0BNEVVRQCcB468/AsRU+m0c7CZd83N+DlKFbb UTxQ== X-Gm-Message-State: ALoCoQkBEg5GZOXuABiohXjqtMgZ4XB+CusGODtS93NiFQu8peg/NUR62TEz/HFRV7KmX3oi3Tfz X-Received: by 10.112.235.3 with SMTP id ui3mr1814225lbc.93.1403716615307; Wed, 25 Jun 2014 10:16:55 -0700 (PDT) Received: from localhost ([109.110.67.53]) by mx.google.com with ESMTPSA id jf10sm1810387lac.26.2014.06.25.10.16.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 25 Jun 2014 10:16:54 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 02/14] libceph: add maybe_move_osd_to_lru() and switch to it Date: Wed, 25 Jun 2014 21:16:35 +0400 Message-Id: <1403716607-13535-3-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1403716607-13535-1-git-send-email-ilya.dryomov@inktank.com> References: <1403716607-13535-1-git-send-email-ilya.dryomov@inktank.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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Abstract out __move_osd_to_lru() logic from __unregister_request() and __unregister_linger_request(). Signed-off-by: Ilya Dryomov Reviewed-by: Alex Elder --- net/ceph/osd_client.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index d5d2be3bd113..6202923b41ff 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -1029,12 +1029,23 @@ static void remove_all_osds(struct ceph_osd_client *osdc) static void __move_osd_to_lru(struct ceph_osd_client *osdc, struct ceph_osd *osd) { - dout("__move_osd_to_lru %p\n", osd); + dout("%s %p\n", __func__, osd); BUG_ON(!list_empty(&osd->o_osd_lru)); + list_add_tail(&osd->o_osd_lru, &osdc->osd_lru); osd->lru_ttl = jiffies + osdc->client->options->osd_idle_ttl * HZ; } +static void maybe_move_osd_to_lru(struct ceph_osd_client *osdc, + struct ceph_osd *osd) +{ + dout("%s %p\n", __func__, osd); + + if (list_empty(&osd->o_requests) && + list_empty(&osd->o_linger_requests)) + __move_osd_to_lru(osdc, osd); +} + static void __remove_osd_from_lru(struct ceph_osd *osd) { dout("__remove_osd_from_lru %p\n", osd); @@ -1182,11 +1193,7 @@ static void __unregister_request(struct ceph_osd_client *osdc, ceph_msg_revoke(req->r_request); list_del_init(&req->r_osd_item); - if (list_empty(&req->r_osd->o_requests) && - list_empty(&req->r_osd->o_linger_requests)) { - dout("moving osd to %p lru\n", req->r_osd); - __move_osd_to_lru(osdc, req->r_osd); - } + maybe_move_osd_to_lru(osdc, req->r_osd); if (list_empty(&req->r_linger_item)) req->r_osd = NULL; } @@ -1229,12 +1236,7 @@ static void __unregister_linger_request(struct ceph_osd_client *osdc, list_del_init(&req->r_linger_item); if (req->r_osd) { list_del_init(&req->r_linger_osd_item); - - if (list_empty(&req->r_osd->o_requests) && - list_empty(&req->r_osd->o_linger_requests)) { - dout("moving osd to %p lru\n", req->r_osd); - __move_osd_to_lru(osdc, req->r_osd); - } + maybe_move_osd_to_lru(osdc, req->r_osd); if (list_empty(&req->r_osd_item)) req->r_osd = NULL; }