diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-30 14:17:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-30 14:17:19 -0400 |
commit | af56e0aa35f3ae2a4c1a6d1000702df1dd78cb76 (patch) | |
tree | 304bd85e5db2d07efa2913aa7c6313b918cfbfdb /net/ceph/osdmap.c | |
parent | 65a50c951a38e9827dd9655b6e686bde912e799b (diff) | |
parent | 6bd9adbdf9ca6a052b0b7455ac67b925eb38cfad (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client
Pull ceph updates from Sage Weil:
"There are some updates and cleanups to the CRUSH placement code, a bug
fix with incremental maps, several cleanups and fixes from Josh Durgin
in the RBD block device code, a series of cleanups and bug fixes from
Alex Elder in the messenger code, and some miscellaneous bounds
checking and gfp cleanups/fixes."
Fix up trivial conflicts in net/ceph/{messenger.c,osdmap.c} due to the
networking people preferring "unsigned int" over just "unsigned".
* git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client: (45 commits)
libceph: fix pg_temp updates
libceph: avoid unregistering osd request when not registered
ceph: add auth buf in prepare_write_connect()
ceph: rename prepare_connect_authorizer()
ceph: return pointer from prepare_connect_authorizer()
ceph: use info returned by get_authorizer
ceph: have get_authorizer methods return pointers
ceph: ensure auth ops are defined before use
ceph: messenger: reduce args to create_authorizer
ceph: define ceph_auth_handshake type
ceph: messenger: check return from get_authorizer
ceph: messenger: rework prepare_connect_authorizer()
ceph: messenger: check prepare_write_connect() result
ceph: don't set WRITE_PENDING too early
ceph: drop msgr argument from prepare_write_connect()
ceph: messenger: send banner in process_connect()
ceph: messenger: reset connection kvec caller
libceph: don't reset kvec in prepare_write_banner()
ceph: ignore preferred_osd field
ceph: fully initialize new layout
...
Diffstat (limited to 'net/ceph/osdmap.c')
-rw-r--r-- | net/ceph/osdmap.c | 73 |
1 files changed, 25 insertions, 48 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 56e561a69004..81e3b84a77ef 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c | |||
@@ -161,13 +161,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
161 | c->max_rules = ceph_decode_32(p); | 161 | c->max_rules = ceph_decode_32(p); |
162 | c->max_devices = ceph_decode_32(p); | 162 | c->max_devices = ceph_decode_32(p); |
163 | 163 | ||
164 | c->device_parents = kcalloc(c->max_devices, sizeof(u32), GFP_NOFS); | ||
165 | if (c->device_parents == NULL) | ||
166 | goto badmem; | ||
167 | c->bucket_parents = kcalloc(c->max_buckets, sizeof(u32), GFP_NOFS); | ||
168 | if (c->bucket_parents == NULL) | ||
169 | goto badmem; | ||
170 | |||
171 | c->buckets = kcalloc(c->max_buckets, sizeof(*c->buckets), GFP_NOFS); | 164 | c->buckets = kcalloc(c->max_buckets, sizeof(*c->buckets), GFP_NOFS); |
172 | if (c->buckets == NULL) | 165 | if (c->buckets == NULL) |
173 | goto badmem; | 166 | goto badmem; |
@@ -890,8 +883,12 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, | |||
890 | pglen = ceph_decode_32(p); | 883 | pglen = ceph_decode_32(p); |
891 | 884 | ||
892 | if (pglen) { | 885 | if (pglen) { |
893 | /* insert */ | ||
894 | ceph_decode_need(p, end, pglen*sizeof(u32), bad); | 886 | ceph_decode_need(p, end, pglen*sizeof(u32), bad); |
887 | |||
888 | /* removing existing (if any) */ | ||
889 | (void) __remove_pg_mapping(&map->pg_temp, pgid); | ||
890 | |||
891 | /* insert */ | ||
895 | pg = kmalloc(sizeof(*pg) + sizeof(u32)*pglen, GFP_NOFS); | 892 | pg = kmalloc(sizeof(*pg) + sizeof(u32)*pglen, GFP_NOFS); |
896 | if (!pg) { | 893 | if (!pg) { |
897 | err = -ENOMEM; | 894 | err = -ENOMEM; |
@@ -1000,7 +997,6 @@ int ceph_calc_object_layout(struct ceph_object_layout *ol, | |||
1000 | { | 997 | { |
1001 | unsigned int num, num_mask; | 998 | unsigned int num, num_mask; |
1002 | struct ceph_pg pgid; | 999 | struct ceph_pg pgid; |
1003 | s32 preferred = (s32)le32_to_cpu(fl->fl_pg_preferred); | ||
1004 | int poolid = le32_to_cpu(fl->fl_pg_pool); | 1000 | int poolid = le32_to_cpu(fl->fl_pg_pool); |
1005 | struct ceph_pg_pool_info *pool; | 1001 | struct ceph_pg_pool_info *pool; |
1006 | unsigned int ps; | 1002 | unsigned int ps; |
@@ -1011,23 +1007,13 @@ int ceph_calc_object_layout(struct ceph_object_layout *ol, | |||
1011 | if (!pool) | 1007 | if (!pool) |
1012 | return -EIO; | 1008 | return -EIO; |
1013 | ps = ceph_str_hash(pool->v.object_hash, oid, strlen(oid)); | 1009 | ps = ceph_str_hash(pool->v.object_hash, oid, strlen(oid)); |
1014 | if (preferred >= 0) { | 1010 | num = le32_to_cpu(pool->v.pg_num); |
1015 | ps += preferred; | 1011 | num_mask = pool->pg_num_mask; |
1016 | num = le32_to_cpu(pool->v.lpg_num); | ||
1017 | num_mask = pool->lpg_num_mask; | ||
1018 | } else { | ||
1019 | num = le32_to_cpu(pool->v.pg_num); | ||
1020 | num_mask = pool->pg_num_mask; | ||
1021 | } | ||
1022 | 1012 | ||
1023 | pgid.ps = cpu_to_le16(ps); | 1013 | pgid.ps = cpu_to_le16(ps); |
1024 | pgid.preferred = cpu_to_le16(preferred); | 1014 | pgid.preferred = cpu_to_le16(-1); |
1025 | pgid.pool = fl->fl_pg_pool; | 1015 | pgid.pool = fl->fl_pg_pool; |
1026 | if (preferred >= 0) | 1016 | dout("calc_object_layout '%s' pgid %d.%x\n", oid, poolid, ps); |
1027 | dout("calc_object_layout '%s' pgid %d.%xp%d\n", oid, poolid, ps, | ||
1028 | (int)preferred); | ||
1029 | else | ||
1030 | dout("calc_object_layout '%s' pgid %d.%x\n", oid, poolid, ps); | ||
1031 | 1017 | ||
1032 | ol->ol_pgid = pgid; | 1018 | ol->ol_pgid = pgid; |
1033 | ol->ol_stripe_unit = fl->fl_object_stripe_unit; | 1019 | ol->ol_stripe_unit = fl->fl_object_stripe_unit; |
@@ -1045,24 +1031,18 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid, | |||
1045 | struct ceph_pg_mapping *pg; | 1031 | struct ceph_pg_mapping *pg; |
1046 | struct ceph_pg_pool_info *pool; | 1032 | struct ceph_pg_pool_info *pool; |
1047 | int ruleno; | 1033 | int ruleno; |
1048 | unsigned int poolid, ps, pps, t; | 1034 | unsigned int poolid, ps, pps, t, r; |
1049 | int preferred; | ||
1050 | 1035 | ||
1051 | poolid = le32_to_cpu(pgid.pool); | 1036 | poolid = le32_to_cpu(pgid.pool); |
1052 | ps = le16_to_cpu(pgid.ps); | 1037 | ps = le16_to_cpu(pgid.ps); |
1053 | preferred = (s16)le16_to_cpu(pgid.preferred); | ||
1054 | 1038 | ||
1055 | pool = __lookup_pg_pool(&osdmap->pg_pools, poolid); | 1039 | pool = __lookup_pg_pool(&osdmap->pg_pools, poolid); |
1056 | if (!pool) | 1040 | if (!pool) |
1057 | return NULL; | 1041 | return NULL; |
1058 | 1042 | ||
1059 | /* pg_temp? */ | 1043 | /* pg_temp? */ |
1060 | if (preferred >= 0) | 1044 | t = ceph_stable_mod(ps, le32_to_cpu(pool->v.pg_num), |
1061 | t = ceph_stable_mod(ps, le32_to_cpu(pool->v.lpg_num), | 1045 | pool->pgp_num_mask); |
1062 | pool->lpgp_num_mask); | ||
1063 | else | ||
1064 | t = ceph_stable_mod(ps, le32_to_cpu(pool->v.pg_num), | ||
1065 | pool->pgp_num_mask); | ||
1066 | pgid.ps = cpu_to_le16(t); | 1046 | pgid.ps = cpu_to_le16(t); |
1067 | pg = __lookup_pg_mapping(&osdmap->pg_temp, pgid); | 1047 | pg = __lookup_pg_mapping(&osdmap->pg_temp, pgid); |
1068 | if (pg) { | 1048 | if (pg) { |
@@ -1080,23 +1060,20 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid, | |||
1080 | return NULL; | 1060 | return NULL; |
1081 | } | 1061 | } |
1082 | 1062 | ||
1083 | /* don't forcefeed bad device ids to crush */ | 1063 | pps = ceph_stable_mod(ps, |
1084 | if (preferred >= osdmap->max_osd || | 1064 | le32_to_cpu(pool->v.pgp_num), |
1085 | preferred >= osdmap->crush->max_devices) | 1065 | pool->pgp_num_mask); |
1086 | preferred = -1; | ||
1087 | |||
1088 | if (preferred >= 0) | ||
1089 | pps = ceph_stable_mod(ps, | ||
1090 | le32_to_cpu(pool->v.lpgp_num), | ||
1091 | pool->lpgp_num_mask); | ||
1092 | else | ||
1093 | pps = ceph_stable_mod(ps, | ||
1094 | le32_to_cpu(pool->v.pgp_num), | ||
1095 | pool->pgp_num_mask); | ||
1096 | pps += poolid; | 1066 | pps += poolid; |
1097 | *num = crush_do_rule(osdmap->crush, ruleno, pps, osds, | 1067 | r = crush_do_rule(osdmap->crush, ruleno, pps, osds, |
1098 | min_t(int, pool->v.size, *num), | 1068 | min_t(int, pool->v.size, *num), |
1099 | preferred, osdmap->osd_weight); | 1069 | osdmap->osd_weight); |
1070 | if (r < 0) { | ||
1071 | pr_err("error %d from crush rule: pool %d ruleset %d type %d" | ||
1072 | " size %d\n", r, poolid, pool->v.crush_ruleset, | ||
1073 | pool->v.type, pool->v.size); | ||
1074 | return NULL; | ||
1075 | } | ||
1076 | *num = r; | ||
1100 | return osds; | 1077 | return osds; |
1101 | } | 1078 | } |
1102 | 1079 | ||