Deleted Added
full compact
g_virstor.c (298698) g_virstor.c (298848)
1/*-
2 * Copyright (c) 2006-2007 Ivan Voras <ivoras@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

25 */
26
27/* Implementation notes:
28 * - "Components" are wrappers around providers that make up the
29 * virtual storage (i.e. a virstor has "physical" components)
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2006-2007 Ivan Voras <ivoras@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

25 */
26
27/* Implementation notes:
28 * - "Components" are wrappers around providers that make up the
29 * virtual storage (i.e. a virstor has "physical" components)
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/geom/virstor/g_virstor.c 298698 2016-04-27 15:10:40Z pfg $");
33__FBSDID("$FreeBSD: head/sys/geom/virstor/g_virstor.c 298848 2016-04-30 14:41:18Z pfg $");
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/module.h>
39#include <sys/lock.h>
40#include <sys/mutex.h>
41#include <sys/sx.h>

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

1252 off = count = n = 0;
1253 while (count < sc->map_size) {
1254 struct g_virstor_map_entry *mapbuf;
1255 size_t bs;
1256
1257 bs = MIN(MAXPHYS, sc->map_size - count);
1258 if (bs % sc->sectorsize != 0) {
1259 /* Check for alignment errors */
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/module.h>
39#include <sys/lock.h>
40#include <sys/mutex.h>
41#include <sys/sx.h>

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

1252 off = count = n = 0;
1253 while (count < sc->map_size) {
1254 struct g_virstor_map_entry *mapbuf;
1255 size_t bs;
1256
1257 bs = MIN(MAXPHYS, sc->map_size - count);
1258 if (bs % sc->sectorsize != 0) {
1259 /* Check for alignment errors */
1260 bs = (bs / sc->sectorsize) * sc->sectorsize;
1260 bs = rounddown(bs, sc->sectorsize);
1261 if (bs == 0)
1262 break;
1263 LOG_MSG(LVL_ERROR, "Trouble: map is not sector-aligned "
1264 "for %s on %s", sc->geom->name,
1265 sc->components[0].gcons->provider->name);
1266 }
1267 mapbuf = g_read_data(sc->components[0].gcons, off, bs, &error);
1268 if (mapbuf == NULL) {

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

1718 /* The allocation table is stored continuously
1719 * at the start of the drive. We need to
1720 * calculate the offset of the sector that holds
1721 * this map entry both on the drive and in the
1722 * map array.
1723 * sc_offset will end up pointing to the drive
1724 * sector. */
1725 s_offset = chunk_index * sizeof *me;
1261 if (bs == 0)
1262 break;
1263 LOG_MSG(LVL_ERROR, "Trouble: map is not sector-aligned "
1264 "for %s on %s", sc->geom->name,
1265 sc->components[0].gcons->provider->name);
1266 }
1267 mapbuf = g_read_data(sc->components[0].gcons, off, bs, &error);
1268 if (mapbuf == NULL) {

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

1718 /* The allocation table is stored continuously
1719 * at the start of the drive. We need to
1720 * calculate the offset of the sector that holds
1721 * this map entry both on the drive and in the
1722 * map array.
1723 * sc_offset will end up pointing to the drive
1724 * sector. */
1725 s_offset = chunk_index * sizeof *me;
1726 s_offset = (s_offset / sc->sectorsize) *
1727 sc->sectorsize;
1726 s_offset = rounddown(s_offset, sc->sectorsize);
1728
1729 /* data_me points to map entry sector
1727
1728 /* data_me points to map entry sector
1730 * in memory (analoguos to offset) */
1731 data_me = &sc->map[(chunk_index /
1732 sc->me_per_sector) * sc->me_per_sector];
1729 * in memory (analogous to offset) */
1730 data_me = &sc->map[rounddown(chunk_index,
1731 sc->me_per_sector)];
1733
1734 /* Commit sector with map entry to storage */
1735 cb->bio_to = sc->components[0].gcons->provider;
1736 cb->bio_done = g_virstor_done;
1737 cb->bio_offset = s_offset;
1738 cb->bio_data = (char *)data_me;
1739 cb->bio_length = sc->sectorsize;
1740 cb->bio_caller1 = &sc->components[0];

--- 153 unchanged lines hidden ---
1732
1733 /* Commit sector with map entry to storage */
1734 cb->bio_to = sc->components[0].gcons->provider;
1735 cb->bio_done = g_virstor_done;
1736 cb->bio_offset = s_offset;
1737 cb->bio_data = (char *)data_me;
1738 cb->bio_length = sc->sectorsize;
1739 cb->bio_caller1 = &sc->components[0];

--- 153 unchanged lines hidden ---