Deleted Added
full compact
g_uzip.c (298619) g_uzip.c (298649)
1/*-
2 * Copyright (c) 2004 Max Khon
3 * Copyright (c) 2014 Juniper Networks, Inc.
4 * Copyright (c) 2006-2016 Maxim Sobolev <sobomax@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2004 Max Khon
3 * Copyright (c) 2014 Juniper Networks, Inc.
4 * Copyright (c) 2006-2016 Maxim Sobolev <sobomax@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/geom/uzip/g_uzip.c 298619 2016-04-26 06:50:38Z sobomax $");
30__FBSDID("$FreeBSD: head/sys/geom/uzip/g_uzip.c 298649 2016-04-26 15:38:17Z pfg $");
31
32#include <sys/param.h>
33#include <sys/bio.h>
34#include <sys/endian.h>
35#include <sys/errno.h>
36#include <sys/kernel.h>
37#include <sys/lock.h>
38#include <sys/mutex.h>

--- 151 unchanged lines hidden (view full) ---

190 (sc)->toc[(bi)].blen)
191
192#define BLK_IS_CONT(sc, bi) (BLK_ENDS((sc), (bi) - 1) == \
193 (sc)->toc[(bi)].offset)
194#define BLK_IS_NIL(sc, bi) ((sc)->toc[(bi)].blen == 0)
195
196#define TOFF_2_BOFF(sc, pp, bi) ((sc)->toc[(bi)].offset - \
197 (sc)->toc[(bi)].offset % (pp)->sectorsize)
31
32#include <sys/param.h>
33#include <sys/bio.h>
34#include <sys/endian.h>
35#include <sys/errno.h>
36#include <sys/kernel.h>
37#include <sys/lock.h>
38#include <sys/mutex.h>

--- 151 unchanged lines hidden (view full) ---

190 (sc)->toc[(bi)].blen)
191
192#define BLK_IS_CONT(sc, bi) (BLK_ENDS((sc), (bi) - 1) == \
193 (sc)->toc[(bi)].offset)
194#define BLK_IS_NIL(sc, bi) ((sc)->toc[(bi)].blen == 0)
195
196#define TOFF_2_BOFF(sc, pp, bi) ((sc)->toc[(bi)].offset - \
197 (sc)->toc[(bi)].offset % (pp)->sectorsize)
198#define TLEN_2_BLEN(sc, pp, bp, ei) ((BLK_ENDS((sc), (ei)) - \
199 (bp)->bio_offset + (pp)->sectorsize - 1) / \
200 (pp)->sectorsize * (pp)->sectorsize)
198#define TLEN_2_BLEN(sc, pp, bp, ei) roundup(BLK_ENDS((sc), (ei)) - \
199 (bp)->bio_offset, (pp)->sectorsize)
201
202static int
203g_uzip_request(struct g_geom *gp, struct bio *bp)
204{
205 struct g_uzip_softc *sc;
206 struct bio *bp2;
207 struct g_consumer *cp;
208 struct g_provider *pp;

--- 6 unchanged lines hidden (view full) ---

215 sc = gp->softc;
216
217 cp = LIST_FIRST(&gp->consumer);
218 pp = cp->provider;
219
220 ofs = bp->bio_offset + bp->bio_completed;
221 start_blk = ofs / sc->blksz;
222 KASSERT(start_blk < sc->nblocks, ("start_blk out of range"));
200
201static int
202g_uzip_request(struct g_geom *gp, struct bio *bp)
203{
204 struct g_uzip_softc *sc;
205 struct bio *bp2;
206 struct g_consumer *cp;
207 struct g_provider *pp;

--- 6 unchanged lines hidden (view full) ---

214 sc = gp->softc;
215
216 cp = LIST_FIRST(&gp->consumer);
217 pp = cp->provider;
218
219 ofs = bp->bio_offset + bp->bio_completed;
220 start_blk = ofs / sc->blksz;
221 KASSERT(start_blk < sc->nblocks, ("start_blk out of range"));
223 end_blk = (ofs + bp->bio_resid + sc->blksz - 1) / sc->blksz;
222 end_blk = howmany(ofs + bp->bio_resid, sc->blksz);
224 KASSERT(end_blk <= sc->nblocks, ("end_blk out of range"));
225
226 for (; BLK_IS_NIL(sc, start_blk) && start_blk < end_blk; start_blk++) {
227 /* Fill in any leading Nil blocks */
228 start_blk_ofs = ofs % sc->blksz;
229 zsize = MIN(sc->blksz - start_blk_ofs, bp->bio_resid);
230 DPRINTF_BLK(GUZ_DBG_IO, start_blk, ("%s/%s: %p/%ju: "
231 "filling %ju zero bytes\n", __func__, gp->name, gp,

--- 599 unchanged lines hidden ---
223 KASSERT(end_blk <= sc->nblocks, ("end_blk out of range"));
224
225 for (; BLK_IS_NIL(sc, start_blk) && start_blk < end_blk; start_blk++) {
226 /* Fill in any leading Nil blocks */
227 start_blk_ofs = ofs % sc->blksz;
228 zsize = MIN(sc->blksz - start_blk_ofs, bp->bio_resid);
229 DPRINTF_BLK(GUZ_DBG_IO, start_blk, ("%s/%s: %p/%ju: "
230 "filling %ju zero bytes\n", __func__, gp->name, gp,

--- 599 unchanged lines hidden ---