aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2005-09-12 22:01:32 -0400
committerJames Bottomley <jejb@mulgrave.(none)>2005-09-20 13:30:58 -0400
commitaf973481f4a0902ad35726636c290f4794704948 (patch)
tree4322eec02304f7dbb4667c9243c38d1c1308f374 /drivers/scsi
parentb13941f635c3119eb02dc29b5248066f934f76be (diff)
[SCSI] iscsi: preemt fix and cleanup
From: zhenyu.z.wang@intel.com Delay the head digest update until xmit time, like data digest update. [To make things cleaner and avoid prempt bug] Signed-off-by: Alex Aizman <itn780@yahoo.com> Signed-off-by: Dmitry Yusupov <dmitry_yus@yahoo.com> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/iscsi_tcp.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 584e51024fd6..8751f6015559 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -129,14 +129,11 @@ iscsi_buf_left(struct iscsi_buf *ibuf)
129} 129}
130 130
131static inline void 131static inline void
132iscsi_buf_init_hdr(struct iscsi_conn *conn, struct iscsi_buf *ibuf, 132iscsi_hdr_digest(struct iscsi_conn *conn, struct iscsi_buf *buf,
133 char *vbuf, u8 *crc) 133 u8* crc)
134{ 134{
135 iscsi_buf_init_virt(ibuf, vbuf, sizeof(struct iscsi_hdr)); 135 crypto_digest_digest(conn->tx_tfm, &buf->sg, 1, crc);
136 if (conn->hdrdgst_en) { 136 buf->sg.length += sizeof(uint32_t);
137 crypto_digest_digest(conn->tx_tfm, &ibuf->sg, 1, crc);
138 ibuf->sg.length += sizeof(uint32_t);
139 }
140} 137}
141 138
142static void 139static void
@@ -427,8 +424,8 @@ iscsi_solicit_data_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
427 424
428 r2t->sent = 0; 425 r2t->sent = 0;
429 426
430 iscsi_buf_init_hdr(conn, &r2t->headbuf, (char*)hdr, 427 iscsi_buf_init_virt(&r2t->headbuf, (char*)hdr,
431 (u8 *)dtask->hdrext); 428 sizeof(struct iscsi_hdr));
432 429
433 r2t->dtask = dtask; 430 r2t->dtask = dtask;
434 431
@@ -1494,8 +1491,8 @@ iscsi_solicit_data_cont(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1494 } 1491 }
1495 conn->dataout_pdus_cnt++; 1492 conn->dataout_pdus_cnt++;
1496 1493
1497 iscsi_buf_init_hdr(conn, &r2t->headbuf, (char*)hdr, 1494 iscsi_buf_init_virt(&r2t->headbuf, (char*)hdr,
1498 (u8 *)dtask->hdrext); 1495 sizeof(struct iscsi_hdr));
1499 1496
1500 r2t->dtask = dtask; 1497 r2t->dtask = dtask;
1501 1498
@@ -1541,8 +1538,8 @@ iscsi_unsolicit_data_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1541 hdr->flags = ISCSI_FLAG_CMD_FINAL; 1538 hdr->flags = ISCSI_FLAG_CMD_FINAL;
1542 } 1539 }
1543 1540
1544 iscsi_buf_init_hdr(conn, &ctask->headbuf, (char*)hdr, 1541 iscsi_buf_init_virt(&ctask->headbuf, (char*)hdr,
1545 (u8 *)dtask->hdrext); 1542 sizeof(struct iscsi_hdr));
1546 1543
1547 list_add(&dtask->item, &ctask->dataqueue); 1544 list_add(&dtask->item, &ctask->dataqueue);
1548 1545
@@ -1662,8 +1659,8 @@ iscsi_cmd_init(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1662 zero_data(ctask->hdr.dlength); 1659 zero_data(ctask->hdr.dlength);
1663 } 1660 }
1664 1661
1665 iscsi_buf_init_hdr(conn, &ctask->headbuf, (char*)&ctask->hdr, 1662 iscsi_buf_init_virt(&ctask->headbuf, (char*)&ctask->hdr,
1666 (u8 *)ctask->hdrext); 1663 sizeof(struct iscsi_hdr));
1667 conn->scsicmd_pdus_cnt++; 1664 conn->scsicmd_pdus_cnt++;
1668} 1665}
1669 1666
@@ -1692,6 +1689,11 @@ iscsi_mtask_xmit(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask)
1692 mtask->xmstate &= ~XMSTATE_IMM_HDR; 1689 mtask->xmstate &= ~XMSTATE_IMM_HDR;
1693 if (mtask->data_count) 1690 if (mtask->data_count)
1694 mtask->xmstate |= XMSTATE_IMM_DATA; 1691 mtask->xmstate |= XMSTATE_IMM_DATA;
1692 if (conn->c_stage != ISCSI_CONN_INITIAL_STAGE &&
1693 conn->stop_stage != STOP_CONN_RECOVER &&
1694 conn->hdrdgst_en)
1695 iscsi_hdr_digest(conn, &mtask->headbuf,
1696 (u8*)mtask->hdrext);
1695 if (iscsi_sendhdr(conn, &mtask->headbuf, mtask->data_count)) { 1697 if (iscsi_sendhdr(conn, &mtask->headbuf, mtask->data_count)) {
1696 mtask->xmstate |= XMSTATE_IMM_HDR; 1698 mtask->xmstate |= XMSTATE_IMM_HDR;
1697 if (mtask->data_count) 1699 if (mtask->data_count)
@@ -1723,6 +1725,8 @@ static inline int
1723handle_xmstate_r_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) 1725handle_xmstate_r_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1724{ 1726{
1725 ctask->xmstate &= ~XMSTATE_R_HDR; 1727 ctask->xmstate &= ~XMSTATE_R_HDR;
1728 if (conn->hdrdgst_en)
1729 iscsi_hdr_digest(conn, &ctask->headbuf, (u8*)ctask->hdrext);
1726 if (!iscsi_sendhdr(conn, &ctask->headbuf, 0)) { 1730 if (!iscsi_sendhdr(conn, &ctask->headbuf, 0)) {
1727 BUG_ON(ctask->xmstate != XMSTATE_IDLE); 1731 BUG_ON(ctask->xmstate != XMSTATE_IDLE);
1728 return 0; /* wait for Data-In */ 1732 return 0; /* wait for Data-In */
@@ -1735,6 +1739,8 @@ static inline int
1735handle_xmstate_w_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) 1739handle_xmstate_w_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1736{ 1740{
1737 ctask->xmstate &= ~XMSTATE_W_HDR; 1741 ctask->xmstate &= ~XMSTATE_W_HDR;
1742 if (conn->hdrdgst_en)
1743 iscsi_hdr_digest(conn, &ctask->headbuf, (u8*)ctask->hdrext);
1738 if (iscsi_sendhdr(conn, &ctask->headbuf, ctask->imm_count)) { 1744 if (iscsi_sendhdr(conn, &ctask->headbuf, ctask->imm_count)) {
1739 ctask->xmstate |= XMSTATE_W_HDR; 1745 ctask->xmstate |= XMSTATE_W_HDR;
1740 return -EAGAIN; 1746 return -EAGAIN;
@@ -1813,7 +1819,9 @@ handle_xmstate_uns_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
1813 iscsi_unsolicit_data_init(conn, ctask); 1819 iscsi_unsolicit_data_init(conn, ctask);
1814 BUG_ON(!ctask->dtask); 1820 BUG_ON(!ctask->dtask);
1815 dtask = ctask->dtask; 1821 dtask = ctask->dtask;
1816 1822 if (conn->hdrdgst_en)
1823 iscsi_hdr_digest(conn, &ctask->headbuf,
1824 (u8*)dtask->hdrext);
1817 ctask->xmstate &= ~XMSTATE_UNS_INIT; 1825 ctask->xmstate &= ~XMSTATE_UNS_INIT;
1818 } 1826 }
1819 if (iscsi_sendhdr(conn, &ctask->headbuf, ctask->data_count)) { 1827 if (iscsi_sendhdr(conn, &ctask->headbuf, ctask->data_count)) {
@@ -2118,7 +2126,9 @@ unsolicit_head_again:
2118 sizeof(void*)); 2126 sizeof(void*));
2119solicit_head_again: 2127solicit_head_again:
2120 r2t = ctask->r2t; 2128 r2t = ctask->r2t;
2121 2129 if (conn->hdrdgst_en)
2130 iscsi_hdr_digest(conn, &r2t->headbuf,
2131 (u8*)r2t->dtask->hdrext);
2122 if (iscsi_sendhdr(conn, &r2t->headbuf, r2t->data_count)) { 2132 if (iscsi_sendhdr(conn, &r2t->headbuf, r2t->data_count)) {
2123 ctask->xmstate &= ~XMSTATE_SOL_DATA; 2133 ctask->xmstate &= ~XMSTATE_SOL_DATA;
2124 ctask->xmstate |= XMSTATE_SOL_HDR; 2134 ctask->xmstate |= XMSTATE_SOL_HDR;
@@ -2889,14 +2899,8 @@ iscsi_conn_send_generic(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
2889 2899
2890 memcpy(&mtask->hdr, hdr, sizeof(struct iscsi_hdr)); 2900 memcpy(&mtask->hdr, hdr, sizeof(struct iscsi_hdr));
2891 2901
2892 if (conn->c_stage == ISCSI_CONN_INITIAL_STAGE || 2902 iscsi_buf_init_virt(&mtask->headbuf, (char*)&mtask->hdr,
2893 conn->stop_stage == STOP_CONN_RECOVER)
2894 iscsi_buf_init_virt(&mtask->headbuf, (char*)&mtask->hdr,
2895 sizeof(struct iscsi_hdr)); 2903 sizeof(struct iscsi_hdr));
2896 else
2897 /* this will update header digest */
2898 iscsi_buf_init_hdr(conn, &mtask->headbuf, (char*)&mtask->hdr,
2899 (u8 *)mtask->hdrext);
2900 2904
2901 spin_unlock_bh(&session->lock); 2905 spin_unlock_bh(&session->lock);
2902 2906