Skip to content

Commit 6ec9d4d

Browse files
Max Gurtovoyrolandd
authored andcommitted
IB/iser: Fix possible SQ overflow
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>
1 parent 93acb7b commit 6ec9d4d

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
@@ -437,6 +437,7 @@ struct fast_reg_descriptor {
437437
* @cma_id: rdma_cm connection maneger handle
438438
* @qp: Connection Queue-pair
439439
* @post_recv_buf_count: post receive counter
440+
* @sig_count: send work request signal count
440441
* @rx_wr: receive work request for batch posts
441442
* @device: reference to iser device
442443
* @comp: iser completion context
@@ -457,6 +458,7 @@ struct ib_conn {
457458
struct rdma_cm_id *cma_id;
458459
struct ib_qp *qp;
459460
int post_recv_buf_count;
461+
u8 sig_count;
460462
struct ib_recv_wr rx_wr[ISER_MIN_POSTED_RX];
461463
struct iser_device *device;
462464
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)