isc_sm.c (201758) | isc_sm.c (211095) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 2005-2008 Daniel Braniss <danny@cs.huji.ac.il> | 2 * Copyright (c) 2005-2010 Daniel Braniss <danny@cs.huji.ac.il> |
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 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 10 unchanged lines hidden (view full) --- 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/* 28 | iSCSI - Session Manager | 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 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 10 unchanged lines hidden (view full) --- 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/* 28 | iSCSI - Session Manager |
29 | $Id: isc_sm.c,v 1.30 2007/04/22 09:53:09 danny Exp danny $ | 29 | $Id: isc_sm.c 743 2009-08-08 10:54:53Z danny $ |
30 */ 31 32#include <sys/cdefs.h> | 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/iscsi/initiator/isc_sm.c 201758 2010-01-07 21:01:37Z mbr $"); | 33__FBSDID("$FreeBSD: head/sys/dev/iscsi/initiator/isc_sm.c 211095 2010-08-09 12:36:36Z des $"); |
34 35#include "opt_iscsi_initiator.h" 36 37#include <sys/param.h> 38#include <sys/kernel.h> 39#include <sys/conf.h> 40#include <sys/systm.h> 41#include <sys/malloc.h> --- 7 unchanged lines hidden (view full) --- 49#include <sys/protosw.h> 50#include <sys/proc.h> 51#include <sys/ioccom.h> 52#include <sys/queue.h> 53#include <sys/kthread.h> 54#include <sys/syslog.h> 55#include <sys/mbuf.h> 56#include <sys/bus.h> | 34 35#include "opt_iscsi_initiator.h" 36 37#include <sys/param.h> 38#include <sys/kernel.h> 39#include <sys/conf.h> 40#include <sys/systm.h> 41#include <sys/malloc.h> --- 7 unchanged lines hidden (view full) --- 49#include <sys/protosw.h> 50#include <sys/proc.h> 51#include <sys/ioccom.h> 52#include <sys/queue.h> 53#include <sys/kthread.h> 54#include <sys/syslog.h> 55#include <sys/mbuf.h> 56#include <sys/bus.h> |
57#include <sys/sx.h> |
|
57 58#include <cam/cam.h> 59#include <cam/cam_ccb.h> 60#include <cam/cam_sim.h> 61#include <cam/cam_xpt_sim.h> 62#include <cam/cam_periph.h> 63 64#include <dev/iscsi/initiator/iscsi.h> --- 61 unchanged lines hidden (view full) --- 126static void 127_scsi_rsp(isc_session_t *sp, pduq_t *pq) 128{ 129 pduq_t *opq; 130 131 debug_called(8); 132 opq = i_search_hld(sp, pq->pdu.ipdu.bhs.itt, 0); 133 debug(5, "itt=%x pq=%p opq=%p", ntohl(pq->pdu.ipdu.bhs.itt), pq, opq); | 58 59#include <cam/cam.h> 60#include <cam/cam_ccb.h> 61#include <cam/cam_sim.h> 62#include <cam/cam_xpt_sim.h> 63#include <cam/cam_periph.h> 64 65#include <dev/iscsi/initiator/iscsi.h> --- 61 unchanged lines hidden (view full) --- 127static void 128_scsi_rsp(isc_session_t *sp, pduq_t *pq) 129{ 130 pduq_t *opq; 131 132 debug_called(8); 133 opq = i_search_hld(sp, pq->pdu.ipdu.bhs.itt, 0); 134 debug(5, "itt=%x pq=%p opq=%p", ntohl(pq->pdu.ipdu.bhs.itt), pq, opq); |
134 if(opq != NULL) | 135 if(opq != NULL) { |
135 iscsi_done(sp, opq, pq); | 136 iscsi_done(sp, opq, pq); |
137 i_acked_hld(sp, &pq->pdu); 138 } |
|
136 else 137 xdebug("%d] we lost something itt=%x", 138 sp->sid, ntohl(pq->pdu.ipdu.bhs.itt)); 139 pdu_free(sp->isc, pq); 140} 141 142static void 143_read_data(isc_session_t *sp, pduq_t *pq) --- 118 unchanged lines hidden (view full) --- 262 pdu_t *pp = &pq->pdu; 263 bhs_t *bhp = &pp->ipdu.bhs; 264 265 len = sizeof(bhs_t); 266 if(pp->ahs_len) { 267 len += pp->ahs_len; 268 bhp->AHSLength = pp->ahs_len / 4; 269 } | 139 else 140 xdebug("%d] we lost something itt=%x", 141 sp->sid, ntohl(pq->pdu.ipdu.bhs.itt)); 142 pdu_free(sp->isc, pq); 143} 144 145static void 146_read_data(isc_session_t *sp, pduq_t *pq) --- 118 unchanged lines hidden (view full) --- 265 pdu_t *pp = &pq->pdu; 266 bhs_t *bhp = &pp->ipdu.bhs; 267 268 len = sizeof(bhs_t); 269 if(pp->ahs_len) { 270 len += pp->ahs_len; 271 bhp->AHSLength = pp->ahs_len / 4; 272 } |
270 if(sp->hdrDigest) | 273 if(ISOK2DIG(sp->hdrDigest, pp)) |
271 len += 4; 272 if(pp->ds_len) { 273 n = pp->ds_len; 274 len += n; 275#if BYTE_ORDER == LITTLE_ENDIAN 276 bhp->DSLength = ((n & 0x00ff0000) >> 16) 277 | (n & 0x0000ff00) 278 | ((n & 0x000000ff) << 16); 279#else 280 bhp->DSLength = n; 281#endif 282 if(len & 03) { 283 n = 4 - (len & 03); 284 len += n; 285 } | 274 len += 4; 275 if(pp->ds_len) { 276 n = pp->ds_len; 277 len += n; 278#if BYTE_ORDER == LITTLE_ENDIAN 279 bhp->DSLength = ((n & 0x00ff0000) >> 16) 280 | (n & 0x0000ff00) 281 | ((n & 0x000000ff) << 16); 282#else 283 bhp->DSLength = n; 284#endif 285 if(len & 03) { 286 n = 4 - (len & 03); 287 len += n; 288 } |
286 if(sp->dataDigest) | 289 if(ISOK2DIG(sp->dataDigest, pp)) |
287 len += 4; 288 } 289 290 pq->len = len; 291 len -= sizeof(bhs_t); 292 if(sp->opt.maxBurstLength && (len > sp->opt.maxBurstLength)) { 293 xdebug("%d] pdu len=%zd > %d", 294 sp->sid, len, sp->opt.maxBurstLength); --- 21 unchanged lines hidden (view full) --- 316 else 317 i_nqueue_csnd(sp, pq); 318 319 sdebug(5, "enqued: pq=%p", pq); 320 321 mtx_lock(&sp->io_mtx); 322 sp->flags |= ISC_OQNOTEMPTY; 323 if(sp->flags & ISC_OWAITING) | 290 len += 4; 291 } 292 293 pq->len = len; 294 len -= sizeof(bhs_t); 295 if(sp->opt.maxBurstLength && (len > sp->opt.maxBurstLength)) { 296 xdebug("%d] pdu len=%zd > %d", 297 sp->sid, len, sp->opt.maxBurstLength); --- 21 unchanged lines hidden (view full) --- 319 else 320 i_nqueue_csnd(sp, pq); 321 322 sdebug(5, "enqued: pq=%p", pq); 323 324 mtx_lock(&sp->io_mtx); 325 sp->flags |= ISC_OQNOTEMPTY; 326 if(sp->flags & ISC_OWAITING) |
324 wakeup(&sp->flags); | 327 wakeup(&sp->flags); |
325 mtx_unlock(&sp->io_mtx); 326 327 return error; 328} 329/* 330 | called when a fullPhase is restarted 331 */ | 328 mtx_unlock(&sp->io_mtx); 329 330 return error; 331} 332/* 333 | called when a fullPhase is restarted 334 */ |
332static void | 335void |
333ism_restart(isc_session_t *sp) 334{ 335 int lastcmd; 336 337 sdebug(2, "restart ..."); 338 lastcmd = iscsi_requeue(sp); 339#if 0 340 if(lastcmd != sp->sn.cmd) { 341 sdebug(1, "resetting CmdSN to=%d (from %d)", lastcmd, sp->sn.cmd); 342 sp->sn.cmd = lastcmd; 343 } 344#endif 345 mtx_lock(&sp->io_mtx); 346 if(sp->flags & ISC_OWAITING) { 347 wakeup(&sp->flags); 348 } 349 mtx_unlock(&sp->io_mtx); 350 | 336ism_restart(isc_session_t *sp) 337{ 338 int lastcmd; 339 340 sdebug(2, "restart ..."); 341 lastcmd = iscsi_requeue(sp); 342#if 0 343 if(lastcmd != sp->sn.cmd) { 344 sdebug(1, "resetting CmdSN to=%d (from %d)", lastcmd, sp->sn.cmd); 345 sp->sn.cmd = lastcmd; 346 } 347#endif 348 mtx_lock(&sp->io_mtx); 349 if(sp->flags & ISC_OWAITING) { 350 wakeup(&sp->flags); 351 } 352 mtx_unlock(&sp->io_mtx); 353 |
351 sdebug(2, "restarted lastcmd=0x%x", lastcmd); | 354 sdebug(2, "restarted sn.cmd=0x%x lastcmd=0x%x", sp->sn.cmd, lastcmd); |
352} 353 | 355} 356 |
354int 355ism_fullfeature(struct cdev *dev, int flag) 356{ 357 isc_session_t *sp = (isc_session_t *)dev->si_drv2; 358 int error; 359 360 sdebug(2, "flag=%d", flag); 361 362 error = 0; 363 switch(flag) { 364 case 0: // stop 365 sp->flags &= ~ISC_FFPHASE; 366 break; 367 case 1: // start 368 error = ic_fullfeature(dev); 369 break; 370 case 2: // restart 371 ism_restart(sp); 372 break; 373 } 374 return error; 375} 376 | |
377void 378ism_recv(isc_session_t *sp, pduq_t *pq) 379{ 380 bhs_t *bhs; 381 int statSN; 382 383 debug_called(8); 384 385 bhs = &pq->pdu.ipdu.bhs; 386 statSN = ntohl(bhs->OpcodeSpecificFields[1]); | 357void 358ism_recv(isc_session_t *sp, pduq_t *pq) 359{ 360 bhs_t *bhs; 361 int statSN; 362 363 debug_called(8); 364 365 bhs = &pq->pdu.ipdu.bhs; 366 statSN = ntohl(bhs->OpcodeSpecificFields[1]); |
387#if 0 388 { 389 /* 390 | this code is only for debugging. 391 */ 392 sn_t *sn = &sp->sn; 393 if(sp->cws == 0) { 394 if((sp->flags & ISC_STALLED) == 0) { 395 sdebug(4, "window closed: max=0x%x exp=0x%x opcode=0x%x cmd=0x%x cws=%d.", 396 sn->maxCmd, sn->expCmd, bhs->opcode, sn->cmd, sp->cws); 397 sp->flags |= ISC_STALLED; 398 } else 399 if(sp->flags & ISC_STALLED) { 400 sdebug(4, "window opened: max=0x%x exp=0x%x opcode=0x%x cmd=0x%x cws=%d.", 401 sn->maxCmd, sn->expCmd, bhs->opcode, sn->cmd, sp->cws); 402 sp->flags &= ~ISC_STALLED; 403 } 404 } 405 } 406#endif | |
407 408#ifdef notyet 409 if(sp->sn.expCmd != sn->cmd) { 410 sdebug(1, "we lost something ... exp=0x%x cmd=0x%x", 411 sn->expCmd, sn->cmd); 412 } 413#endif 414 sdebug(5, "opcode=0x%x itt=0x%x stat#0x%x maxcmd=0x%0x", --- 34 unchanged lines hidden (view full) --- 449 450 case ISCSI_TASK_RSP: 451 default: 452 sdebug(1, "opcode=0x%x itt=0x%x not implemented yet", 453 bhs->opcode, ntohl(bhs->itt)); 454 break; 455 } 456} | 367 368#ifdef notyet 369 if(sp->sn.expCmd != sn->cmd) { 370 sdebug(1, "we lost something ... exp=0x%x cmd=0x%x", 371 sn->expCmd, sn->cmd); 372 } 373#endif 374 sdebug(5, "opcode=0x%x itt=0x%x stat#0x%x maxcmd=0x%0x", --- 34 unchanged lines hidden (view full) --- 409 410 case ISCSI_TASK_RSP: 411 default: 412 sdebug(1, "opcode=0x%x itt=0x%x not implemented yet", 413 bhs->opcode, ntohl(bhs->itt)); 414 break; 415 } 416} |
457 | 417 |
458/* 459 | go through the out queues looking for work 460 | if either nothing to do, or window is closed 461 | return. 462 */ 463static int 464proc_out(isc_session_t *sp) 465{ 466 sn_t *sn = &sp->sn; 467 pduq_t *pq; | 418/* 419 | go through the out queues looking for work 420 | if either nothing to do, or window is closed 421 | return. 422 */ 423static int 424proc_out(isc_session_t *sp) 425{ 426 sn_t *sn = &sp->sn; 427 pduq_t *pq; |
468 int error, ndone; 469 int which; | 428 int error, which; |
470 471 debug_called(8); | 429 430 debug_called(8); |
472 error = ndone = 0; | 431 error = 0; |
473 474 while(sp->flags & ISC_LINK_UP) { 475 pdu_t *pp; 476 bhs_t *bhs; 477 /* 478 | check if there is outstanding work in: 479 | 1- the Immediate queue 480 | 2- the R2T queue --- 22 unchanged lines hidden (view full) --- 503 case ISCSI_SNACK: 504 case ISCSI_NOP_OUT: 505 case ISCSI_TASK_CMD: 506 bhs->CmdSN = htonl(sn->cmd); 507 if(bhs->I == 0) 508 sn->cmd++; 509 510 case ISCSI_WRITE_DATA: | 432 433 while(sp->flags & ISC_LINK_UP) { 434 pdu_t *pp; 435 bhs_t *bhs; 436 /* 437 | check if there is outstanding work in: 438 | 1- the Immediate queue 439 | 2- the R2T queue --- 22 unchanged lines hidden (view full) --- 462 case ISCSI_SNACK: 463 case ISCSI_NOP_OUT: 464 case ISCSI_TASK_CMD: 465 bhs->CmdSN = htonl(sn->cmd); 466 if(bhs->I == 0) 467 sn->cmd++; 468 469 case ISCSI_WRITE_DATA: |
511 bhs->ExpStSN = htonl(sn->stat); | 470 bhs->ExpStSN = htonl(sn->stat + 1); |
512 break; 513 514 default: 515 // XXX: can this happen? 516 xdebug("bad opcode=0x%x sn(cmd=0x%x expCmd=0x%x maxCmd=0x%x expStat=0x%x itt=0x%x)", 517 bhs->opcode, 518 sn->cmd, sn->expCmd, sn->maxCmd, sn->expStat, sn->itt); 519 // XXX: and now? 520 } 521 522 sdebug(4, "opcode=0x%x sn(cmd=0x%x expCmd=0x%x maxCmd=0x%x expStat=0x%x itt=0x%x)", 523 bhs->opcode, 524 sn->cmd, sn->expCmd, sn->maxCmd, sn->expStat, sn->itt); 525 | 471 break; 472 473 default: 474 // XXX: can this happen? 475 xdebug("bad opcode=0x%x sn(cmd=0x%x expCmd=0x%x maxCmd=0x%x expStat=0x%x itt=0x%x)", 476 bhs->opcode, 477 sn->cmd, sn->expCmd, sn->maxCmd, sn->expStat, sn->itt); 478 // XXX: and now? 479 } 480 481 sdebug(4, "opcode=0x%x sn(cmd=0x%x expCmd=0x%x maxCmd=0x%x expStat=0x%x itt=0x%x)", 482 bhs->opcode, 483 sn->cmd, sn->expCmd, sn->maxCmd, sn->expStat, sn->itt); 484 |
526 if(pq->ccb) | 485 if(bhs->opcode != ISCSI_NOP_OUT) 486 /* 487 | enqued till ack is received 488 | note: sosend(...) does not mean the packet left 489 | the host so that freeing resources has to wait 490 */ |
527 i_nqueue_hld(sp, pq); 528 | 491 i_nqueue_hld(sp, pq); 492 |
529 if((error = isc_sendPDU(sp, pq)) == 0) { 530 ndone++; 531 if(pq->ccb == NULL) 532 pdu_free(sp->isc, pq); 533 } 534 else { 535 xdebug("error=%d ndone=%d opcode=0x%x ccb=%p itt=%x", 536 error, ndone, bhs->opcode, pq->ccb, ntohl(bhs->itt)); 537 if(pq->ccb) 538 i_remove_hld(sp, pq); | 493 error = isc_sendPDU(sp, pq); 494 if(bhs->opcode == ISCSI_NOP_OUT) 495 pdu_free(sp->isc, pq); 496 if(error) { 497 xdebug("error=%d opcode=0x%x ccb=%p itt=%x", 498 error, bhs->opcode, pq->ccb, ntohl(bhs->itt)); 499 i_remove_hld(sp, pq); |
539 switch(error) { 540 case EPIPE: 541 sp->flags &= ~ISC_LINK_UP; 542 543 case EAGAIN: 544 xdebug("requed"); 545 i_rqueue_pdu(sp, pq); 546 break; 547 548 default: | 500 switch(error) { 501 case EPIPE: 502 sp->flags &= ~ISC_LINK_UP; 503 504 case EAGAIN: 505 xdebug("requed"); 506 i_rqueue_pdu(sp, pq); 507 break; 508 509 default: |
549 if(pq->ccb) { | 510 if(pq->ccb) { |
550 xdebug("back to cam"); 551 pq->ccb->ccb_h.status |= CAM_REQUEUE_REQ; // some better error? | 511 xdebug("back to cam"); 512 pq->ccb->ccb_h.status |= CAM_REQUEUE_REQ; // some better error? |
552 XPT_DONE(sp->isc, pq->ccb); | 513 XPT_DONE(sp, pq->ccb); |
553 pdu_free(sp->isc, pq); | 514 pdu_free(sp->isc, pq); |
554 } | 515 } |
555 else 556 xdebug("we lost it!"); 557 } 558 } 559 } 560 return error; 561} | 516 else 517 xdebug("we lost it!"); 518 } 519 } 520 } 521 return error; 522} |
562 | 523 |
563/* 564 | survives link breakdowns. 565 */ 566static void | 524/* 525 | survives link breakdowns. 526 */ 527static void |
567ism_proc(void *vp) | 528ism_out(void *vp) |
568{ 569 isc_session_t *sp = (isc_session_t *)vp; 570 int error; 571 572 debug_called(8); 573 574 sp->flags |= ISC_SM_RUNNING; 575 sdebug(3, "started sp->flags=%x", sp->flags); 576 do { 577 if((sp->flags & ISC_HOLD) == 0) { 578 error = proc_out(sp); 579 if(error) { 580 sdebug(3, "error=%d", error); 581 } 582 } | 529{ 530 isc_session_t *sp = (isc_session_t *)vp; 531 int error; 532 533 debug_called(8); 534 535 sp->flags |= ISC_SM_RUNNING; 536 sdebug(3, "started sp->flags=%x", sp->flags); 537 do { 538 if((sp->flags & ISC_HOLD) == 0) { 539 error = proc_out(sp); 540 if(error) { 541 sdebug(3, "error=%d", error); 542 } 543 } |
583 mtx_lock(&sp->io_mtx); | 544 mtx_lock(&sp->io_mtx); |
584 if((sp->flags & ISC_LINK_UP) == 0) { | 545 if((sp->flags & ISC_LINK_UP) == 0) { |
546 sdebug(3, "ISC_LINK_UP==0, sp->flags=%x ", sp->flags); 547 if(sp->soc != NULL) 548 sdebug(3, "so_state=%x", sp->soc->so_state); |
|
585 wakeup(&sp->soc); 586 } 587 588 if(!(sp->flags & ISC_OQNOTEMPTY)) { 589 sp->flags |= ISC_OWAITING; 590 if(msleep(&sp->flags, &sp->io_mtx, PRIBIO, "isc_proc", hz*30) == EWOULDBLOCK) { 591 if(sp->flags & ISC_CON_RUNNING) | 549 wakeup(&sp->soc); 550 } 551 552 if(!(sp->flags & ISC_OQNOTEMPTY)) { 553 sp->flags |= ISC_OWAITING; 554 if(msleep(&sp->flags, &sp->io_mtx, PRIBIO, "isc_proc", hz*30) == EWOULDBLOCK) { 555 if(sp->flags & ISC_CON_RUNNING) |
592 _nop_out(sp); | 556 _nop_out(sp); |
593 } 594 sp->flags &= ~ISC_OWAITING; 595 } 596 sp->flags &= ~ISC_OQNOTEMPTY; 597 mtx_unlock(&sp->io_mtx); 598 } while(sp->flags & ISC_SM_RUN); 599 600 sp->flags &= ~ISC_SM_RUNNING; 601 sdebug(3, "dropped ISC_SM_RUNNING"); 602 | 557 } 558 sp->flags &= ~ISC_OWAITING; 559 } 560 sp->flags &= ~ISC_OQNOTEMPTY; 561 mtx_unlock(&sp->io_mtx); 562 } while(sp->flags & ISC_SM_RUN); 563 564 sp->flags &= ~ISC_SM_RUNNING; 565 sdebug(3, "dropped ISC_SM_RUNNING"); 566 |
567 wakeup(&sp->soc); 568 wakeup(sp); // XXX: do we need this one? 569 |
|
603#if __FreeBSD_version >= 700000 604 destroy_dev(sp->dev); 605#endif | 570#if __FreeBSD_version >= 700000 571 destroy_dev(sp->dev); 572#endif |
606 wakeup(sp); | |
607 608 debug(3, "terminated sp=%p sp->sid=%d", sp, sp->sid); 609 | 573 574 debug(3, "terminated sp=%p sp->sid=%d", sp, sp->sid); 575 |
576#if __FreeBSD_version >= 800000 |
|
610 kproc_exit(0); | 577 kproc_exit(0); |
578#else 579 kthread_exit(0); 580#endif |
|
611} 612 613#if 0 614static int 615isc_dump_options(SYSCTL_HANDLER_ARGS) 616{ 617 int error; 618 isc_session_t *sp; --- 129 unchanged lines hidden (view full) --- 748 } 749 sdebug(2, "final n=%d", n); 750 sp->flags &= ~ISC_FFPHASE; 751 752 iscsi_cleanup(sp); 753 754 (void)i_pdu_flush(sp); 755 | 581} 582 583#if 0 584static int 585isc_dump_options(SYSCTL_HANDLER_ARGS) 586{ 587 int error; 588 isc_session_t *sp; --- 129 unchanged lines hidden (view full) --- 718 } 719 sdebug(2, "final n=%d", n); 720 sp->flags &= ~ISC_FFPHASE; 721 722 iscsi_cleanup(sp); 723 724 (void)i_pdu_flush(sp); 725 |
756 ic_lost_target(sp, sp->sid); | 726 ic_destroy(sp); |
757 | 727 |
758 mtx_lock(&sc->mtx); | 728 sx_xlock(&sc->unit_sx); 729 free_unr(sc->unit, sp->sid); 730 sx_xunlock(&sc->unit_sx); 731 732 mtx_lock(&sc->isc_mtx); |
759 TAILQ_REMOVE(&sc->isc_sess, sp, sp_link); 760 sc->nsess--; | 733 TAILQ_REMOVE(&sc->isc_sess, sp, sp_link); 734 sc->nsess--; |
761 mtx_unlock(&sc->mtx); | 735 mtx_unlock(&sc->isc_mtx); |
762 763#if __FreeBSD_version < 700000 764 destroy_dev(sp->dev); 765#endif 766 767 mtx_destroy(&sp->rsp_mtx); 768 mtx_destroy(&sp->rsv_mtx); 769 mtx_destroy(&sp->hld_mtx); 770 mtx_destroy(&sp->snd_mtx); 771 mtx_destroy(&sp->io_mtx); 772 773 i_freeopt(&sp->opt); | 736 737#if __FreeBSD_version < 700000 738 destroy_dev(sp->dev); 739#endif 740 741 mtx_destroy(&sp->rsp_mtx); 742 mtx_destroy(&sp->rsv_mtx); 743 mtx_destroy(&sp->hld_mtx); 744 mtx_destroy(&sp->snd_mtx); 745 mtx_destroy(&sp->io_mtx); 746 747 i_freeopt(&sp->opt); |
774 sc->sessions[sp->sid] = NULL; | |
775 776 if(sysctl_ctx_free(&sp->clist)) 777 xdebug("sysctl_ctx_free failed"); 778 779 free(sp, M_ISCSI); 780} 781 782int --- 4 unchanged lines hidden (view full) --- 787 | now is a good time to do some initialization 788 */ 789 TAILQ_INIT(&sp->rsp); 790 TAILQ_INIT(&sp->rsv); 791 TAILQ_INIT(&sp->csnd); 792 TAILQ_INIT(&sp->isnd); 793 TAILQ_INIT(&sp->wsnd); 794 TAILQ_INIT(&sp->hld); | 748 749 if(sysctl_ctx_free(&sp->clist)) 750 xdebug("sysctl_ctx_free failed"); 751 752 free(sp, M_ISCSI); 753} 754 755int --- 4 unchanged lines hidden (view full) --- 760 | now is a good time to do some initialization 761 */ 762 TAILQ_INIT(&sp->rsp); 763 TAILQ_INIT(&sp->rsv); 764 TAILQ_INIT(&sp->csnd); 765 TAILQ_INIT(&sp->isnd); 766 TAILQ_INIT(&sp->wsnd); 767 TAILQ_INIT(&sp->hld); |
795#if 1 | 768 |
796 mtx_init(&sp->rsv_mtx, "iscsi-rsv", NULL, MTX_DEF); 797 mtx_init(&sp->rsp_mtx, "iscsi-rsp", NULL, MTX_DEF); 798 mtx_init(&sp->snd_mtx, "iscsi-snd", NULL, MTX_DEF); 799 mtx_init(&sp->hld_mtx, "iscsi-hld", NULL, MTX_DEF); | 769 mtx_init(&sp->rsv_mtx, "iscsi-rsv", NULL, MTX_DEF); 770 mtx_init(&sp->rsp_mtx, "iscsi-rsp", NULL, MTX_DEF); 771 mtx_init(&sp->snd_mtx, "iscsi-snd", NULL, MTX_DEF); 772 mtx_init(&sp->hld_mtx, "iscsi-hld", NULL, MTX_DEF); |
800#else 801 mtx_init(&sp->rsv_mtx, "iscsi-rsv", NULL, MTX_SPIN); 802 mtx_init(&sp->rsp_mtx, "iscsi-rsp", NULL, MTX_SPIN); 803 mtx_init(&sp->snd_mtx, "iscsi-snd", NULL, MTX_SPIN); 804 mtx_init(&sp->hld_mtx, "iscsi-hld", NULL, MTX_SPIN); 805#endif | |
806 mtx_init(&sp->io_mtx, "iscsi-io", NULL, MTX_DEF); 807 808 isc_add_sysctls(sp); 809 810 sp->flags |= ISC_SM_RUN; 811 812 debug(4, "starting ism_proc: sp->sid=%d", sp->sid); | 773 mtx_init(&sp->io_mtx, "iscsi-io", NULL, MTX_DEF); 774 775 isc_add_sysctls(sp); 776 777 sp->flags |= ISC_SM_RUN; 778 779 debug(4, "starting ism_proc: sp->sid=%d", sp->sid); |
813 return kproc_create(ism_proc, sp, &sp->stp, 0, 0, "ism_%d", sp->sid); | 780 781#if __FreeBSD_version >= 800000 782 return kproc_create(ism_out, sp, &sp->stp, 0, 0, "isc_out %d", sp->sid); 783#else 784 return kthread_create(ism_out, sp, &sp->stp, 0, 0, "isc_out %d", sp->sid); 785#endif |
814} | 786} |