From owner-svn-src-all@FreeBSD.ORG Tue May 19 17:36:35 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BFB98A2A; Tue, 19 May 2015 17:36:35 +0000 (UTC) Received: from mail-ig0-x22c.google.com (mail-ig0-x22c.google.com [IPv6:2607:f8b0:4001:c05::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8A76E1CAD; Tue, 19 May 2015 17:36:35 +0000 (UTC) Received: by igbpi8 with SMTP id pi8so112610997igb.0; Tue, 19 May 2015 10:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=RZJTI4dIfSNUTOUzxy9rF8wpFM6KHp3QjDBT04FimfY=; b=KCZzGRUg4ic0pnHiRLXsHDHEAB299u979WvoIraeplKZEg8bKzz/09JzPD6uGIDs0i LgxEKQcXIjXo++3t+zDSQ1VGweweCbhVxUtwR5Xc0bjSR7p1JTYcwdvv6vTbYgkismaV moxKZN+tJu430tqn2eSgX8M4SYEx6pO6iwsMtq7WZtYPag21Crm5AXqp68tae4BIwzyQ pjQCz013HE9nq2Ugdez5IDG9pf7zXdacwhjHvBmsyJysu35GafN5zyfHQBv/LSXRsmAI Vhe7OThy7keNz3R8jZY94sxd4FFzeO3AHVITSJnyK19hCCatgZkejS6eoZZZ9RAkP2nD p/cg== MIME-Version: 1.0 X-Received: by 10.50.114.9 with SMTP id jc9mr8552514igb.49.1432056994971; Tue, 19 May 2015 10:36:34 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.36.38.133 with HTTP; Tue, 19 May 2015 10:36:34 -0700 (PDT) In-Reply-To: <201505190928.t4J9Sq4M030475@svn.freebsd.org> References: <201505190928.t4J9Sq4M030475@svn.freebsd.org> Date: Tue, 19 May 2015 10:36:34 -0700 X-Google-Sender-Auth: fbCAB7m7dN0IFRCMvv04_N2VB_I Message-ID: Subject: Re: svn commit: r283104 - head/sys/geom/uncompress From: Adrian Chadd To: "Andrey V. Elsukov" Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2015 17:36:35 -0000 Hi, How big are the images you were using? Did you try on the smaller footprint boards (eg things with < 128MB RAM) to see if it changed behaviour? -a On 19 May 2015 at 02:28, Andrey V. Elsukov wrote: > Author: ae > Date: Tue May 19 09:28:52 2015 > New Revision: 283104 > URL: https://svnweb.freebsd.org/changeset/base/283104 > > Log: > Read GEOM_UNCOMPRESS metadata using several requests that fit into > MAXPHYS. For large compressed images the metadata size can be bigger > than MAXPHYS and this triggers KASSERT in g_read_data(). > Also use g_free() to free memory allocated by g_read_data(). > > PR: 199476 > MFC after: 2 weeks > > Modified: > head/sys/geom/uncompress/g_uncompress.c > > Modified: head/sys/geom/uncompress/g_uncompress.c > ============================================================================== > --- head/sys/geom/uncompress/g_uncompress.c Tue May 19 09:22:06 2015 (r283103) > +++ head/sys/geom/uncompress/g_uncompress.c Tue May 19 09:28:52 2015 (r283104) > @@ -464,7 +464,8 @@ g_uncompress_taste(struct g_class *mp, s > struct g_provider *pp2; > struct g_consumer *cp; > struct g_geom *gp; > - uint32_t i, total_offsets, type; > + uint64_t *offsets; > + uint32_t i, r, total, total_offsets, type; > uint8_t *buf; > int error; > > @@ -499,8 +500,8 @@ g_uncompress_taste(struct g_class *mp, s > */ > DPRINTF(("%s: media sectorsize %u, mediasize %jd\n", > gp->name, pp->sectorsize, (intmax_t)pp->mediasize)); > - i = roundup(sizeof(struct cloop_header), pp->sectorsize); > - buf = g_read_data(cp, 0, i, NULL); > + total = roundup(sizeof(struct cloop_header), pp->sectorsize); > + buf = g_read_data(cp, 0, total, NULL); > if (buf == NULL) > goto err; > header = (struct cloop_header *) buf; > @@ -557,20 +558,29 @@ g_uncompress_taste(struct g_class *mp, s > gp->name, sc->nblocks); > goto err; > } > - free(buf, M_GEOM); > + g_free(buf); > > - i = roundup((sizeof(struct cloop_header) + > - total_offsets * sizeof(uint64_t)), pp->sectorsize); > - buf = g_read_data(cp, 0, i, NULL); > - if (buf == NULL) > - goto err; > sc->offsets = malloc(total_offsets * sizeof(uint64_t), > - M_GEOM_UNCOMPRESS, M_WAITOK); > - for (i = 0; i <= total_offsets; i++) { > - sc->offsets[i] = be64toh(((uint64_t *) > - (buf+sizeof(struct cloop_header)))[i]); > + M_GEOM_UNCOMPRESS, M_WAITOK | M_ZERO); > + total = roundup((sizeof(struct cloop_header) + > + total_offsets * sizeof(uint64_t)), pp->sectorsize); > +#define RSZ ((total - r) > MAXPHYS ? MAXPHYS: (total - r)) > + for (r = 0, i = 0; r < total; r += MAXPHYS) { > + buf = g_read_data(cp, r, RSZ, &error); > + if (buf == NULL) { > + free(sc->offsets, M_GEOM_UNCOMPRESS); > + goto err; > + } > + offsets = (uint64_t *)buf; > + if (r == 0) > + offsets += > + sizeof(struct cloop_header) / sizeof(uint64_t); > + for (; i < total_offsets && offsets < (uint64_t *)(buf + RSZ); > + i++, offsets++) > + sc->offsets[i] = be64toh(*offsets); > + g_free(buf); > } > - free(buf, M_GEOM); > +#undef RSZ > buf = NULL; > DPRINTF(("%s: done reading offsets\n", gp->name)); > mtx_init(&sc->last_mtx, "geom_uncompress cache", NULL, MTX_DEF); > @@ -619,7 +629,7 @@ err: > g_topology_lock(); > g_access(cp, -1, 0, 0); > if (buf != NULL) > - free(buf, M_GEOM); > + g_free(buf); > if (gp->softc != NULL) { > g_uncompress_softc_free(gp->softc, NULL); > gp->softc = NULL; >