Skip to content

Commit 782e182

Browse files
committed
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 <[email protected]>
1 parent 935b639 commit 782e182

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

net/ceph/osdmap.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,29 +1046,32 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
10461046
struct ceph_pg_mapping *pg;
10471047
struct ceph_pg_pool_info *pool;
10481048
int ruleno;
1049-
unsigned poolid, ps, pps;
1049+
unsigned poolid, ps, pps, t;
10501050
int preferred;
10511051

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+
10521060
/* 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);
10531068
pg = __lookup_pg_mapping(&osdmap->pg_temp, pgid);
10541069
if (pg) {
10551070
*num = pg->len;
10561071
return pg->osds;
10571072
}
10581073

10591074
/* 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;
10721075
ruleno = crush_find_rule(osdmap->crush, pool->v.crush_ruleset,
10731076
pool->v.type, pool->v.size);
10741077
if (ruleno < 0) {
@@ -1078,6 +1081,11 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
10781081
return NULL;
10791082
}
10801083

1084+
/* don't forcefeed bad device ids to crush */
1085+
if (preferred >= osdmap->max_osd ||
1086+
preferred >= osdmap->crush->max_devices)
1087+
preferred = -1;
1088+
10811089
if (preferred >= 0)
10821090
pps = ceph_stable_mod(ps,
10831091
le32_to_cpu(pool->v.lpgp_num),

0 commit comments

Comments
 (0)