From patchwork Mon Feb 3 13:47:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 3569571 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 5655FC02DD for ; Mon, 3 Feb 2014 13:47:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 859EF201BA for ; Mon, 3 Feb 2014 13:47:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A205420176 for ; Mon, 3 Feb 2014 13:47:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751866AbaBCNrZ (ORCPT ); Mon, 3 Feb 2014 08:47:25 -0500 Received: from mail-we0-f182.google.com ([74.125.82.182]:41255 "EHLO mail-we0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752312AbaBCNrT (ORCPT ); Mon, 3 Feb 2014 08:47:19 -0500 Received: by mail-we0-f182.google.com with SMTP id u57so2249103wes.27 for ; Mon, 03 Feb 2014 05:47:18 -0800 (PST) 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=Dg7fY/SAB0PAecKJ/Ciuc8Lld8YYstyD25U20TPCPw4=; b=NL2CYyal1ifz1b4S8ZPKntHcoXLe1wpB7jUvfEWvd0kjQ0SDafquUmL5z6lKWhxQeD ou25oNXkpHBbwJQrJwlOWTDb3HLIVFO/tpq8CpEdZi08rqrz2omQaeV7E5nMfbrcKaV0 nLIwzIQEVbtP/0SByDpbfqKgZ8WwrDoXihvFKJKKTpTQX0nm3C3FqDqwWfPYWdglfcwj YCBdgZWor3dLW4iQabHV0PYaadOhazxXvlka6jK9r9MPgpRTWE2m8DQ7rWstTK1PASk5 hr/mZ+NGJJG0xFFa03qjF/kTgdOEB6CCx5kzjMTsEl2w43QyKBH+UU5d6WSE3QF4H1XQ lNAQ== X-Gm-Message-State: ALoCoQlqzSNb2UZiU4QCvEKTdwaIziwKuqVEY8ClmlZWeCxJwQhMWwK347boAcuSwoTt2gW42LVg X-Received: by 10.180.211.68 with SMTP id na4mr8922113wic.0.1391435238439; Mon, 03 Feb 2014 05:47:18 -0800 (PST) Received: from localhost ([109.110.66.110]) by mx.google.com with ESMTPSA id e18sm26007334wic.4.2014.02.03.05.47.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 03 Feb 2014 05:47:17 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 3/4] libceph: factor out logic from ceph_osdc_start_request() Date: Mon, 3 Feb 2014 15:47:07 +0200 Message-Id: <1391435228-27874-4-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1391435228-27874-1-git-send-email-ilya.dryomov@inktank.com> References: <1391435228-27874-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=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Factor out logic from ceph_osdc_start_request() into a new helper, __ceph_osdc_start_request(). ceph_osdc_start_request() now amounts to taking locks and calling __ceph_osdc_start_request(). Signed-off-by: Ilya Dryomov --- net/ceph/osd_client.c | 62 +++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 166d4c7ba065..2aa82b6bb305 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -1427,6 +1427,40 @@ static void __send_queued(struct ceph_osd_client *osdc) } /* + * Caller should hold map_sem for read and request_mutex. + */ +static int __ceph_osdc_start_request(struct ceph_osd_client *osdc, + struct ceph_osd_request *req, + bool nofail) +{ + int rc; + + __register_request(osdc, req); + req->r_sent = 0; + req->r_got_reply = 0; + rc = __map_request(osdc, req, 0); + if (rc < 0) { + if (nofail) { + dout("osdc_start_request failed map, " + " will retry %lld\n", req->r_tid); + rc = 0; + } else { + __unregister_request(osdc, req); + } + return rc; + } + + if (req->r_osd == NULL) { + dout("send_request %p no up osds in pg\n", req); + ceph_monc_request_next_osdmap(&osdc->client->monc); + } else { + __send_queued(osdc); + } + + return 0; +} + +/* * Timeout callback, called every N seconds when 1 or more osd * requests has been active for more than N seconds. When this * happens, we ping all OSDs with requests who have timed out to @@ -2351,34 +2385,16 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc, struct ceph_osd_request *req, bool nofail) { - int rc = 0; + int rc; down_read(&osdc->map_sem); mutex_lock(&osdc->request_mutex); - __register_request(osdc, req); - req->r_sent = 0; - req->r_got_reply = 0; - rc = __map_request(osdc, req, 0); - if (rc < 0) { - if (nofail) { - dout("osdc_start_request failed map, " - " will retry %lld\n", req->r_tid); - rc = 0; - } else { - __unregister_request(osdc, req); - } - goto out_unlock; - } - if (req->r_osd == NULL) { - dout("send_request %p no up osds in pg\n", req); - ceph_monc_request_next_osdmap(&osdc->client->monc); - } else { - __send_queued(osdc); - } - rc = 0; -out_unlock: + + rc = __ceph_osdc_start_request(osdc, req, nofail); + mutex_unlock(&osdc->request_mutex); up_read(&osdc->map_sem); + return rc; } EXPORT_SYMBOL(ceph_osdc_start_request);