From patchwork Wed Oct 31 01:49:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1675361 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id CE87C3FD8C for ; Wed, 31 Oct 2012 01:49:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932614Ab2JaBtl (ORCPT ); Tue, 30 Oct 2012 21:49:41 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:58325 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932421Ab2JaBtk (ORCPT ); Tue, 30 Oct 2012 21:49:40 -0400 Received: by mail-ie0-f174.google.com with SMTP id k13so1403826iea.19 for ; Tue, 30 Oct 2012 18:49:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=QoBfO/+iV1xUxCZFqUKHEiFEphTuKXxSTQ2VE1wtWqU=; b=itG/SkTqXkoWw2elC26eyN6gWZMo/OLkL0r5oPAHy/OrlICHk0PBpIZxn9H8CmbUA/ GDZoqsytEnkwiBl8o5KrsjKwvEmiaQB9A3W1W0/K5qFFuihNAskf3liQvdtmGVmEh1SD s564DNvIzQX/SUyRgr/XdMAiVzZhCnp0lDBrWdYA+zpTGKHjTH2ubWZhDvN4gip1ElAN 9INEG3RsvRKl8HAxhZ9VWrG6IWxdovmW3vC8giuAe2vGlb+cXy4r2bhm0gEJN0VZt/0J 5uhhH/kvvfPPxTAcEGlTgVQPTusCs4p6giReEsHH/xSJAZqbh9+F47GrXo9pTgGYQYJN u4hg== Received: by 10.42.101.11 with SMTP id c11mr30303810ico.52.1351648180114; Tue, 30 Oct 2012 18:49:40 -0700 (PDT) Received: from [172.22.22.4] (c-24-118-242-216.hsd1.mn.comcast.net. [24.118.242.216]) by mx.google.com with ESMTPS id gs6sm2022200igc.11.2012.10.30.18.49.35 (version=SSLv3 cipher=OTHER); Tue, 30 Oct 2012 18:49:39 -0700 (PDT) Message-ID: <509083AF.1000000@inktank.com> Date: Tue, 30 Oct 2012 20:49:35 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 MIME-Version: 1.0 To: ceph-devel Subject: [PATCH 4/6] libceph: define ceph_pg_pool_name_by_id() References: <509081C4.3050402@inktank.com> In-Reply-To: <509081C4.3050402@inktank.com> X-Gm-Message-State: ALoCoQkl1F1N4nrnKDbFlQ8KV9hfpGVIM+A3+W9XCUTfbRxcoUhvyp0vdeGpqcu/S5ThDFYK8BEZ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Define and export function ceph_pg_pool_name_by_id() to supply the name of a pg pool whose id is given. This will be used by the next patch. Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- include/linux/ceph/osdmap.h | 1 + net/ceph/osdmap.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) struct rb_node *rbp; diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h index e88a620..5ea57ba 100644 --- a/include/linux/ceph/osdmap.h +++ b/include/linux/ceph/osdmap.h @@ -123,6 +123,7 @@ extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap, struct ceph_pg pgid, extern int ceph_calc_pg_primary(struct ceph_osdmap *osdmap, struct ceph_pg pgid); +extern const char *ceph_pg_pool_name_by_id(struct ceph_osdmap *map, u64 id); extern int ceph_pg_poolid_by_name(struct ceph_osdmap *map, const char *name); #endif diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index f552aa4..de73214 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -469,6 +469,22 @@ static struct ceph_pg_pool_info *__lookup_pg_pool(struct rb_root *root, int id) return NULL; } +const char *ceph_pg_pool_name_by_id(struct ceph_osdmap *map, u64 id) +{ + struct ceph_pg_pool_info *pi; + + if (id == CEPH_NOPOOL) + return NULL; + + if (WARN_ON_ONCE(id > (u64) INT_MAX)) + return NULL; + + pi = __lookup_pg_pool(&map->pg_pools, (int) id); + + return pi ? pi->name : NULL; +} +EXPORT_SYMBOL(ceph_pg_pool_name_by_id); + int ceph_pg_poolid_by_name(struct ceph_osdmap *map, const char *name) {