g_bde_work.c (114152) | g_bde_work.c (114153) |
---|---|
1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * | 1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * |
32 * $FreeBSD: head/sys/geom/bde/g_bde_work.c 114152 2003-04-28 06:19:41Z phk $ | 32 * $FreeBSD: head/sys/geom/bde/g_bde_work.c 114153 2003-04-28 06:38:31Z phk $ |
33 * 34 * This source file contains the state-engine which makes things happen in the 35 * right order. 36 * 37 * Outline: 38 * 1) g_bde_start1() 39 * Break the struct bio into multiple work packets one per zone. 40 * 2) g_bde_start2() --- 31 unchanged lines hidden (view full) --- 72#include <crypto/rijndael/rijndael.h> 73#include <crypto/sha2/sha2.h> 74#include <geom/geom.h> 75#include <geom/bde/g_bde.h> 76 77static void g_bde_delete_sector(struct g_bde_softc *wp, struct g_bde_sector *sp); 78static struct g_bde_sector * g_bde_new_sector(struct g_bde_work *wp, u_int len); 79static void g_bde_release_keysector(struct g_bde_work *wp); | 33 * 34 * This source file contains the state-engine which makes things happen in the 35 * right order. 36 * 37 * Outline: 38 * 1) g_bde_start1() 39 * Break the struct bio into multiple work packets one per zone. 40 * 2) g_bde_start2() --- 31 unchanged lines hidden (view full) --- 72#include <crypto/rijndael/rijndael.h> 73#include <crypto/sha2/sha2.h> 74#include <geom/geom.h> 75#include <geom/bde/g_bde.h> 76 77static void g_bde_delete_sector(struct g_bde_softc *wp, struct g_bde_sector *sp); 78static struct g_bde_sector * g_bde_new_sector(struct g_bde_work *wp, u_int len); 79static void g_bde_release_keysector(struct g_bde_work *wp); |
80static struct g_bde_sector *g_bde_get_sector(struct g_bde_work *wp, off_t offset); | 80static struct g_bde_sector *g_bde_get_keysector(struct g_bde_work *wp); |
81static int g_bde_start_read(struct g_bde_sector *sp); 82static void g_bde_purge_sector(struct g_bde_softc *sc, int fraction); 83 84/* 85 * Work item allocation. 86 * 87 * C++ would call these constructors and destructors. 88 */ --- 101 unchanged lines hidden (view full) --- 190 TAILQ_REMOVE(&sc->freelist, sp, list); 191 g_bde_ncache--; 192 sc->ncache--; 193 bzero(sp->data, sp->size); 194 g_bde_delete_sector(sc, sp); 195} 196 197static struct g_bde_sector * | 81static int g_bde_start_read(struct g_bde_sector *sp); 82static void g_bde_purge_sector(struct g_bde_softc *sc, int fraction); 83 84/* 85 * Work item allocation. 86 * 87 * C++ would call these constructors and destructors. 88 */ --- 101 unchanged lines hidden (view full) --- 190 TAILQ_REMOVE(&sc->freelist, sp, list); 191 g_bde_ncache--; 192 sc->ncache--; 193 bzero(sp->data, sp->size); 194 g_bde_delete_sector(sc, sp); 195} 196 197static struct g_bde_sector * |
198g_bde_get_sector(struct g_bde_work *wp, off_t offset) | 198g_bde_get_keysector(struct g_bde_work *wp) |
199{ 200 struct g_bde_sector *sp; 201 struct g_bde_softc *sc; | 199{ 200 struct g_bde_sector *sp; 201 struct g_bde_softc *sc; |
202 off_t offset; |
|
202 | 203 |
203 g_trace(G_T_TOPOLOGY, "g_bde_get_sector(%p, %jd)", wp, (intmax_t)offset); | 204 offset = wp->kso; 205 g_trace(G_T_TOPOLOGY, "g_bde_get_keysector(%p, %jd)", wp, (intmax_t)offset); |
204 sc = wp->softc; 205 206 if (malloc_last_fail() < g_bde_ncache) 207 g_bde_purge_sector(sc, -1); 208 209 sp = TAILQ_FIRST(&sc->freelist); 210 if (sp != NULL && sp->ref == 0 && sp->used + 300 < time_uptime) 211 g_bde_purge_one_sector(sc, sp); --- 112 unchanged lines hidden (view full) --- 324} 325 326static struct g_bde_sector * 327g_bde_read_keysector(struct g_bde_softc *sc, struct g_bde_work *wp) 328{ 329 struct g_bde_sector *sp; 330 331 g_trace(G_T_TOPOLOGY, "g_bde_read_keysector(%p)", wp); | 206 sc = wp->softc; 207 208 if (malloc_last_fail() < g_bde_ncache) 209 g_bde_purge_sector(sc, -1); 210 211 sp = TAILQ_FIRST(&sc->freelist); 212 if (sp != NULL && sp->ref == 0 && sp->used + 300 < time_uptime) 213 g_bde_purge_one_sector(sc, sp); --- 112 unchanged lines hidden (view full) --- 326} 327 328static struct g_bde_sector * 329g_bde_read_keysector(struct g_bde_softc *sc, struct g_bde_work *wp) 330{ 331 struct g_bde_sector *sp; 332 333 g_trace(G_T_TOPOLOGY, "g_bde_read_keysector(%p)", wp); |
332 sp = g_bde_get_sector(wp, wp->kso); | 334 sp = g_bde_get_keysector(wp); |
333 if (sp == NULL) { 334 g_bde_purge_sector(sc, -1); | 335 if (sp == NULL) { 336 g_bde_purge_sector(sc, -1); |
335 sp = g_bde_get_sector(wp, wp->kso); | 337 sp = g_bde_get_keysector(wp); |
336 } 337 if (sp == NULL) 338 return (sp); 339 if (sp->owner != wp) 340 return (sp); 341 if (sp->state == VALID) 342 return (sp); 343 if (g_bde_start_read(sp) == 0) --- 414 unchanged lines hidden --- | 338 } 339 if (sp == NULL) 340 return (sp); 341 if (sp->owner != wp) 342 return (sp); 343 if (sp->state == VALID) 344 return (sp); 345 if (g_bde_start_read(sp) == 0) --- 414 unchanged lines hidden --- |