diff options
author | Ilya Dryomov <ilya.dryomov@inktank.com> | 2014-03-21 13:05:30 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2014-04-05 00:08:04 -0400 |
commit | 63a6993f521b2629872e89c02a336fb3f18b092b (patch) | |
tree | 1d3dcc49a45bcd4beaeb132c0b3521de86bea76c /net/ceph | |
parent | 2cfa34f2d67a36e292cbe6e4c1e60d212b7ba4d1 (diff) |
libceph: primary_affinity decode bits
Add two helpers to decode primary_affinity (full map, vector<u32>) and
new_primary_affinity (inc map, map<u32, u32>) and switch to them.
Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/osdmap.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 0ac129388e07..9568e6221852 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c | |||
@@ -959,6 +959,60 @@ static int set_primary_affinity(struct ceph_osdmap *map, int osd, u32 aff) | |||
959 | return 0; | 959 | return 0; |
960 | } | 960 | } |
961 | 961 | ||
962 | static int decode_primary_affinity(void **p, void *end, | ||
963 | struct ceph_osdmap *map) | ||
964 | { | ||
965 | u32 len, i; | ||
966 | |||
967 | ceph_decode_32_safe(p, end, len, e_inval); | ||
968 | if (len == 0) { | ||
969 | kfree(map->osd_primary_affinity); | ||
970 | map->osd_primary_affinity = NULL; | ||
971 | return 0; | ||
972 | } | ||
973 | if (len != map->max_osd) | ||
974 | goto e_inval; | ||
975 | |||
976 | ceph_decode_need(p, end, map->max_osd*sizeof(u32), e_inval); | ||
977 | |||
978 | for (i = 0; i < map->max_osd; i++) { | ||
979 | int ret; | ||
980 | |||
981 | ret = set_primary_affinity(map, i, ceph_decode_32(p)); | ||
982 | if (ret) | ||
983 | return ret; | ||
984 | } | ||
985 | |||
986 | return 0; | ||
987 | |||
988 | e_inval: | ||
989 | return -EINVAL; | ||
990 | } | ||
991 | |||
992 | static int decode_new_primary_affinity(void **p, void *end, | ||
993 | struct ceph_osdmap *map) | ||
994 | { | ||
995 | u32 n; | ||
996 | |||
997 | ceph_decode_32_safe(p, end, n, e_inval); | ||
998 | while (n--) { | ||
999 | u32 osd, aff; | ||
1000 | int ret; | ||
1001 | |||
1002 | ceph_decode_32_safe(p, end, osd, e_inval); | ||
1003 | ceph_decode_32_safe(p, end, aff, e_inval); | ||
1004 | |||
1005 | ret = set_primary_affinity(map, osd, aff); | ||
1006 | if (ret) | ||
1007 | return ret; | ||
1008 | } | ||
1009 | |||
1010 | return 0; | ||
1011 | |||
1012 | e_inval: | ||
1013 | return -EINVAL; | ||
1014 | } | ||
1015 | |||
962 | /* | 1016 | /* |
963 | * decode a full map. | 1017 | * decode a full map. |
964 | */ | 1018 | */ |
@@ -1042,6 +1096,17 @@ static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map) | |||
1042 | goto bad; | 1096 | goto bad; |
1043 | } | 1097 | } |
1044 | 1098 | ||
1099 | /* primary_affinity */ | ||
1100 | if (struct_v >= 2) { | ||
1101 | err = decode_primary_affinity(p, end, map); | ||
1102 | if (err) | ||
1103 | goto bad; | ||
1104 | } else { | ||
1105 | /* XXX can this happen? */ | ||
1106 | kfree(map->osd_primary_affinity); | ||
1107 | map->osd_primary_affinity = NULL; | ||
1108 | } | ||
1109 | |||
1045 | /* crush */ | 1110 | /* crush */ |
1046 | ceph_decode_32_safe(p, end, len, e_inval); | 1111 | ceph_decode_32_safe(p, end, len, e_inval); |
1047 | map->crush = crush_decode(*p, min(*p + len, end)); | 1112 | map->crush = crush_decode(*p, min(*p + len, end)); |
@@ -1249,6 +1314,13 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, | |||
1249 | goto bad; | 1314 | goto bad; |
1250 | } | 1315 | } |
1251 | 1316 | ||
1317 | /* new_primary_affinity */ | ||
1318 | if (struct_v >= 2) { | ||
1319 | err = decode_new_primary_affinity(p, end, map); | ||
1320 | if (err) | ||
1321 | goto bad; | ||
1322 | } | ||
1323 | |||
1252 | /* ignore the rest */ | 1324 | /* ignore the rest */ |
1253 | *p = end; | 1325 | *p = end; |
1254 | 1326 | ||