From patchwork Thu Apr 24 16:23:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 4052711 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 5238DC0ACC for ; Thu, 24 Apr 2014 16:23:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D143201D5 for ; Thu, 24 Apr 2014 16:23:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1C31202F0 for ; Thu, 24 Apr 2014 16:23:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754688AbaDXQXi (ORCPT ); Thu, 24 Apr 2014 12:23:38 -0400 Received: from mail-ee0-f54.google.com ([74.125.83.54]:49381 "EHLO mail-ee0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753363AbaDXQXf (ORCPT ); Thu, 24 Apr 2014 12:23:35 -0400 Received: by mail-ee0-f54.google.com with SMTP id d49so2074461eek.27 for ; Thu, 24 Apr 2014 09:23:34 -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=2XJ7w8S5VdqmYdXb69H65VlFNTf8uQu/AkzEbhkrWXY=; b=dH76TmgsjBViOFQOMmxlsCuZhlHZ7Nwhwky0zpDGjFgaQ4B1KSHOMKvdtYpzM9UD8a W2rYO/IWpthL+BaawQ9Cg82z9mjR/lqvcM3IybyYQFaW02irGa+zhBzasJpAWVBRzAXu eUDH/Pnf9P8W2PuLgIXadOZGKuD1+DtbfGbBHoO22Tm1H10VpPHDkdCBcG9qZKGrJSXP p67QRseaykhk7u1/nB5YNOpGUv2UuF6A3y8umyuaWWM9kvSpfLhFrvRFoD8AEv5KrReO naA2zfsZgCNol8vzxIcGpxirTBd6Lcta5nJWKHCPINVR2AHUJqj1Y81zV8j7/qnh0Mqj Svyg== X-Gm-Message-State: ALoCoQl03DYeWuxgnJG42JeLku3fbiN+31KyuJrVE0xmR5UTLVHOTEjjyv2nWQdpkMl1eZKNjDfz X-Received: by 10.14.241.139 with SMTP id g11mr3367223eer.49.1398356614066; Thu, 24 Apr 2014 09:23:34 -0700 (PDT) Received: from localhost ([109.110.67.18]) by mx.google.com with ESMTPSA id 4sm17089557eeq.33.2014.04.24.09.23.32 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 24 Apr 2014 09:23:33 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 2/3] libceph: add ceph_monc_wait_osdmap() Date: Thu, 24 Apr 2014 20:23:26 +0400 Message-Id: <1398356607-10666-3-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1398356607-10666-1-git-send-email-ilya.dryomov@inktank.com> References: <1398356607-10666-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 --- 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 d8060dd87f16..99ea0d60042f 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 d64023965d1c..7aa1ab1dbbf6 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); /* *