Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Dec 2009 23:31:03 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r200821 - head/sys/geom/raid3
Message-ID:  <200912212331.nBLNV3Kb044323@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Mon Dec 21 23:31:03 2009
New Revision: 200821
URL: http://svn.freebsd.org/changeset/base/200821

Log:
  Make graid3 fallback to malloc() when component request size is bigger
  then maximal prepared UMA zone size. This fixes crash with MAXPHYS > 128K.

Modified:
  head/sys/geom/raid3/g_raid3.c
  head/sys/geom/raid3/g_raid3.h

Modified: head/sys/geom/raid3/g_raid3.c
==============================================================================
--- head/sys/geom/raid3/g_raid3.c	Mon Dec 21 22:57:40 2009	(r200820)
+++ head/sys/geom/raid3/g_raid3.c	Mon Dec 21 23:31:03 2009	(r200821)
@@ -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, 
 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]);
 	}
 }
 

Modified: head/sys/geom/raid3/g_raid3.h
==============================================================================
--- head/sys/geom/raid3/g_raid3.h	Mon Dec 21 22:57:40 2009	(r200820)
+++ head/sys/geom/raid3/g_raid3.h	Mon Dec 21 23:31:03 2009	(r200821)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912212331.nBLNV3Kb044323>