libiscsi_tcp.c (e64c026dd09b73faf20707711402fc5ed55a8e70) | libiscsi_tcp.c (7acd72eb85f1c7a15e8b5eb554994949241737f1) |
---|---|
1/* 2 * iSCSI over TCP/IP Data-Path lib 3 * 4 * Copyright (C) 2004 Dmitry Yusupov 5 * Copyright (C) 2004 Alex Aizman 6 * Copyright (C) 2005 - 2006 Mike Christie 7 * Copyright (C) 2006 Red Hat, Inc. All rights reserved. 8 * maintained by open-iscsi@googlegroups.com --- 431 unchanged lines hidden (view full) --- 440 struct iscsi_tcp_task *tcp_task = task->dd_data; 441 struct iscsi_r2t_info *r2t; 442 443 /* nothing to do for mgmt */ 444 if (!task->sc) 445 return; 446 447 /* flush task's r2t queues */ | 1/* 2 * iSCSI over TCP/IP Data-Path lib 3 * 4 * Copyright (C) 2004 Dmitry Yusupov 5 * Copyright (C) 2004 Alex Aizman 6 * Copyright (C) 2005 - 2006 Mike Christie 7 * Copyright (C) 2006 Red Hat, Inc. All rights reserved. 8 * maintained by open-iscsi@googlegroups.com --- 431 unchanged lines hidden (view full) --- 440 struct iscsi_tcp_task *tcp_task = task->dd_data; 441 struct iscsi_r2t_info *r2t; 442 443 /* nothing to do for mgmt */ 444 if (!task->sc) 445 return; 446 447 /* flush task's r2t queues */ |
448 while (kfifo_get(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) { 449 kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t, | 448 while (kfifo_out(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) { 449 kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t, |
450 sizeof(void*)); 451 ISCSI_DBG_TCP(task->conn, "pending r2t dropped\n"); 452 } 453 454 r2t = tcp_task->r2t; 455 if (r2t != NULL) { | 450 sizeof(void*)); 451 ISCSI_DBG_TCP(task->conn, "pending r2t dropped\n"); 452 } 453 454 r2t = tcp_task->r2t; 455 if (r2t != NULL) { |
456 kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t, | 456 kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t, |
457 sizeof(void*)); 458 tcp_task->r2t = NULL; 459 } 460} 461EXPORT_SYMBOL_GPL(iscsi_tcp_cleanup_task); 462 463/** 464 * iscsi_tcp_data_in - SCSI Data-In Response processing --- 71 unchanged lines hidden (view full) --- 536 537 if (!task->sc || session->state != ISCSI_STATE_LOGGED_IN) { 538 iscsi_conn_printk(KERN_INFO, conn, 539 "dropping R2T itt %d in recovery.\n", 540 task->itt); 541 return 0; 542 } 543 | 457 sizeof(void*)); 458 tcp_task->r2t = NULL; 459 } 460} 461EXPORT_SYMBOL_GPL(iscsi_tcp_cleanup_task); 462 463/** 464 * iscsi_tcp_data_in - SCSI Data-In Response processing --- 71 unchanged lines hidden (view full) --- 536 537 if (!task->sc || session->state != ISCSI_STATE_LOGGED_IN) { 538 iscsi_conn_printk(KERN_INFO, conn, 539 "dropping R2T itt %d in recovery.\n", 540 task->itt); 541 return 0; 542 } 543 |
544 rc = kfifo_get(&tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*)); | 544 rc = kfifo_out(&tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*)); |
545 if (!rc) { 546 iscsi_conn_printk(KERN_ERR, conn, "Could not allocate R2T. " 547 "Target has sent more R2Ts than it " 548 "negotiated for or driver has has leaked.\n"); 549 return ISCSI_ERR_PROTO; 550 } 551 552 r2t->exp_statsn = rhdr->statsn; 553 r2t->data_length = be32_to_cpu(rhdr->data_length); 554 if (r2t->data_length == 0) { 555 iscsi_conn_printk(KERN_ERR, conn, 556 "invalid R2T with zero data len\n"); | 545 if (!rc) { 546 iscsi_conn_printk(KERN_ERR, conn, "Could not allocate R2T. " 547 "Target has sent more R2Ts than it " 548 "negotiated for or driver has has leaked.\n"); 549 return ISCSI_ERR_PROTO; 550 } 551 552 r2t->exp_statsn = rhdr->statsn; 553 r2t->data_length = be32_to_cpu(rhdr->data_length); 554 if (r2t->data_length == 0) { 555 iscsi_conn_printk(KERN_ERR, conn, 556 "invalid R2T with zero data len\n"); |
557 kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t, | 557 kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t, |
558 sizeof(void*)); 559 return ISCSI_ERR_DATALEN; 560 } 561 562 if (r2t->data_length > session->max_burst) 563 ISCSI_DBG_TCP(conn, "invalid R2T with data len %u and max " 564 "burst %u. Attempting to execute request.\n", 565 r2t->data_length, session->max_burst); 566 567 r2t->data_offset = be32_to_cpu(rhdr->data_offset); 568 if (r2t->data_offset + r2t->data_length > scsi_out(task->sc)->length) { 569 iscsi_conn_printk(KERN_ERR, conn, 570 "invalid R2T with data len %u at offset %u " 571 "and total length %d\n", r2t->data_length, 572 r2t->data_offset, scsi_out(task->sc)->length); | 558 sizeof(void*)); 559 return ISCSI_ERR_DATALEN; 560 } 561 562 if (r2t->data_length > session->max_burst) 563 ISCSI_DBG_TCP(conn, "invalid R2T with data len %u and max " 564 "burst %u. Attempting to execute request.\n", 565 r2t->data_length, session->max_burst); 566 567 r2t->data_offset = be32_to_cpu(rhdr->data_offset); 568 if (r2t->data_offset + r2t->data_length > scsi_out(task->sc)->length) { 569 iscsi_conn_printk(KERN_ERR, conn, 570 "invalid R2T with data len %u at offset %u " 571 "and total length %d\n", r2t->data_length, 572 r2t->data_offset, scsi_out(task->sc)->length); |
573 kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t, | 573 kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t, |
574 sizeof(void*)); 575 return ISCSI_ERR_DATALEN; 576 } 577 578 r2t->ttt = rhdr->ttt; /* no flip */ 579 r2t->datasn = 0; 580 r2t->sent = 0; 581 582 tcp_task->exp_datasn = r2tsn + 1; | 574 sizeof(void*)); 575 return ISCSI_ERR_DATALEN; 576 } 577 578 r2t->ttt = rhdr->ttt; /* no flip */ 579 r2t->datasn = 0; 580 r2t->sent = 0; 581 582 tcp_task->exp_datasn = r2tsn + 1; |
583 kfifo_put(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*)); | 583 kfifo_in(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*)); |
584 conn->r2t_pdus_cnt++; 585 586 iscsi_requeue_task(task); 587 return 0; 588} 589 590/* 591 * Handle incoming reply to DataIn command --- 385 unchanged lines hidden (view full) --- 977 else { 978 spin_lock_bh(&session->lock); 979 if (tcp_task->r2t) { 980 r2t = tcp_task->r2t; 981 /* Continue with this R2T? */ 982 if (r2t->data_length <= r2t->sent) { 983 ISCSI_DBG_TCP(task->conn, 984 " done with r2t %p\n", r2t); | 584 conn->r2t_pdus_cnt++; 585 586 iscsi_requeue_task(task); 587 return 0; 588} 589 590/* 591 * Handle incoming reply to DataIn command --- 385 unchanged lines hidden (view full) --- 977 else { 978 spin_lock_bh(&session->lock); 979 if (tcp_task->r2t) { 980 r2t = tcp_task->r2t; 981 /* Continue with this R2T? */ 982 if (r2t->data_length <= r2t->sent) { 983 ISCSI_DBG_TCP(task->conn, 984 " done with r2t %p\n", r2t); |
985 kfifo_put(&tcp_task->r2tpool.queue, | 985 kfifo_in(&tcp_task->r2tpool.queue, |
986 (void *)&tcp_task->r2t, 987 sizeof(void *)); 988 tcp_task->r2t = r2t = NULL; 989 } 990 } 991 992 if (r2t == NULL) { | 986 (void *)&tcp_task->r2t, 987 sizeof(void *)); 988 tcp_task->r2t = r2t = NULL; 989 } 990 } 991 992 if (r2t == NULL) { |
993 kfifo_get(&tcp_task->r2tqueue, | 993 kfifo_out(&tcp_task->r2tqueue, |
994 (void *)&tcp_task->r2t, sizeof(void *)); 995 r2t = tcp_task->r2t; 996 } 997 spin_unlock_bh(&session->lock); 998 } 999 1000 return r2t; 1001} --- 179 unchanged lines hidden --- | 994 (void *)&tcp_task->r2t, sizeof(void *)); 995 r2t = tcp_task->r2t; 996 } 997 spin_unlock_bh(&session->lock); 998 } 999 1000 return r2t; 1001} --- 179 unchanged lines hidden --- |