ceph: do not feed bad device ids to crush
authorSage Weil <sage@newdream.net>
Wed, 9 Dec 2009 20:34:01 +0000 (12:34 -0800)
committerSage Weil <sage@newdream.net>
Wed, 9 Dec 2009 23:57:16 +0000 (15:57 -0800)
Do not feed bad (large) device ids to CRUSH.

Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/osdmap.c

index 8c994c714781ea8dd8521b37933cb57fe21fd50a..be5318aa77141381a15410131a11fc7d577915a0 100644 (file)
@@ -868,6 +868,11 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
        ps = le16_to_cpu(pgid.ps);
        preferred = (s16)le16_to_cpu(pgid.preferred);
 
+       /* don't forcefeed bad device ids to crush */
+       if (preferred >= osdmap->max_osd ||
+           preferred >= osdmap->crush->max_devices)
+               preferred = -1;
+
        if (poolid >= osdmap->num_pools)
                return NULL;
        pool = &osdmap->pg_pool[poolid];