提交 6ec9d4d2 编写于 作者: M Max Gurtovoy 提交者: Roland Dreier

IB/iser: Fix possible SQ overflow

Fix a regression was introduced in commit 6df5a128 ("IB/iser:
Suppress scsi command send completions").

The sig_count was wrongly set to be static variable, thus it is
possible that we won't reach to (sig_count % ISER_SIGNAL_BATCH) == 0
condition (due to races) and the send queue will be overflowed.

Instead keep sig_count per connection. We don't need it to be atomic
as we are safe under the iscsi session frwd_lock taken by libiscsi on
the queuecommand path.

Fixes: 6df5a128 ("IB/iser: Suppress scsi command send completions")
Signed-off-by: NMax Gurtovoy <maxg@mellanox.com>
Signed-off-by: NSagi Grimberg <sagig@mellanox.com>
Signed-off-by: NOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: NRoland Dreier <roland@purestorage.com>
上级 93acb7bb
...@@ -437,6 +437,7 @@ struct fast_reg_descriptor { ...@@ -437,6 +437,7 @@ struct fast_reg_descriptor {
* @cma_id: rdma_cm connection maneger handle * @cma_id: rdma_cm connection maneger handle
* @qp: Connection Queue-pair * @qp: Connection Queue-pair
* @post_recv_buf_count: post receive counter * @post_recv_buf_count: post receive counter
* @sig_count: send work request signal count
* @rx_wr: receive work request for batch posts * @rx_wr: receive work request for batch posts
* @device: reference to iser device * @device: reference to iser device
* @comp: iser completion context * @comp: iser completion context
...@@ -457,6 +458,7 @@ struct ib_conn { ...@@ -457,6 +458,7 @@ struct ib_conn {
struct rdma_cm_id *cma_id; struct rdma_cm_id *cma_id;
struct ib_qp *qp; struct ib_qp *qp;
int post_recv_buf_count; int post_recv_buf_count;
u8 sig_count;
struct ib_recv_wr rx_wr[ISER_MIN_POSTED_RX]; struct ib_recv_wr rx_wr[ISER_MIN_POSTED_RX];
struct iser_device *device; struct iser_device *device;
struct iser_comp *comp; struct iser_comp *comp;
......
...@@ -369,7 +369,7 @@ static int iser_post_rx_bufs(struct iscsi_conn *conn, struct iscsi_hdr *req) ...@@ -369,7 +369,7 @@ static int iser_post_rx_bufs(struct iscsi_conn *conn, struct iscsi_hdr *req)
return 0; return 0;
} }
static inline bool iser_signal_comp(int sig_count) static inline bool iser_signal_comp(u8 sig_count)
{ {
return ((sig_count % ISER_SIGNAL_CMD_COUNT) == 0); return ((sig_count % ISER_SIGNAL_CMD_COUNT) == 0);
} }
...@@ -388,7 +388,7 @@ int iser_send_command(struct iscsi_conn *conn, ...@@ -388,7 +388,7 @@ int iser_send_command(struct iscsi_conn *conn,
struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)task->hdr; struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)task->hdr;
struct scsi_cmnd *sc = task->sc; struct scsi_cmnd *sc = task->sc;
struct iser_tx_desc *tx_desc = &iser_task->desc; struct iser_tx_desc *tx_desc = &iser_task->desc;
static unsigned sig_count; u8 sig_count = ++iser_conn->ib_conn.sig_count;
edtl = ntohl(hdr->data_length); edtl = ntohl(hdr->data_length);
...@@ -435,7 +435,7 @@ int iser_send_command(struct iscsi_conn *conn, ...@@ -435,7 +435,7 @@ int iser_send_command(struct iscsi_conn *conn,
iser_task->status = ISER_TASK_STATUS_STARTED; iser_task->status = ISER_TASK_STATUS_STARTED;
err = iser_post_send(&iser_conn->ib_conn, tx_desc, err = iser_post_send(&iser_conn->ib_conn, tx_desc,
iser_signal_comp(++sig_count)); iser_signal_comp(sig_count));
if (!err) if (!err)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册