From patchwork Fri Aug 13 17:40:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sage Weil X-Patchwork-Id: 119476 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7DHfl0Y004309 for ; Fri, 13 Aug 2010 17:41:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761925Ab0HMRlq (ORCPT ); Fri, 13 Aug 2010 13:41:46 -0400 Received: from cobra.newdream.net ([66.33.216.30]:46692 "EHLO cobra.newdream.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761917Ab0HMRlp (ORCPT ); Fri, 13 Aug 2010 13:41:45 -0400 Received: from localhost.localdomain (ip-66-33-206-8.dreamhost.com [66.33.206.8]) by cobra.newdream.net (Postfix) with ESMTPA id 8266EBC77E; Fri, 13 Aug 2010 10:41:59 -0700 (PDT) From: Sage Weil To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-scsi@vger.kernel.org Cc: ceph-devel@vger.kernel.org, hch@lst.de, akpm@linux-foundation.org, yehuda@hq.newdream.net, Sage Weil Subject: [PATCH 1/8] ceph-rbd: lookup pool in osdmap by name Date: Fri, 13 Aug 2010 10:40:33 -0700 Message-Id: <1281721240-26130-2-git-send-email-sage@newdream.net> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1281721240-26130-1-git-send-email-sage@newdream.net> References: <1281721240-26130-1-git-send-email-sage@newdream.net> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 13 Aug 2010 17:41:47 +0000 (UTC) diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c index e31f118..3ccd117 100644 --- a/fs/ceph/osdmap.c +++ b/fs/ceph/osdmap.c @@ -417,6 +417,19 @@ static struct ceph_pg_pool_info *__lookup_pg_pool(struct rb_root *root, int id) return NULL; } +int ceph_pg_poolid_by_name(struct ceph_osdmap *map, const char *name) +{ + struct rb_node *rbp; + + for (rbp = rb_first(&map->pg_pools); rbp; rbp = rb_next(rbp)) { + struct ceph_pg_pool_info *pi = + rb_entry(rbp, struct ceph_pg_pool_info, node); + if (pi->name && strcmp(pi->name, name) == 0) + return pi->id; + } + return -ENOENT; +} + static void __remove_pg_pool(struct rb_root *root, struct ceph_pg_pool_info *pi) { rb_erase(&pi->node, root); diff --git a/fs/ceph/osdmap.h b/fs/ceph/osdmap.h index 970b547..a592b21 100644 --- a/fs/ceph/osdmap.h +++ b/fs/ceph/osdmap.h @@ -125,4 +125,6 @@ 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 int ceph_pg_poolid_by_name(struct ceph_osdmap *map, const char *name); + #endif