Commit 782e182e91e97f529a1edb30fdece9f1bef90ecc

Authored by Sage Weil
1 parent 935b639a04

libceph: fix pg_temp mapping calculation

We need to apply the modulo pg_num calculation before looking up a pgid in
the pg_temp mapping rbtree.  This fixes pg_temp mappings, and fixes
(some) misdirected requests that result in messages like

[WRN] client4104 10.0.1.219:0/275025290 misdirected client4104.1:129 0.1 to osd0 not [1,0] in e11/11

on the server and stall make the client block without getting a reply (at
least until the pg_temp mapping goes way, but that can take a long long
time).

Reorder calc_pg_raw() a bit to make more sense.

Signed-off-by: Sage Weil <sage@newdream.net>

Showing 1 changed file with 21 additions and 13 deletions Side-by-side Diff

... ... @@ -1046,10 +1046,25 @@
1046 1046 struct ceph_pg_mapping *pg;
1047 1047 struct ceph_pg_pool_info *pool;
1048 1048 int ruleno;
1049   - unsigned poolid, ps, pps;
  1049 + unsigned poolid, ps, pps, t;
1050 1050 int preferred;
1051 1051  
  1052 + poolid = le32_to_cpu(pgid.pool);
  1053 + ps = le16_to_cpu(pgid.ps);
  1054 + preferred = (s16)le16_to_cpu(pgid.preferred);
  1055 +
  1056 + pool = __lookup_pg_pool(&osdmap->pg_pools, poolid);
  1057 + if (!pool)
  1058 + return NULL;
  1059 +
1052 1060 /* pg_temp? */
  1061 + if (preferred >= 0)
  1062 + t = ceph_stable_mod(ps, le32_to_cpu(pool->v.lpg_num),
  1063 + pool->lpgp_num_mask);
  1064 + else
  1065 + t = ceph_stable_mod(ps, le32_to_cpu(pool->v.pg_num),
  1066 + pool->pgp_num_mask);
  1067 + pgid.ps = cpu_to_le16(t);
1053 1068 pg = __lookup_pg_mapping(&osdmap->pg_temp, pgid);
1054 1069 if (pg) {
1055 1070 *num = pg->len;
... ... @@ -1057,18 +1072,6 @@
1057 1072 }
1058 1073  
1059 1074 /* crush */
1060   - poolid = le32_to_cpu(pgid.pool);
1061   - ps = le16_to_cpu(pgid.ps);
1062   - preferred = (s16)le16_to_cpu(pgid.preferred);
1063   -
1064   - /* don't forcefeed bad device ids to crush */
1065   - if (preferred >= osdmap->max_osd ||
1066   - preferred >= osdmap->crush->max_devices)
1067   - preferred = -1;
1068   -
1069   - pool = __lookup_pg_pool(&osdmap->pg_pools, poolid);
1070   - if (!pool)
1071   - return NULL;
1072 1075 ruleno = crush_find_rule(osdmap->crush, pool->v.crush_ruleset,
1073 1076 pool->v.type, pool->v.size);
1074 1077 if (ruleno < 0) {
... ... @@ -1077,6 +1080,11 @@
1077 1080 pool->v.size);
1078 1081 return NULL;
1079 1082 }
  1083 +
  1084 + /* don't forcefeed bad device ids to crush */
  1085 + if (preferred >= osdmap->max_osd ||
  1086 + preferred >= osdmap->crush->max_devices)
  1087 + preferred = -1;
1080 1088  
1081 1089 if (preferred >= 0)
1082 1090 pps = ceph_stable_mod(ps,