diff options
author | Christoph Hellwig <hch@lst.de> | 2012-11-06 15:24:09 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-11-06 23:55:46 -0500 |
commit | de103c93aff0bed0ae984274e5dc8b95899badab (patch) | |
tree | 7db9bba755fa95772052e8d31285a38ba48f1a84 /drivers/infiniband/ulp/srpt/ib_srpt.c | |
parent | fecae40abb1ae9218bdbaa8b8e30bfb5ae43f522 (diff) |
target: pass sense_reason as a return value
Pass the sense reason as an explicit return value from the I/O submission
path instead of storing it in struct se_cmd and using negative return
values. This cleans up a lot of the code pathes, and with the sparse
annotations for the new sense_reason_t type allows for much better
error checking.
(nab: Convert spc_emulate_modesense + spc_emulate_modeselect to use
sense_reason_t with Roland's MODE SELECT changes)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/infiniband/ulp/srpt/ib_srpt.c')
-rw-r--r-- | drivers/infiniband/ulp/srpt/ib_srpt.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index cf23c46185b2..e6fafc62acae 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c | |||
@@ -1730,7 +1730,7 @@ static int srpt_handle_cmd(struct srpt_rdma_ch *ch, | |||
1730 | uint64_t unpacked_lun; | 1730 | uint64_t unpacked_lun; |
1731 | u64 data_len; | 1731 | u64 data_len; |
1732 | enum dma_data_direction dir; | 1732 | enum dma_data_direction dir; |
1733 | int ret; | 1733 | sense_reason_t ret; |
1734 | 1734 | ||
1735 | BUG_ON(!send_ioctx); | 1735 | BUG_ON(!send_ioctx); |
1736 | 1736 | ||
@@ -1755,12 +1755,10 @@ static int srpt_handle_cmd(struct srpt_rdma_ch *ch, | |||
1755 | break; | 1755 | break; |
1756 | } | 1756 | } |
1757 | 1757 | ||
1758 | ret = srpt_get_desc_tbl(send_ioctx, srp_cmd, &dir, &data_len); | 1758 | if (srpt_get_desc_tbl(send_ioctx, srp_cmd, &dir, &data_len)) { |
1759 | if (ret) { | ||
1760 | printk(KERN_ERR "0x%llx: parsing SRP descriptor table failed.\n", | 1759 | printk(KERN_ERR "0x%llx: parsing SRP descriptor table failed.\n", |
1761 | srp_cmd->tag); | 1760 | srp_cmd->tag); |
1762 | cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | 1761 | ret = TCM_INVALID_CDB_FIELD; |
1763 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; | ||
1764 | kref_put(&send_ioctx->kref, srpt_put_send_ioctx_kref); | 1762 | kref_put(&send_ioctx->kref, srpt_put_send_ioctx_kref); |
1765 | goto send_sense; | 1763 | goto send_sense; |
1766 | } | 1764 | } |
@@ -1769,26 +1767,26 @@ static int srpt_handle_cmd(struct srpt_rdma_ch *ch, | |||
1769 | cmd->data_direction = dir; | 1767 | cmd->data_direction = dir; |
1770 | unpacked_lun = srpt_unpack_lun((uint8_t *)&srp_cmd->lun, | 1768 | unpacked_lun = srpt_unpack_lun((uint8_t *)&srp_cmd->lun, |
1771 | sizeof(srp_cmd->lun)); | 1769 | sizeof(srp_cmd->lun)); |
1772 | if (transport_lookup_cmd_lun(cmd, unpacked_lun) < 0) { | 1770 | ret = transport_lookup_cmd_lun(cmd, unpacked_lun); |
1771 | if (ret) { | ||
1773 | kref_put(&send_ioctx->kref, srpt_put_send_ioctx_kref); | 1772 | kref_put(&send_ioctx->kref, srpt_put_send_ioctx_kref); |
1774 | goto send_sense; | 1773 | goto send_sense; |
1775 | } | 1774 | } |
1776 | ret = target_setup_cmd_from_cdb(cmd, srp_cmd->cdb); | 1775 | ret = target_setup_cmd_from_cdb(cmd, srp_cmd->cdb); |
1777 | if (ret < 0) { | 1776 | if (ret) { |
1778 | kref_put(&send_ioctx->kref, srpt_put_send_ioctx_kref); | 1777 | kref_put(&send_ioctx->kref, srpt_put_send_ioctx_kref); |
1779 | if (cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT) { | 1778 | if (ret == TCM_RESERVATION_CONFLICT) { |
1780 | srpt_queue_status(cmd); | 1779 | srpt_queue_status(cmd); |
1781 | return 0; | 1780 | return 0; |
1782 | } else | 1781 | } |
1783 | goto send_sense; | 1782 | goto send_sense; |
1784 | } | 1783 | } |
1785 | 1784 | ||
1786 | transport_handle_cdb_direct(cmd); | 1785 | transport_handle_cdb_direct(cmd); |
1787 | return 0; | 1786 | return 0; |
1788 | 1787 | ||
1789 | send_sense: | 1788 | send_sense: |
1790 | transport_send_check_condition_and_sense(cmd, cmd->scsi_sense_reason, | 1789 | transport_send_check_condition_and_sense(cmd, ret, 0); |
1791 | 0); | ||
1792 | return -1; | 1790 | return -1; |
1793 | } | 1791 | } |
1794 | 1792 | ||
@@ -1882,16 +1880,14 @@ static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch, | |||
1882 | send_ioctx->tag = srp_tsk->tag; | 1880 | send_ioctx->tag = srp_tsk->tag; |
1883 | tcm_tmr = srp_tmr_to_tcm(srp_tsk->tsk_mgmt_func); | 1881 | tcm_tmr = srp_tmr_to_tcm(srp_tsk->tsk_mgmt_func); |
1884 | if (tcm_tmr < 0) { | 1882 | if (tcm_tmr < 0) { |
1885 | send_ioctx->cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1886 | send_ioctx->cmd.se_tmr_req->response = | 1883 | send_ioctx->cmd.se_tmr_req->response = |
1887 | TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED; | 1884 | TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED; |
1888 | goto process_tmr; | 1885 | goto fail; |
1889 | } | 1886 | } |
1890 | res = core_tmr_alloc_req(cmd, NULL, tcm_tmr, GFP_KERNEL); | 1887 | res = core_tmr_alloc_req(cmd, NULL, tcm_tmr, GFP_KERNEL); |
1891 | if (res < 0) { | 1888 | if (res < 0) { |
1892 | send_ioctx->cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1893 | send_ioctx->cmd.se_tmr_req->response = TMR_FUNCTION_REJECTED; | 1889 | send_ioctx->cmd.se_tmr_req->response = TMR_FUNCTION_REJECTED; |
1894 | goto process_tmr; | 1890 | goto fail; |
1895 | } | 1891 | } |
1896 | 1892 | ||
1897 | unpacked_lun = srpt_unpack_lun((uint8_t *)&srp_tsk->lun, | 1893 | unpacked_lun = srpt_unpack_lun((uint8_t *)&srp_tsk->lun, |
@@ -1899,22 +1895,19 @@ static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch, | |||
1899 | res = transport_lookup_tmr_lun(&send_ioctx->cmd, unpacked_lun); | 1895 | res = transport_lookup_tmr_lun(&send_ioctx->cmd, unpacked_lun); |
1900 | if (res) { | 1896 | if (res) { |
1901 | pr_debug("rejecting TMR for LUN %lld\n", unpacked_lun); | 1897 | pr_debug("rejecting TMR for LUN %lld\n", unpacked_lun); |
1902 | send_ioctx->cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1903 | send_ioctx->cmd.se_tmr_req->response = TMR_LUN_DOES_NOT_EXIST; | 1898 | send_ioctx->cmd.se_tmr_req->response = TMR_LUN_DOES_NOT_EXIST; |
1904 | goto process_tmr; | 1899 | goto fail; |
1905 | } | 1900 | } |
1906 | 1901 | ||
1907 | if (srp_tsk->tsk_mgmt_func == SRP_TSK_ABORT_TASK) | 1902 | if (srp_tsk->tsk_mgmt_func == SRP_TSK_ABORT_TASK) |
1908 | srpt_rx_mgmt_fn_tag(send_ioctx, srp_tsk->task_tag); | 1903 | srpt_rx_mgmt_fn_tag(send_ioctx, srp_tsk->task_tag); |
1909 | 1904 | ||
1910 | process_tmr: | ||
1911 | kref_get(&send_ioctx->kref); | 1905 | kref_get(&send_ioctx->kref); |
1912 | if (!(send_ioctx->cmd.se_cmd_flags & SCF_SCSI_CDB_EXCEPTION)) | 1906 | transport_generic_handle_tmr(&send_ioctx->cmd); |
1913 | transport_generic_handle_tmr(&send_ioctx->cmd); | 1907 | return; |
1914 | else | 1908 | fail: |
1915 | transport_send_check_condition_and_sense(cmd, | 1909 | kref_get(&send_ioctx->kref); |
1916 | cmd->scsi_sense_reason, 0); | 1910 | transport_send_check_condition_and_sense(cmd, 0, 0); // XXX: |
1917 | |||
1918 | } | 1911 | } |
1919 | 1912 | ||
1920 | /** | 1913 | /** |