From patchwork Mon Apr 21 13:26:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 4024931 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 954EFBFF02 for ; Mon, 21 Apr 2014 13:26:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96EE320304 for ; Mon, 21 Apr 2014 13:26:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E614201F5 for ; Mon, 21 Apr 2014 13:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752733AbaDUN0Y (ORCPT ); Mon, 21 Apr 2014 09:26:24 -0400 Received: from mail-ee0-f44.google.com ([74.125.83.44]:40318 "EHLO mail-ee0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752154AbaDUN0U (ORCPT ); Mon, 21 Apr 2014 09:26:20 -0400 Received: by mail-ee0-f44.google.com with SMTP id e49so3698163eek.3 for ; Mon, 21 Apr 2014 06:26:19 -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; bh=+lxtbjJihbTzNB9Cq/2H3XKtf/bPaQyIFZFgAxEHtU8=; b=mOVFcPOW+r97KK1IXm2r2mJduf6Y3UDKvkacjd59XrkujD/+xlss9lf6MjAxm4DcJK vp1wzhlj2y7QEEyemDDyA4BD9DRvVluvvr/lWSWRLsltq2bfWUbhYa5iyU9RI0cuBwBd pz8szxsKZaaJPy6ZOMRoMw6enjEQ/giVkZMSr5RvSftP49NLuxlCuoU9leng+zhSpRrC 7QdE0H2EJDIXrLickjYdhcN5gvD1gnCJadNjVR5A/RsjCaASbPPxefiejGdwgjcebpm2 2qHlzMVkifiv6ETjbytrWTgroallnKb3aUdIwlo+uE++Ienzchzq5Pu7VRIVHVvzlVis 6tMA== X-Gm-Message-State: ALoCoQkYHJbkjDOX3IJJP5sgbwKzLa1J9yhapX1qL63AIBFqRK/Ix6ybytGtUZmXiZcclkbYl7cF X-Received: by 10.14.105.4 with SMTP id j4mr48116886eeg.41.1398086779228; Mon, 21 Apr 2014 06:26:19 -0700 (PDT) Received: from localhost ([109.110.67.18]) by mx.google.com with ESMTPSA id w12sm103630548eez.36.2014.04.21.06.26.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 21 Apr 2014 06:26:18 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 1/2] libceph: add ceph_monc_wait_next_osdmap() Date: Mon, 21 Apr 2014 17:26:15 +0400 Message-Id: <1398086776-7228-1-git-send-email-ilya.dryomov@inktank.com> X-Mailer: git-send-email 1.7.10.4 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_next_osdmap(), which will block until the next requested with ceph_monc_request_next_osdmap() osdmap 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 a486f390dfbe..5444897e8ebd 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_next_osdmap(struct ceph_mon_client *monc, + 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 2ac9ef35110b..39953ba83b4c 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_next_osdmap(struct ceph_mon_client *monc, + unsigned long timeout) +{ + unsigned long started = jiffies; + int ret; + + mutex_lock(&monc->mutex); + while (monc->want_next_osdmap != 0) { + 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->want_next_osdmap == 0, timeout); + if (ret < 0) + return ret; + + mutex_lock(&monc->mutex); + } + + mutex_unlock(&monc->mutex); + return 0; +} +EXPORT_SYMBOL(ceph_monc_wait_next_osdmap); /* *