ceph: lookup pool in osdmap by name
authorYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 17 May 2010 19:31:35 +0000 (12:31 -0700)
committerSage Weil <sage@newdream.net>
Wed, 20 Oct 2010 22:35:36 +0000 (15:35 -0700)
Implement a pool lookup by name.  This will be used by rbd.

Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/osdmap.c
fs/ceph/osdmap.h

index e31f118f1392988351257d2385863c37228bc7df..3ccd11761cb603912404891866c16fa9ac0b0677 100644 (file)
@@ -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);
index 970b547e510dbd0edb8ba8c2ec95c45932be6106..a592b211be3923f4ead88703d2e8cc940934c23c 100644 (file)
@@ -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