Skip to content

Commit f7146ce

Browse files
Max Gurtovoygregkh
authored andcommitted
IB/iser: Fix possible SQ overflow
commit 6ec9d4d upstream. Fix a regression was introduced in commit 6df5a12 ("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: 6df5a12 ("IB/iser: Suppress scsi command send completions") Signed-off-by: Max Gurtovoy <maxg@mellanox.com> Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1943a1a commit f7146ce

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎drivers/infiniband/ulp/iser/iscsi_iser.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ struct fast_reg_descriptor {
432432
* @cma_id: rdma_cm connection maneger handle
433433
* @qp: Connection Queue-pair
434434
* @post_recv_buf_count: post receive counter
435+
* @sig_count: send work request signal count
435436
* @rx_wr: receive work request for batch posts
436437
* @device: reference to iser device
437438
* @comp: iser completion context
@@ -452,6 +453,7 @@ struct ib_conn {
452453
struct rdma_cm_id *cma_id;
453454
struct ib_qp *qp;
454455
int post_recv_buf_count;
456+
u8 sig_count;
455457
struct ib_recv_wr rx_wr[ISER_MIN_POSTED_RX];
456458
struct iser_device *device;
457459
struct iser_comp *comp;

‎drivers/infiniband/ulp/iser/iser_initiator.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ static int iser_post_rx_bufs(struct iscsi_conn *conn, struct iscsi_hdr *req)
369369
return 0;
370370
}
371371

372-
static inline bool iser_signal_comp(int sig_count)
372+
static inline bool iser_signal_comp(u8 sig_count)
373373
{
374374
return ((sig_count % ISER_SIGNAL_CMD_COUNT) == 0);
375375
}
@@ -388,7 +388,7 @@ int iser_send_command(struct iscsi_conn *conn,
388388
struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)task->hdr;
389389
struct scsi_cmnd *sc = task->sc;
390390
struct iser_tx_desc *tx_desc = &iser_task->desc;
391-
static unsigned sig_count;
391+
u8 sig_count = ++iser_conn->ib_conn.sig_count;
392392

393393
edtl = ntohl(hdr->data_length);
394394

@@ -435,7 +435,7 @@ int iser_send_command(struct iscsi_conn *conn,
435435
iser_task->status = ISER_TASK_STATUS_STARTED;
436436

437437
err = iser_post_send(&iser_conn->ib_conn, tx_desc,
438-
iser_signal_comp(++sig_count));
438+
iser_signal_comp(sig_count));
439439
if (!err)
440440
return 0;
441441

0 commit comments

Comments
 (0)