From patchwork Thu Apr 24 16:23:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 4052721 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 4D9E19F271 for ; Thu, 24 Apr 2014 16:23:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F354201D5 for ; Thu, 24 Apr 2014 16:23:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A6162013A for ; Thu, 24 Apr 2014 16:23:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753810AbaDXQXp (ORCPT ); Thu, 24 Apr 2014 12:23:45 -0400 Received: from mail-ee0-f52.google.com ([74.125.83.52]:55188 "EHLO mail-ee0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754345AbaDXQXh (ORCPT ); Thu, 24 Apr 2014 12:23:37 -0400 Received: by mail-ee0-f52.google.com with SMTP id e49so2030912eek.39 for ; Thu, 24 Apr 2014 09:23:36 -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=3hzfRXZBcN6v/ErTv0d2W+8tqon2TO/ztz+aKDW4DDI=; b=k7/sIstbooX/fNF9sZwnEiZyTew+psFI6u6m+anTAzAIue2tHCBDeDC80R/H5+QDof TqsEtu5mzDPLZn3M26bKnLT+mpcsD9Y2sPK+qdOaYGGTJ1r8+yxVERlVg1IIvEydanMF Ns0hkj9c1dCQhMQ4gO0SCuoqmgRecFc0idTWsQdK0iDROyPIz4a4Rb8Mv8GgddbVJt8b wbVkW8BIVfuDHaB19ZJWPvBajuqL2oHyB6anxZBa/1+uNdeKuLLHIv3g7aYP7AK24w1e PlMWWRG/RlDvqb1rDdQMMdUo/OMcIrqtEhLAz0NYYzT/+axCV/VpsK0rWzSHp8ySAFvW SyWw== X-Gm-Message-State: ALoCoQk9u5OWThizzOpEbw/VfqJy0mj0edsT4FCGnahR6msoCKxvuwNqSoj7nUlUgpo94febENl/ X-Received: by 10.15.75.9 with SMTP id k9mr3442164eey.110.1398356616215; Thu, 24 Apr 2014 09:23:36 -0700 (PDT) Received: from localhost ([109.110.67.18]) by mx.google.com with ESMTPSA id t4sm17091455eeb.29.2014.04.24.09.23.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 24 Apr 2014 09:23:35 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 3/3] rbd: make sure we have latest osdmap on 'rbd map' Date: Thu, 24 Apr 2014 20:23:27 +0400 Message-Id: <1398356607-10666-4-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 Given an existing idle mapping (img1), mapping an image (img2) in a newly created pool (pool2) fails: $ ceph osd pool create pool1 8 8 $ rbd create --size 1000 pool1/img1 $ sudo rbd map pool1/img1 $ ceph osd pool create pool2 8 8 $ rbd create --size 1000 pool2/img2 $ sudo rbd map pool2/img2 rbd: sysfs write failed rbd: map failed: (2) No such file or directory This is because client instances are shared by default and we don't request an osdmap update when bumping a ref on an existing client. The fix is to use the mon_get_version request to see if the osdmap we have is the latest, and block until the requested update is received if it's not. Fixes: http://tracker.ceph.com/issues/8184 Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 552a2edcaa74..a3734726eef9 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -723,15 +723,34 @@ static int parse_rbd_opts_token(char *c, void *private) static struct rbd_client *rbd_get_client(struct ceph_options *ceph_opts) { struct rbd_client *rbdc; + u64 newest_epoch; mutex_lock_nested(&client_mutex, SINGLE_DEPTH_NESTING); rbdc = rbd_client_find(ceph_opts); - if (rbdc) /* using an existing client */ - ceph_destroy_options(ceph_opts); - else + if (!rbdc) { rbdc = rbd_client_create(ceph_opts); - mutex_unlock(&client_mutex); + mutex_unlock(&client_mutex); + return rbdc; + } + + /* + * Using an existing client, make sure we've got the latest + * osdmap. Ignore the errors though, as failing to get it + * doesn't necessarily prevent from working. + */ + if (ceph_monc_do_get_version(&rbdc->client->monc, "osdmap", + &newest_epoch) < 0) + goto out; + + if (rbdc->client->osdc.osdmap->epoch < newest_epoch) { + ceph_monc_request_next_osdmap(&rbdc->client->monc); + (void) ceph_monc_wait_osdmap(&rbdc->client->monc, newest_epoch, + rbdc->client->options->mount_timeout * HZ); + } +out: + mutex_unlock(&client_mutex); + ceph_destroy_options(ceph_opts); return rbdc; }