g_eli.c (214116) | g_eli.c (214118) |
---|---|
1/*- 2 * Copyright (c) 2005-2010 Pawel Jakub Dawidek <pjd@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 --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2005-2010 Pawel Jakub Dawidek <pjd@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 --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/geom/eli/g_eli.c 214116 2010-10-20 20:01:45Z pjd $"); | 28__FBSDID("$FreeBSD: head/sys/geom/eli/g_eli.c 214118 2010-10-20 20:50:55Z pjd $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/linker.h> 34#include <sys/module.h> 35#include <sys/lock.h> 36#include <sys/mutex.h> --- 64 unchanged lines hidden (view full) --- 101 .init = g_eli_init, 102 .fini = g_eli_fini 103}; 104 105 106/* 107 * Code paths: 108 * BIO_READ: | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/linker.h> 34#include <sys/module.h> 35#include <sys/lock.h> 36#include <sys/mutex.h> --- 64 unchanged lines hidden (view full) --- 101 .init = g_eli_init, 102 .fini = g_eli_fini 103}; 104 105 106/* 107 * Code paths: 108 * BIO_READ: |
109 * g_eli_start -> g_io_request -> g_eli_read_done -> g_eli_crypto_run -> g_eli_crypto_read_done -> g_io_deliver | 109 * g_eli_start -> g_eli_crypto_read -> g_io_request -> g_eli_read_done -> g_eli_crypto_run -> g_eli_crypto_read_done -> g_io_deliver |
110 * BIO_WRITE: 111 * g_eli_start -> g_eli_crypto_run -> g_eli_crypto_write_done -> g_io_request -> g_eli_write_done -> g_io_deliver 112 */ 113 114 115/* 116 * EAGAIN from crypto(9) means, that we were probably balanced to another crypto 117 * accelerator or something like this. --- 25 unchanged lines hidden (view full) --- 143 G_ELI_DEBUG(1, "%s: crypto_dispatch() returned %d.", __func__, error); 144 crp->crp_etype = error; 145 return (error); 146} 147 148/* 149 * The function is called afer reading encrypted data from the provider. 150 * | 110 * BIO_WRITE: 111 * g_eli_start -> g_eli_crypto_run -> g_eli_crypto_write_done -> g_io_request -> g_eli_write_done -> g_io_deliver 112 */ 113 114 115/* 116 * EAGAIN from crypto(9) means, that we were probably balanced to another crypto 117 * accelerator or something like this. --- 25 unchanged lines hidden (view full) --- 143 G_ELI_DEBUG(1, "%s: crypto_dispatch() returned %d.", __func__, error); 144 crp->crp_etype = error; 145 return (error); 146} 147 148/* 149 * The function is called afer reading encrypted data from the provider. 150 * |
151 * g_eli_start -> g_io_request -> G_ELI_READ_DONE -> g_eli_crypto_run -> g_eli_crypto_read_done -> g_io_deliver | 151 * g_eli_start -> g_eli_crypto_read -> g_io_request -> G_ELI_READ_DONE -> g_eli_crypto_run -> g_eli_crypto_read_done -> g_io_deliver |
152 */ 153void 154g_eli_read_done(struct bio *bp) 155{ 156 struct g_eli_softc *sc; 157 struct bio *pbp; 158 159 G_ELI_LOGREQ(2, bp, "Request done."); 160 pbp = bp->bio_parent; 161 if (pbp->bio_error == 0) 162 pbp->bio_error = bp->bio_error; 163 /* 164 * Do we have all sectors already? 165 */ 166 pbp->bio_inbed++; 167 if (pbp->bio_inbed < pbp->bio_children) 168 return; 169 g_destroy_bio(bp); | 152 */ 153void 154g_eli_read_done(struct bio *bp) 155{ 156 struct g_eli_softc *sc; 157 struct bio *pbp; 158 159 G_ELI_LOGREQ(2, bp, "Request done."); 160 pbp = bp->bio_parent; 161 if (pbp->bio_error == 0) 162 pbp->bio_error = bp->bio_error; 163 /* 164 * Do we have all sectors already? 165 */ 166 pbp->bio_inbed++; 167 if (pbp->bio_inbed < pbp->bio_children) 168 return; 169 g_destroy_bio(bp); |
170 sc = pbp->bio_to->geom->softc; |
|
170 if (pbp->bio_error != 0) { 171 G_ELI_LOGREQ(0, pbp, "%s() failed", __func__); 172 pbp->bio_completed = 0; 173 if (pbp->bio_driver2 != NULL) { 174 free(pbp->bio_driver2, M_ELI); 175 pbp->bio_driver2 = NULL; 176 } 177 g_io_deliver(pbp, pbp->bio_error); | 171 if (pbp->bio_error != 0) { 172 G_ELI_LOGREQ(0, pbp, "%s() failed", __func__); 173 pbp->bio_completed = 0; 174 if (pbp->bio_driver2 != NULL) { 175 free(pbp->bio_driver2, M_ELI); 176 pbp->bio_driver2 = NULL; 177 } 178 g_io_deliver(pbp, pbp->bio_error); |
179 atomic_subtract_int(&sc->sc_inflight, 1); |
|
178 return; 179 } | 180 return; 181 } |
180 sc = pbp->bio_to->geom->softc; | |
181 mtx_lock(&sc->sc_queue_mtx); 182 bioq_insert_tail(&sc->sc_queue, pbp); 183 mtx_unlock(&sc->sc_queue_mtx); 184 wakeup(sc); 185} 186 187/* 188 * The function is called after we encrypt and write data. 189 * 190 * g_eli_start -> g_eli_crypto_run -> g_eli_crypto_write_done -> g_io_request -> G_ELI_WRITE_DONE -> g_io_deliver 191 */ 192void 193g_eli_write_done(struct bio *bp) 194{ | 182 mtx_lock(&sc->sc_queue_mtx); 183 bioq_insert_tail(&sc->sc_queue, pbp); 184 mtx_unlock(&sc->sc_queue_mtx); 185 wakeup(sc); 186} 187 188/* 189 * The function is called after we encrypt and write data. 190 * 191 * g_eli_start -> g_eli_crypto_run -> g_eli_crypto_write_done -> g_io_request -> G_ELI_WRITE_DONE -> g_io_deliver 192 */ 193void 194g_eli_write_done(struct bio *bp) 195{ |
196 struct g_eli_softc *sc; |
|
195 struct bio *pbp; 196 197 G_ELI_LOGREQ(2, bp, "Request done."); 198 pbp = bp->bio_parent; 199 if (pbp->bio_error == 0) { 200 if (bp->bio_error != 0) 201 pbp->bio_error = bp->bio_error; 202 } --- 10 unchanged lines hidden (view full) --- 213 pbp->bio_error); 214 pbp->bio_completed = 0; 215 } 216 g_destroy_bio(bp); 217 /* 218 * Write is finished, send it up. 219 */ 220 pbp->bio_completed = pbp->bio_length; | 197 struct bio *pbp; 198 199 G_ELI_LOGREQ(2, bp, "Request done."); 200 pbp = bp->bio_parent; 201 if (pbp->bio_error == 0) { 202 if (bp->bio_error != 0) 203 pbp->bio_error = bp->bio_error; 204 } --- 10 unchanged lines hidden (view full) --- 215 pbp->bio_error); 216 pbp->bio_completed = 0; 217 } 218 g_destroy_bio(bp); 219 /* 220 * Write is finished, send it up. 221 */ 222 pbp->bio_completed = pbp->bio_length; |
223 sc = pbp->bio_to->geom->softc; |
|
221 g_io_deliver(pbp, pbp->bio_error); | 224 g_io_deliver(pbp, pbp->bio_error); |
225 atomic_subtract_int(&sc->sc_inflight, 1); |
|
222} 223 224/* 225 * This function should never be called, but GEOM made as it set ->orphan() 226 * method for every geom. 227 */ 228static void 229g_eli_orphan_spoil_assert(struct g_consumer *cp) --- 6 unchanged lines hidden (view full) --- 236g_eli_orphan(struct g_consumer *cp) 237{ 238 struct g_eli_softc *sc; 239 240 g_topology_assert(); 241 sc = cp->geom->softc; 242 if (sc == NULL) 243 return; | 226} 227 228/* 229 * This function should never be called, but GEOM made as it set ->orphan() 230 * method for every geom. 231 */ 232static void 233g_eli_orphan_spoil_assert(struct g_consumer *cp) --- 6 unchanged lines hidden (view full) --- 240g_eli_orphan(struct g_consumer *cp) 241{ 242 struct g_eli_softc *sc; 243 244 g_topology_assert(); 245 sc = cp->geom->softc; 246 if (sc == NULL) 247 return; |
244 g_eli_destroy(sc, 1); | 248 g_eli_destroy(sc, TRUE); |
245} 246 247/* 248 * BIO_READ: | 249} 250 251/* 252 * BIO_READ: |
249 * G_ELI_START -> g_io_request -> g_eli_read_done -> g_eli_crypto_run -> g_eli_crypto_read_done -> g_io_deliver | 253 * G_ELI_START -> g_eli_crypto_read -> g_io_request -> g_eli_read_done -> g_eli_crypto_run -> g_eli_crypto_read_done -> g_io_deliver |
250 * BIO_WRITE: 251 * G_ELI_START -> g_eli_crypto_run -> g_eli_crypto_write_done -> g_io_request -> g_eli_write_done -> g_io_deliver 252 */ 253static void 254g_eli_start(struct bio *bp) 255{ 256 struct g_eli_softc *sc; 257 struct g_consumer *cp; --- 21 unchanged lines hidden (view full) --- 279 g_io_deliver(bp, EOPNOTSUPP); 280 return; 281 } 282 cbp = g_clone_bio(bp); 283 if (cbp == NULL) { 284 g_io_deliver(bp, ENOMEM); 285 return; 286 } | 254 * BIO_WRITE: 255 * G_ELI_START -> g_eli_crypto_run -> g_eli_crypto_write_done -> g_io_request -> g_eli_write_done -> g_io_deliver 256 */ 257static void 258g_eli_start(struct bio *bp) 259{ 260 struct g_eli_softc *sc; 261 struct g_consumer *cp; --- 21 unchanged lines hidden (view full) --- 283 g_io_deliver(bp, EOPNOTSUPP); 284 return; 285 } 286 cbp = g_clone_bio(bp); 287 if (cbp == NULL) { 288 g_io_deliver(bp, ENOMEM); 289 return; 290 } |
291 bp->bio_driver1 = cbp; 292 bp->bio_pflags = G_ELI_NEW_BIO; |
|
287 switch (bp->bio_cmd) { 288 case BIO_READ: 289 if (!(sc->sc_flags & G_ELI_FLAG_AUTH)) { | 293 switch (bp->bio_cmd) { 294 case BIO_READ: 295 if (!(sc->sc_flags & G_ELI_FLAG_AUTH)) { |
290 bp->bio_driver2 = NULL; 291 cbp->bio_done = g_eli_read_done; 292 cp = LIST_FIRST(&sc->sc_geom->consumer); 293 cbp->bio_to = cp->provider; 294 G_ELI_LOGREQ(2, cbp, "Sending request."); 295 /* 296 * Read encrypted data from provider. 297 */ 298 g_io_request(cbp, cp); | 296 g_eli_crypto_read(sc, bp, 0); |
299 break; 300 } | 297 break; 298 } |
301 bp->bio_pflags = 255; | |
302 /* FALLTHROUGH */ 303 case BIO_WRITE: | 299 /* FALLTHROUGH */ 300 case BIO_WRITE: |
304 bp->bio_driver1 = cbp; | |
305 mtx_lock(&sc->sc_queue_mtx); 306 bioq_insert_tail(&sc->sc_queue, bp); 307 mtx_unlock(&sc->sc_queue_mtx); 308 wakeup(sc); 309 break; 310 case BIO_GETATTR: 311 case BIO_FLUSH: 312 cbp->bio_done = g_std_done; 313 cp = LIST_FIRST(&sc->sc_geom->consumer); 314 cbp->bio_to = cp->provider; 315 G_ELI_LOGREQ(2, cbp, "Sending request."); 316 g_io_request(cbp, cp); 317 break; 318 } 319} 320 | 301 mtx_lock(&sc->sc_queue_mtx); 302 bioq_insert_tail(&sc->sc_queue, bp); 303 mtx_unlock(&sc->sc_queue_mtx); 304 wakeup(sc); 305 break; 306 case BIO_GETATTR: 307 case BIO_FLUSH: 308 cbp->bio_done = g_std_done; 309 cp = LIST_FIRST(&sc->sc_geom->consumer); 310 cbp->bio_to = cp->provider; 311 G_ELI_LOGREQ(2, cbp, "Sending request."); 312 g_io_request(cbp, cp); 313 break; 314 } 315} 316 |
317static void 318g_eli_cancel(struct g_eli_softc *sc) 319{ 320 struct bio *bp; 321 322 mtx_assert(&sc->sc_queue_mtx, MA_OWNED); 323 324 while ((bp = bioq_takefirst(&sc->sc_queue)) != NULL) { 325 KASSERT(bp->bio_pflags == G_ELI_NEW_BIO, 326 ("Not new bio when canceling (bp=%p).", bp)); 327 g_io_deliver(bp, ENXIO); 328 } 329} 330 331static struct bio * 332g_eli_takefirst(struct g_eli_softc *sc) 333{ 334 struct bio *bp; 335 336 mtx_assert(&sc->sc_queue_mtx, MA_OWNED); 337 338 if (!(sc->sc_flags & G_ELI_FLAG_SUSPEND)) 339 return (bioq_takefirst(&sc->sc_queue)); 340 /* 341 * Device suspended, so we skip new I/O requests. 342 */ 343 TAILQ_FOREACH(bp, &sc->sc_queue.queue, bio_queue) { 344 if (bp->bio_pflags != G_ELI_NEW_BIO) 345 break; 346 } 347 if (bp != NULL) 348 bioq_remove(&sc->sc_queue, bp); 349 return (bp); 350} 351 |
|
321/* 322 * This is the main function for kernel worker thread when we don't have 323 * hardware acceleration and we have to do cryptography in software. 324 * Dedicated thread is needed, so we don't slow down g_up/g_down GEOM 325 * threads with crypto work. 326 */ 327static void 328g_eli_worker(void *arg) --- 17 unchanged lines hidden (view full) --- 346 if (sc->sc_crypto == G_ELI_CRYPTO_SW && g_eli_threads == 0) 347 sched_bind(curthread, wr->w_number); 348 thread_unlock(curthread); 349 350 G_ELI_DEBUG(1, "Thread %s started.", curthread->td_proc->p_comm); 351 352 for (;;) { 353 mtx_lock(&sc->sc_queue_mtx); | 352/* 353 * This is the main function for kernel worker thread when we don't have 354 * hardware acceleration and we have to do cryptography in software. 355 * Dedicated thread is needed, so we don't slow down g_up/g_down GEOM 356 * threads with crypto work. 357 */ 358static void 359g_eli_worker(void *arg) --- 17 unchanged lines hidden (view full) --- 377 if (sc->sc_crypto == G_ELI_CRYPTO_SW && g_eli_threads == 0) 378 sched_bind(curthread, wr->w_number); 379 thread_unlock(curthread); 380 381 G_ELI_DEBUG(1, "Thread %s started.", curthread->td_proc->p_comm); 382 383 for (;;) { 384 mtx_lock(&sc->sc_queue_mtx); |
354 bp = bioq_takefirst(&sc->sc_queue); | 385again: 386 bp = g_eli_takefirst(sc); |
355 if (bp == NULL) { 356 if (sc->sc_flags & G_ELI_FLAG_DESTROY) { | 387 if (bp == NULL) { 388 if (sc->sc_flags & G_ELI_FLAG_DESTROY) { |
389 g_eli_cancel(sc); |
|
357 LIST_REMOVE(wr, w_next); 358 crypto_freesession(wr->w_sid); 359 free(wr, M_ELI); 360 G_ELI_DEBUG(1, "Thread %s exiting.", 361 curthread->td_proc->p_comm); 362 wakeup(&sc->sc_workers); 363 mtx_unlock(&sc->sc_queue_mtx); 364 kproc_exit(0); 365 } | 390 LIST_REMOVE(wr, w_next); 391 crypto_freesession(wr->w_sid); 392 free(wr, M_ELI); 393 G_ELI_DEBUG(1, "Thread %s exiting.", 394 curthread->td_proc->p_comm); 395 wakeup(&sc->sc_workers); 396 mtx_unlock(&sc->sc_queue_mtx); 397 kproc_exit(0); 398 } |
399 while (sc->sc_flags & G_ELI_FLAG_SUSPEND) { 400 if (sc->sc_inflight > 0) { 401 G_ELI_DEBUG(0, "inflight=%d", sc->sc_inflight); 402 /* 403 * We still have inflight BIOs, so 404 * sleep and retry. 405 */ 406 msleep(sc, &sc->sc_queue_mtx, PRIBIO, 407 "geli:inf", hz / 5); 408 goto again; 409 } 410 /* 411 * Suspend requested, mark the worker as 412 * suspended and go to sleep. 413 */ 414 wr->w_active = 0; 415 wakeup(&sc->sc_workers); 416 msleep(sc, &sc->sc_queue_mtx, PRIBIO, 417 "geli:suspend", 0); 418 if (!(sc->sc_flags & G_ELI_FLAG_SUSPEND)) 419 wr->w_active = 1; 420 goto again; 421 } |
|
366 msleep(sc, &sc->sc_queue_mtx, PDROP, "geli:w", 0); 367 continue; 368 } | 422 msleep(sc, &sc->sc_queue_mtx, PDROP, "geli:w", 0); 423 continue; 424 } |
425 if (bp->bio_pflags == G_ELI_NEW_BIO) 426 atomic_add_int(&sc->sc_inflight, 1); |
|
369 mtx_unlock(&sc->sc_queue_mtx); | 427 mtx_unlock(&sc->sc_queue_mtx); |
370 if (bp->bio_cmd == BIO_READ && bp->bio_pflags == 255) 371 g_eli_auth_read(sc, bp); 372 else if (sc->sc_flags & G_ELI_FLAG_AUTH) 373 g_eli_auth_run(wr, bp); 374 else 375 g_eli_crypto_run(wr, bp); | 428 if (bp->bio_pflags == G_ELI_NEW_BIO) { 429 bp->bio_pflags = 0; 430 if (sc->sc_flags & G_ELI_FLAG_AUTH) { 431 if (bp->bio_cmd == BIO_READ) 432 g_eli_auth_read(sc, bp); 433 else 434 g_eli_auth_run(wr, bp); 435 } else { 436 if (bp->bio_cmd == BIO_READ) 437 g_eli_crypto_read(sc, bp, 1); 438 else 439 g_eli_crypto_run(wr, bp); 440 } 441 } else { 442 if (sc->sc_flags & G_ELI_FLAG_AUTH) 443 g_eli_auth_run(wr, bp); 444 else 445 g_eli_crypto_run(wr, bp); 446 } |
376 } 377} 378 379/* 380 * Select encryption key. If G_ELI_FLAG_SINGLE_KEY is present we only have one 381 * key available for all the data. If the flag is not present select the key 382 * based on data offset. 383 */ --- 113 unchanged lines hidden (view full) --- 497 struct g_provider *pp; 498 char ppname[64]; 499 int error; 500 501 g_topology_assert(); 502 gp = sc->sc_geom; 503 pp = LIST_FIRST(&gp->provider); 504 strlcpy(ppname, pp->name, sizeof(ppname)); | 447 } 448} 449 450/* 451 * Select encryption key. If G_ELI_FLAG_SINGLE_KEY is present we only have one 452 * key available for all the data. If the flag is not present select the key 453 * based on data offset. 454 */ --- 113 unchanged lines hidden (view full) --- 568 struct g_provider *pp; 569 char ppname[64]; 570 int error; 571 572 g_topology_assert(); 573 gp = sc->sc_geom; 574 pp = LIST_FIRST(&gp->provider); 575 strlcpy(ppname, pp->name, sizeof(ppname)); |
505 error = g_eli_destroy(sc, 1); | 576 error = g_eli_destroy(sc, TRUE); |
506 KASSERT(error == 0, ("Cannot detach %s on last close (error=%d).", 507 ppname, error)); 508 G_ELI_DEBUG(0, "Detached %s on last close.", ppname); 509} 510 511int 512g_eli_access(struct g_provider *pp, int dr, int dw, int de) 513{ --- 67 unchanged lines hidden (view full) --- 581 * If detach-on-last-close feature is not enabled and we don't operate 582 * on read-only provider, we can simply use g_std_access(). 583 */ 584 if (md->md_flags & (G_ELI_FLAG_WO_DETACH | G_ELI_FLAG_RO)) 585 gp->access = g_eli_access; 586 else 587 gp->access = g_std_access; 588 | 577 KASSERT(error == 0, ("Cannot detach %s on last close (error=%d).", 578 ppname, error)); 579 G_ELI_DEBUG(0, "Detached %s on last close.", ppname); 580} 581 582int 583g_eli_access(struct g_provider *pp, int dr, int dw, int de) 584{ --- 67 unchanged lines hidden (view full) --- 652 * If detach-on-last-close feature is not enabled and we don't operate 653 * on read-only provider, we can simply use g_std_access(). 654 */ 655 if (md->md_flags & (G_ELI_FLAG_WO_DETACH | G_ELI_FLAG_RO)) 656 gp->access = g_eli_access; 657 else 658 gp->access = g_std_access; 659 |
660 sc->sc_inflight = 0; |
|
589 sc->sc_crypto = G_ELI_CRYPTO_SW; 590 sc->sc_flags = md->md_flags; 591 /* Backward compatibility. */ 592 if (md->md_version < 4) 593 sc->sc_flags |= G_ELI_FLAG_NATIVE_BYTE_ORDER; 594 if (md->md_version < 5) 595 sc->sc_flags |= G_ELI_FLAG_SINGLE_KEY; 596 sc->sc_ealgo = md->md_ealgo; --- 128 unchanged lines hidden (view full) --- 725 if (g_eli_cpu_is_disabled(i)) { 726 G_ELI_DEBUG(1, "%s: CPU %u disabled, skipping.", 727 bpp->name, i); 728 continue; 729 } 730 wr = malloc(sizeof(*wr), M_ELI, M_WAITOK | M_ZERO); 731 wr->w_softc = sc; 732 wr->w_number = i; | 661 sc->sc_crypto = G_ELI_CRYPTO_SW; 662 sc->sc_flags = md->md_flags; 663 /* Backward compatibility. */ 664 if (md->md_version < 4) 665 sc->sc_flags |= G_ELI_FLAG_NATIVE_BYTE_ORDER; 666 if (md->md_version < 5) 667 sc->sc_flags |= G_ELI_FLAG_SINGLE_KEY; 668 sc->sc_ealgo = md->md_ealgo; --- 128 unchanged lines hidden (view full) --- 797 if (g_eli_cpu_is_disabled(i)) { 798 G_ELI_DEBUG(1, "%s: CPU %u disabled, skipping.", 799 bpp->name, i); 800 continue; 801 } 802 wr = malloc(sizeof(*wr), M_ELI, M_WAITOK | M_ZERO); 803 wr->w_softc = sc; 804 wr->w_number = i; |
805 wr->w_active = TRUE; |
|
733 734 /* 735 * If this is the first pass, try to get hardware support. 736 * Use software cryptography, if we cannot get it. 737 */ 738 if (LIST_EMPTY(&sc->sc_workers)) { 739 error = crypto_newsession(&wr->w_sid, &crie, 740 CRYPTOCAP_F_HARDWARE); --- 131 unchanged lines hidden (view full) --- 872 873static int 874g_eli_destroy_geom(struct gctl_req *req __unused, 875 struct g_class *mp __unused, struct g_geom *gp) 876{ 877 struct g_eli_softc *sc; 878 879 sc = gp->softc; | 806 807 /* 808 * If this is the first pass, try to get hardware support. 809 * Use software cryptography, if we cannot get it. 810 */ 811 if (LIST_EMPTY(&sc->sc_workers)) { 812 error = crypto_newsession(&wr->w_sid, &crie, 813 CRYPTOCAP_F_HARDWARE); --- 131 unchanged lines hidden (view full) --- 945 946static int 947g_eli_destroy_geom(struct gctl_req *req __unused, 948 struct g_class *mp __unused, struct g_geom *gp) 949{ 950 struct g_eli_softc *sc; 951 952 sc = gp->softc; |
880 return (g_eli_destroy(sc, 0)); | 953 return (g_eli_destroy(sc, FALSE)); |
881} 882 883static int 884g_eli_keyfiles_load(struct hmac_ctx *ctx, const char *provider) 885{ 886 u_char *keyfile, *data, *size; 887 char *file, name[64]; 888 int i; --- 214 unchanged lines hidden (view full) --- 1103 if (sc->sc_flags & (flag)) { \ 1104 if (!first) \ 1105 sbuf_printf(sb, ", "); \ 1106 else \ 1107 first = 0; \ 1108 sbuf_printf(sb, name); \ 1109 } \ 1110} while (0) | 954} 955 956static int 957g_eli_keyfiles_load(struct hmac_ctx *ctx, const char *provider) 958{ 959 u_char *keyfile, *data, *size; 960 char *file, name[64]; 961 int i; --- 214 unchanged lines hidden (view full) --- 1176 if (sc->sc_flags & (flag)) { \ 1177 if (!first) \ 1178 sbuf_printf(sb, ", "); \ 1179 else \ 1180 first = 0; \ 1181 sbuf_printf(sb, name); \ 1182 } \ 1183} while (0) |
1184 ADD_FLAG(G_ELI_FLAG_SUSPEND, "SUSPEND"); |
|
1111 ADD_FLAG(G_ELI_FLAG_SINGLE_KEY, "SINGLE-KEY"); 1112 ADD_FLAG(G_ELI_FLAG_NATIVE_BYTE_ORDER, "NATIVE-BYTE-ORDER"); 1113 ADD_FLAG(G_ELI_FLAG_ONETIME, "ONETIME"); 1114 ADD_FLAG(G_ELI_FLAG_BOOT, "BOOT"); 1115 ADD_FLAG(G_ELI_FLAG_WO_DETACH, "W-DETACH"); 1116 ADD_FLAG(G_ELI_FLAG_RW_DETACH, "RW-DETACH"); 1117 ADD_FLAG(G_ELI_FLAG_AUTH, "AUTH"); 1118 ADD_FLAG(G_ELI_FLAG_WOPEN, "W-OPEN"); --- 45 unchanged lines hidden (view full) --- 1164 g_topology_lock(); 1165 LIST_FOREACH_SAFE(gp, &mp->geom, geom, gp2) { 1166 sc = gp->softc; 1167 if (sc == NULL) 1168 continue; 1169 pp = LIST_FIRST(&gp->provider); 1170 KASSERT(pp != NULL, ("No provider? gp=%p (%s)", gp, gp->name)); 1171 if (pp->acr + pp->acw + pp->ace == 0) | 1185 ADD_FLAG(G_ELI_FLAG_SINGLE_KEY, "SINGLE-KEY"); 1186 ADD_FLAG(G_ELI_FLAG_NATIVE_BYTE_ORDER, "NATIVE-BYTE-ORDER"); 1187 ADD_FLAG(G_ELI_FLAG_ONETIME, "ONETIME"); 1188 ADD_FLAG(G_ELI_FLAG_BOOT, "BOOT"); 1189 ADD_FLAG(G_ELI_FLAG_WO_DETACH, "W-DETACH"); 1190 ADD_FLAG(G_ELI_FLAG_RW_DETACH, "RW-DETACH"); 1191 ADD_FLAG(G_ELI_FLAG_AUTH, "AUTH"); 1192 ADD_FLAG(G_ELI_FLAG_WOPEN, "W-OPEN"); --- 45 unchanged lines hidden (view full) --- 1238 g_topology_lock(); 1239 LIST_FOREACH_SAFE(gp, &mp->geom, geom, gp2) { 1240 sc = gp->softc; 1241 if (sc == NULL) 1242 continue; 1243 pp = LIST_FIRST(&gp->provider); 1244 KASSERT(pp != NULL, ("No provider? gp=%p (%s)", gp, gp->name)); 1245 if (pp->acr + pp->acw + pp->ace == 0) |
1172 error = g_eli_destroy(sc, 1); | 1246 error = g_eli_destroy(sc, TRUE); |
1173 else { 1174 sc->sc_flags |= G_ELI_FLAG_RW_DETACH; 1175 gp->access = g_eli_access; 1176 } 1177 } 1178 g_topology_unlock(); 1179 PICKUP_GIANT(); 1180} --- 21 unchanged lines hidden --- | 1247 else { 1248 sc->sc_flags |= G_ELI_FLAG_RW_DETACH; 1249 gp->access = g_eli_access; 1250 } 1251 } 1252 g_topology_unlock(); 1253 PICKUP_GIANT(); 1254} --- 21 unchanged lines hidden --- |