Target/iser: Move check signature status to a function
Remove code duplication from RDMA_READ and RDMA_WRITE completions that do basically the same check. Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
897bb2c916
commit
96b7973e1c
|
@ -1657,26 +1657,20 @@ isert_completion_put(struct iser_tx_desc *tx_desc, struct isert_cmd *isert_cmd,
|
|||
isert_put_cmd(isert_cmd);
|
||||
}
|
||||
|
||||
static void
|
||||
isert_completion_rdma_write(struct iser_tx_desc *tx_desc,
|
||||
struct isert_cmd *isert_cmd)
|
||||
static int
|
||||
isert_check_pi_status(struct se_cmd *se_cmd, struct ib_mr *sig_mr)
|
||||
{
|
||||
struct isert_rdma_wr *wr = &isert_cmd->rdma_wr;
|
||||
struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
|
||||
struct se_cmd *se_cmd = &cmd->se_cmd;
|
||||
struct isert_conn *isert_conn = isert_cmd->conn;
|
||||
struct isert_device *device = isert_conn->conn_device;
|
||||
struct ib_mr_status mr_status;
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
if (wr->fr_desc && wr->fr_desc->ind & ISERT_PROTECTED) {
|
||||
ret = ib_check_mr_status(wr->fr_desc->pi_ctx->sig_mr,
|
||||
IB_MR_CHECK_SIG_STATUS, &mr_status);
|
||||
ret = ib_check_mr_status(sig_mr, IB_MR_CHECK_SIG_STATUS, &mr_status);
|
||||
if (ret) {
|
||||
pr_err("ib_check_mr_status failed, ret %d\n", ret);
|
||||
goto fail_mr_status;
|
||||
}
|
||||
|
||||
if (mr_status.fail_status & IB_MR_CHECK_SIG_STATUS) {
|
||||
u64 sec_offset_err;
|
||||
u32 block_size = se_cmd->se_dev->dev_attrib.block_size + 8;
|
||||
|
||||
switch (mr_status.sig_err.err_type) {
|
||||
|
@ -1690,8 +1684,9 @@ isert_completion_rdma_write(struct iser_tx_desc *tx_desc,
|
|||
se_cmd->pi_err = TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED;
|
||||
break;
|
||||
}
|
||||
se_cmd->bad_sector = mr_status.sig_err.sig_err_offset;
|
||||
do_div(se_cmd->bad_sector, block_size);
|
||||
sec_offset_err = mr_status.sig_err.sig_err_offset;
|
||||
do_div(sec_offset_err, block_size);
|
||||
se_cmd->bad_sector = sec_offset_err + se_cmd->t_task_lba;
|
||||
|
||||
pr_err("isert: PI error found type %d at sector 0x%llx "
|
||||
"expected 0x%x vs actual 0x%x\n",
|
||||
|
@ -1701,9 +1696,28 @@ isert_completion_rdma_write(struct iser_tx_desc *tx_desc,
|
|||
mr_status.sig_err.actual);
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
|
||||
fail_mr_status:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
isert_completion_rdma_write(struct iser_tx_desc *tx_desc,
|
||||
struct isert_cmd *isert_cmd)
|
||||
{
|
||||
struct isert_rdma_wr *wr = &isert_cmd->rdma_wr;
|
||||
struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;
|
||||
struct se_cmd *se_cmd = &cmd->se_cmd;
|
||||
struct isert_conn *isert_conn = isert_cmd->conn;
|
||||
struct isert_device *device = isert_conn->conn_device;
|
||||
int ret = 0;
|
||||
|
||||
if (wr->fr_desc && wr->fr_desc->ind & ISERT_PROTECTED) {
|
||||
ret = isert_check_pi_status(se_cmd,
|
||||
wr->fr_desc->pi_ctx->sig_mr);
|
||||
wr->fr_desc->ind &= ~ISERT_PROTECTED;
|
||||
}
|
||||
|
||||
device->unreg_rdma_mem(isert_cmd, isert_conn);
|
||||
wr->send_wr_num = 0;
|
||||
if (ret)
|
||||
|
@ -1722,43 +1736,14 @@ isert_completion_rdma_read(struct iser_tx_desc *tx_desc,
|
|||
struct se_cmd *se_cmd = &cmd->se_cmd;
|
||||
struct isert_conn *isert_conn = isert_cmd->conn;
|
||||
struct isert_device *device = isert_conn->conn_device;
|
||||
struct ib_mr_status mr_status;
|
||||
int ret;
|
||||
|
||||
if (wr->fr_desc && wr->fr_desc->ind & ISERT_PROTECTED) {
|
||||
ret = ib_check_mr_status(wr->fr_desc->pi_ctx->sig_mr,
|
||||
IB_MR_CHECK_SIG_STATUS, &mr_status);
|
||||
if (ret) {
|
||||
pr_err("ib_check_mr_status failed, ret %d\n", ret);
|
||||
goto fail_mr_status;
|
||||
}
|
||||
if (mr_status.fail_status & IB_MR_CHECK_SIG_STATUS) {
|
||||
u32 block_size = se_cmd->se_dev->dev_attrib.block_size + 8;
|
||||
|
||||
switch (mr_status.sig_err.err_type) {
|
||||
case IB_SIG_BAD_GUARD:
|
||||
se_cmd->pi_err = TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED;
|
||||
break;
|
||||
case IB_SIG_BAD_REFTAG:
|
||||
se_cmd->pi_err = TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED;
|
||||
break;
|
||||
case IB_SIG_BAD_APPTAG:
|
||||
se_cmd->pi_err = TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED;
|
||||
break;
|
||||
}
|
||||
se_cmd->bad_sector = mr_status.sig_err.sig_err_offset;
|
||||
do_div(se_cmd->bad_sector, block_size);
|
||||
|
||||
pr_err("isert: PI error found type %d at sector 0x%llx "
|
||||
"expected 0x%x vs actual 0x%x\n",
|
||||
mr_status.sig_err.err_type,
|
||||
(unsigned long long)se_cmd->bad_sector,
|
||||
mr_status.sig_err.expected,
|
||||
mr_status.sig_err.actual);
|
||||
}
|
||||
ret = isert_check_pi_status(se_cmd,
|
||||
wr->fr_desc->pi_ctx->sig_mr);
|
||||
wr->fr_desc->ind &= ~ISERT_PROTECTED;
|
||||
}
|
||||
|
||||
fail_mr_status:
|
||||
iscsit_stop_dataout_timer(cmd);
|
||||
device->unreg_rdma_mem(isert_cmd, isert_conn);
|
||||
cmd->write_data_done = wr->data.len;
|
||||
|
|
Loading…
Reference in New Issue