aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/osdmap.c
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2014-03-21 13:05:30 -0400
committerSage Weil <sage@inktank.com>2014-04-05 00:08:00 -0400
commitd286de796aab9e306e674c6d23c4f3c1f55e394c (patch)
tree3f22d2b8cebb39f7a6a3495f4a4839084d47c820 /net/ceph/osdmap.c
parent9686f94c8cfc06e8afb7b2233ab8f1f6ac01957f (diff)
libceph: primary_temp decode bits
Add a common helper to decode both primary_temp (full map, map<pg_t, u32>) and new_primary_temp (inc map, same) and switch to it. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'net/ceph/osdmap.c')
-rw-r--r--net/ceph/osdmap.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index c0fc517ab321..c2d793d3d98d 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -857,6 +857,61 @@ static int decode_new_pg_temp(void **p, void *end, struct ceph_osdmap *map)
857 return __decode_pg_temp(p, end, map, true); 857 return __decode_pg_temp(p, end, map, true);
858} 858}
859 859
860static int __decode_primary_temp(void **p, void *end, struct ceph_osdmap *map,
861 bool incremental)
862{
863 u32 n;
864
865 ceph_decode_32_safe(p, end, n, e_inval);
866 while (n--) {
867 struct ceph_pg pgid;
868 u32 osd;
869 int ret;
870
871 ret = ceph_decode_pgid(p, end, &pgid);
872 if (ret)
873 return ret;
874
875 ceph_decode_32_safe(p, end, osd, e_inval);
876
877 ret = __remove_pg_mapping(&map->primary_temp, pgid);
878 BUG_ON(!incremental && ret != -ENOENT);
879
880 if (!incremental || osd != (u32)-1) {
881 struct ceph_pg_mapping *pg;
882
883 pg = kzalloc(sizeof(*pg), GFP_NOFS);
884 if (!pg)
885 return -ENOMEM;
886
887 pg->pgid = pgid;
888 pg->primary_temp.osd = osd;
889
890 ret = __insert_pg_mapping(pg, &map->primary_temp);
891 if (ret) {
892 kfree(pg);
893 return ret;
894 }
895 }
896 }
897
898 return 0;
899
900e_inval:
901 return -EINVAL;
902}
903
904static int decode_primary_temp(void **p, void *end, struct ceph_osdmap *map)
905{
906 return __decode_primary_temp(p, end, map, false);
907}
908
909static int decode_new_primary_temp(void **p, void *end,
910 struct ceph_osdmap *map)
911{
912 return __decode_primary_temp(p, end, map, true);
913}
914
860/* 915/*
861 * decode a full map. 916 * decode a full map.
862 */ 917 */
@@ -933,6 +988,13 @@ static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map)
933 if (err) 988 if (err)
934 goto bad; 989 goto bad;
935 990
991 /* primary_temp */
992 if (struct_v >= 1) {
993 err = decode_primary_temp(p, end, map);
994 if (err)
995 goto bad;
996 }
997
936 /* crush */ 998 /* crush */
937 ceph_decode_32_safe(p, end, len, e_inval); 999 ceph_decode_32_safe(p, end, len, e_inval);
938 map->crush = crush_decode(*p, min(*p + len, end)); 1000 map->crush = crush_decode(*p, min(*p + len, end));
@@ -1133,6 +1195,13 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
1133 if (err) 1195 if (err)
1134 goto bad; 1196 goto bad;
1135 1197
1198 /* new_primary_temp */
1199 if (struct_v >= 1) {
1200 err = decode_new_primary_temp(p, end, map);
1201 if (err)
1202 goto bad;
1203 }
1204
1136 /* ignore the rest */ 1205 /* ignore the rest */
1137 *p = end; 1206 *p = end;
1138 1207