From 7669a2c95e502a77f93f27e5449fc93a00d588b6 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 17 May 2010 12:31:35 -0700 Subject: [PATCH] ceph: lookup pool in osdmap by name Implement a pool lookup by name. This will be used by rbd. Signed-off-by: Yehuda Sadeh Signed-off-by: Sage Weil --- fs/ceph/osdmap.c | 13 +++++++++++++ fs/ceph/osdmap.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c index e31f118f1392..3ccd11761cb6 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 970b547e510d..a592b211be39 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 -- 2.20.1