From patchwork Thu May 22 16:50: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: 4224711 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 1C553BF90B for ; Thu, 22 May 2014 16:50:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 426942037E for ; Thu, 22 May 2014 16:50:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 787842011D for ; Thu, 22 May 2014 16:50:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752171AbaEVQuV (ORCPT ); Thu, 22 May 2014 12:50:21 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:46849 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751888AbaEVQuT (ORCPT ); Thu, 22 May 2014 12:50:19 -0400 Received: by mail-wi0-f170.google.com with SMTP id bs8so10172842wib.1 for ; Thu, 22 May 2014 09:50:18 -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=IczP5U0dSop2EzAepLRe8Fzna535OhGolEEZtGhWr9s=; b=nNlvJM8hT5l/Fv4ac/5Vbu9s5HOeKRhlTZHY+1xvaj8bRUYF+ExfnYm+ONH7gekz+1 APupa0qhu5xmymIaLUzgOR/LlcS2soMMnTJBPdgLUP3aRrdwqe2GzKdq+MS3NeRAMWHQ aaTH/FHPEKRScIxITeIse4/jqQIPKkrrVD07u6EvKioGirxFOEvqJSOr1PnT1KQSa0C7 6NJMp3jfUibRYqzjcMSVKjHvygcu70w8dVBCI2M38/O0JxBW74Zp+gLRlqVCcjxGpcfX b3ucGd0JA9nV3BftKfei3963uVPtaeYzpHu/a1zyEUpeRA6+wCS+Z9U4zCjbF2JERgmx RGzA== X-Gm-Message-State: ALoCoQkQIGgwPT6IGc19W8CI8QvPZeeLCMAYcMi9XEXeP7pYTfkRFKDGXnWttkEdSRCDssot6Ore X-Received: by 10.194.174.168 with SMTP id bt8mr1564030wjc.72.1400777418407; Thu, 22 May 2014 09:50:18 -0700 (PDT) Received: from localhost ([109.110.67.203]) by mx.google.com with ESMTPSA id d6sm1251191wiz.4.2014.05.22.09.50.16 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 22 May 2014 09:50:17 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH v3 3/4] libceph: add ceph_monc_wait_osdmap() Date: Thu, 22 May 2014 20:50:07 +0400 Message-Id: <1400777408-7016-4-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1400777408-7016-1-git-send-email-ilya.dryomov@inktank.com> References: <1400777408-7016-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.5 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 Add ceph_monc_wait_osdmap(), which will block until the osdmap with the specified epoch is received or timeout occurs. Export both of these as they are going to be needed by rbd. Signed-off-by: Ilya Dryomov Reviewed-by: --- include/linux/ceph/mon_client.h | 2 ++ net/ceph/mon_client.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/linux/ceph/mon_client.h b/include/linux/ceph/mon_client.h index 585ef9450e9d..deb47e45ac7c 100644 --- a/include/linux/ceph/mon_client.h +++ b/include/linux/ceph/mon_client.h @@ -104,6 +104,8 @@ extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 have); extern int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 have); extern void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc); +extern int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch, + unsigned long timeout); extern int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf); diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c index 6b46f1205ceb..ecfd65c05f49 100644 --- a/net/ceph/mon_client.c +++ b/net/ceph/mon_client.c @@ -296,6 +296,33 @@ void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc) __send_subscribe(monc); mutex_unlock(&monc->mutex); } +EXPORT_SYMBOL(ceph_monc_request_next_osdmap); + +int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch, + unsigned long timeout) +{ + unsigned long started = jiffies; + int ret; + + mutex_lock(&monc->mutex); + while (monc->have_osdmap < epoch) { + mutex_unlock(&monc->mutex); + + if (timeout != 0 && time_after_eq(jiffies, started + timeout)) + return -ETIMEDOUT; + + ret = wait_event_interruptible_timeout(monc->client->auth_wq, + monc->have_osdmap >= epoch, timeout); + if (ret < 0) + return ret; + + mutex_lock(&monc->mutex); + } + + mutex_unlock(&monc->mutex); + return 0; +} +EXPORT_SYMBOL(ceph_monc_wait_osdmap); /* *