diff options
author | mav <mav@FreeBSD.org> | 2009-12-21 23:31:03 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2009-12-21 23:31:03 +0000 |
commit | 3edd147826811d68c173891011e586667f465361 (patch) | |
tree | 7be53c6d6d526eb6c8eff82e502fd28cf54887dc /sys/geom | |
parent | 42c62812debad35708a667b97cac5e79698581e9 (diff) | |
download | FreeBSD-src-3edd147826811d68c173891011e586667f465361.zip FreeBSD-src-3edd147826811d68c173891011e586667f465361.tar.gz |
Make graid3 fallback to malloc() when component request size is bigger
then maximal prepared UMA zone size. This fixes crash with MAXPHYS > 128K.
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/raid3/g_raid3.c | 20 | ||||
-rw-r--r-- | sys/geom/raid3/g_raid3.h | 4 |
2 files changed, 15 insertions, 9 deletions
diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index 1cbce25..0feca0c 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -183,15 +183,17 @@ static void * g_raid3_alloc(struct g_raid3_softc *sc, size_t size, int flags) { void *ptr; + enum g_raid3_zones zone; - if (g_raid3_use_malloc) + if (g_raid3_use_malloc || + (zone = g_raid3_zone(size)) == G_RAID3_NUM_ZONES) ptr = malloc(size, M_RAID3, flags); else { - ptr = uma_zalloc_arg(sc->sc_zones[g_raid3_zone(size)].sz_zone, - &sc->sc_zones[g_raid3_zone(size)], flags); - sc->sc_zones[g_raid3_zone(size)].sz_requested++; + ptr = uma_zalloc_arg(sc->sc_zones[zone].sz_zone, + &sc->sc_zones[zone], flags); + sc->sc_zones[zone].sz_requested++; if (ptr == NULL) - sc->sc_zones[g_raid3_zone(size)].sz_failed++; + sc->sc_zones[zone].sz_failed++; } return (ptr); } @@ -199,12 +201,14 @@ g_raid3_alloc(struct g_raid3_softc *sc, size_t size, int flags) static void g_raid3_free(struct g_raid3_softc *sc, void *ptr, size_t size) { + enum g_raid3_zones zone; - if (g_raid3_use_malloc) + if (g_raid3_use_malloc || + (zone = g_raid3_zone(size)) == G_RAID3_NUM_ZONES) free(ptr, M_RAID3); else { - uma_zfree_arg(sc->sc_zones[g_raid3_zone(size)].sz_zone, - ptr, &sc->sc_zones[g_raid3_zone(size)]); + uma_zfree_arg(sc->sc_zones[zone].sz_zone, + ptr, &sc->sc_zones[zone]); } } diff --git a/sys/geom/raid3/g_raid3.h b/sys/geom/raid3/g_raid3.h index a375999..5daf16d 100644 --- a/sys/geom/raid3/g_raid3.h +++ b/sys/geom/raid3/g_raid3.h @@ -183,7 +183,9 @@ enum g_raid3_zones { static __inline enum g_raid3_zones g_raid3_zone(size_t nbytes) { - if (nbytes > 16384) + if (nbytes > 65536) + return (G_RAID3_NUM_ZONES); + else if (nbytes > 16384) return (G_RAID3_ZONE_64K); else if (nbytes > 4096) return (G_RAID3_ZONE_16K); |