libceph: generalize ceph_pg_mapping
authorIlya Dryomov <ilya.dryomov@inktank.com>
Fri, 21 Mar 2014 17:05:29 +0000 (19:05 +0200)
committerSage Weil <sage@inktank.com>
Sat, 5 Apr 2014 04:07:57 +0000 (21:07 -0700)
In preparation for adding support for primary_temp mappings, generalize
struct ceph_pg_mapping so it can hold mappings other than pg_temp.

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Alex Elder <elder@linaro.org>
include/linux/ceph/osdmap.h
net/ceph/debugfs.c
net/ceph/osdmap.c

index 46c3e304c3d86d08e6512e22d4fd5ea6b455ef86..4837e58e32031df926754be1fd0435eba5c06677 100644 (file)
@@ -60,8 +60,13 @@ struct ceph_object_id {
 struct ceph_pg_mapping {
        struct rb_node node;
        struct ceph_pg pgid;
-       int len;
-       int osds[];
+
+       union {
+               struct {
+                       int len;
+                       int osds[];
+               } pg_temp;
+       };
 };
 
 struct ceph_osdmap {
index c45d235e774ea4423d1e3cc8efa4a9abee00a582..5865f2c9580ac31da7a1f435ab605498af01fec8 100644 (file)
@@ -88,9 +88,9 @@ static int osdmap_show(struct seq_file *s, void *p)
 
                seq_printf(s, "pg_temp %llu.%x [", pg->pgid.pool,
                           pg->pgid.seed);
-               for (i = 0; i < pg->len; i++)
+               for (i = 0; i < pg->pg_temp.len; i++)
                        seq_printf(s, "%s%d", (i == 0 ? "" : ","),
-                                  pg->osds[i]);
+                                  pg->pg_temp.osds[i]);
                seq_printf(s, "]\n");
        }
 
index be2a65fbd9020643941a56e736c1bdc790fad097..c67a309fdfc21c6d44f8eabc44acf2b49ba7ef7a 100644 (file)
@@ -822,9 +822,9 @@ static int __decode_pg_temp(void **p, void *end, struct ceph_osdmap *map,
                                return -ENOMEM;
 
                        pg->pgid = pgid;
-                       pg->len = len;
+                       pg->pg_temp.len = len;
                        for (i = 0; i < len; i++)
-                               pg->osds[i] = ceph_decode_32(p);
+                               pg->pg_temp.osds[i] = ceph_decode_32(p);
 
                        ret = __insert_pg_mapping(pg, &map->pg_temp);
                        if (ret) {
@@ -1281,8 +1281,8 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
                                    pool->pg_num_mask);
        pg = __lookup_pg_mapping(&osdmap->pg_temp, pgid);
        if (pg) {
-               *num = pg->len;
-               return pg->osds;
+               *num = pg->pg_temp.len;
+               return pg->pg_temp.osds;
        }
 
        /* crush */