diff options
| -rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.c | 38 | ||||
| -rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.h | 2 | ||||
| -rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 4 | ||||
| -rw-r--r-- | drivers/target/iscsi/iscsi_target_core.h | 1 | ||||
| -rw-r--r-- | drivers/target/iscsi/iscsi_target_login.c | 28 | ||||
| -rw-r--r-- | drivers/target/iscsi/iscsi_target_tpg.c | 1 | ||||
| -rw-r--r-- | drivers/target/target_core_device.c | 12 | ||||
| -rw-r--r-- | drivers/target/target_core_transport.c | 2 | ||||
| -rw-r--r-- | drivers/target/tcm_fc/tfc_cmd.c | 8 |
9 files changed, 63 insertions, 33 deletions
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index c98fdb185931..a1710465faaf 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <target/target_core_base.h> | 28 | #include <target/target_core_base.h> |
| 29 | #include <target/target_core_fabric.h> | 29 | #include <target/target_core_fabric.h> |
| 30 | #include <target/iscsi/iscsi_transport.h> | 30 | #include <target/iscsi/iscsi_transport.h> |
| 31 | #include <linux/semaphore.h> | ||
| 31 | 32 | ||
| 32 | #include "isert_proto.h" | 33 | #include "isert_proto.h" |
| 33 | #include "ib_isert.h" | 34 | #include "ib_isert.h" |
| @@ -561,7 +562,15 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) | |||
| 561 | struct isert_device *device; | 562 | struct isert_device *device; |
| 562 | struct ib_device *ib_dev = cma_id->device; | 563 | struct ib_device *ib_dev = cma_id->device; |
| 563 | int ret = 0; | 564 | int ret = 0; |
| 564 | u8 pi_support = np->tpg_np->tpg->tpg_attrib.t10_pi; | 565 | u8 pi_support; |
| 566 | |||
| 567 | spin_lock_bh(&np->np_thread_lock); | ||
| 568 | if (!np->enabled) { | ||
| 569 | spin_unlock_bh(&np->np_thread_lock); | ||
| 570 | pr_debug("iscsi_np is not enabled, reject connect request\n"); | ||
| 571 | return rdma_reject(cma_id, NULL, 0); | ||
| 572 | } | ||
| 573 | spin_unlock_bh(&np->np_thread_lock); | ||
| 565 | 574 | ||
| 566 | pr_debug("Entering isert_connect_request cma_id: %p, context: %p\n", | 575 | pr_debug("Entering isert_connect_request cma_id: %p, context: %p\n", |
| 567 | cma_id, cma_id->context); | 576 | cma_id, cma_id->context); |
| @@ -652,6 +661,7 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) | |||
| 652 | goto out_mr; | 661 | goto out_mr; |
| 653 | } | 662 | } |
| 654 | 663 | ||
| 664 | pi_support = np->tpg_np->tpg->tpg_attrib.t10_pi; | ||
| 655 | if (pi_support && !device->pi_capable) { | 665 | if (pi_support && !device->pi_capable) { |
| 656 | pr_err("Protection information requested but not supported\n"); | 666 | pr_err("Protection information requested but not supported\n"); |
| 657 | ret = -EINVAL; | 667 | ret = -EINVAL; |
| @@ -663,11 +673,11 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) | |||
| 663 | goto out_conn_dev; | 673 | goto out_conn_dev; |
| 664 | 674 | ||
| 665 | mutex_lock(&isert_np->np_accept_mutex); | 675 | mutex_lock(&isert_np->np_accept_mutex); |
| 666 | list_add_tail(&isert_np->np_accept_list, &isert_conn->conn_accept_node); | 676 | list_add_tail(&isert_conn->conn_accept_node, &isert_np->np_accept_list); |
| 667 | mutex_unlock(&isert_np->np_accept_mutex); | 677 | mutex_unlock(&isert_np->np_accept_mutex); |
| 668 | 678 | ||
| 669 | pr_debug("isert_connect_request() waking up np_accept_wq: %p\n", np); | 679 | pr_debug("isert_connect_request() up np_sem np: %p\n", np); |
| 670 | wake_up(&isert_np->np_accept_wq); | 680 | up(&isert_np->np_sem); |
| 671 | return 0; | 681 | return 0; |
| 672 | 682 | ||
| 673 | out_conn_dev: | 683 | out_conn_dev: |
| @@ -2999,7 +3009,7 @@ isert_setup_np(struct iscsi_np *np, | |||
| 2999 | pr_err("Unable to allocate struct isert_np\n"); | 3009 | pr_err("Unable to allocate struct isert_np\n"); |
| 3000 | return -ENOMEM; | 3010 | return -ENOMEM; |
| 3001 | } | 3011 | } |
| 3002 | init_waitqueue_head(&isert_np->np_accept_wq); | 3012 | sema_init(&isert_np->np_sem, 0); |
| 3003 | mutex_init(&isert_np->np_accept_mutex); | 3013 | mutex_init(&isert_np->np_accept_mutex); |
| 3004 | INIT_LIST_HEAD(&isert_np->np_accept_list); | 3014 | INIT_LIST_HEAD(&isert_np->np_accept_list); |
| 3005 | init_completion(&isert_np->np_login_comp); | 3015 | init_completion(&isert_np->np_login_comp); |
| @@ -3048,18 +3058,6 @@ out: | |||
| 3048 | } | 3058 | } |
| 3049 | 3059 | ||
| 3050 | static int | 3060 | static int |
| 3051 | isert_check_accept_queue(struct isert_np *isert_np) | ||
| 3052 | { | ||
| 3053 | int empty; | ||
| 3054 | |||
| 3055 | mutex_lock(&isert_np->np_accept_mutex); | ||
| 3056 | empty = list_empty(&isert_np->np_accept_list); | ||
| 3057 | mutex_unlock(&isert_np->np_accept_mutex); | ||
| 3058 | |||
| 3059 | return empty; | ||
| 3060 | } | ||
| 3061 | |||
| 3062 | static int | ||
| 3063 | isert_rdma_accept(struct isert_conn *isert_conn) | 3061 | isert_rdma_accept(struct isert_conn *isert_conn) |
| 3064 | { | 3062 | { |
| 3065 | struct rdma_cm_id *cm_id = isert_conn->conn_cm_id; | 3063 | struct rdma_cm_id *cm_id = isert_conn->conn_cm_id; |
| @@ -3151,16 +3149,14 @@ isert_accept_np(struct iscsi_np *np, struct iscsi_conn *conn) | |||
| 3151 | int max_accept = 0, ret; | 3149 | int max_accept = 0, ret; |
| 3152 | 3150 | ||
| 3153 | accept_wait: | 3151 | accept_wait: |
| 3154 | ret = wait_event_interruptible(isert_np->np_accept_wq, | 3152 | ret = down_interruptible(&isert_np->np_sem); |
| 3155 | !isert_check_accept_queue(isert_np) || | ||
| 3156 | np->np_thread_state == ISCSI_NP_THREAD_RESET); | ||
| 3157 | if (max_accept > 5) | 3153 | if (max_accept > 5) |
| 3158 | return -ENODEV; | 3154 | return -ENODEV; |
| 3159 | 3155 | ||
| 3160 | spin_lock_bh(&np->np_thread_lock); | 3156 | spin_lock_bh(&np->np_thread_lock); |
| 3161 | if (np->np_thread_state == ISCSI_NP_THREAD_RESET) { | 3157 | if (np->np_thread_state == ISCSI_NP_THREAD_RESET) { |
| 3162 | spin_unlock_bh(&np->np_thread_lock); | 3158 | spin_unlock_bh(&np->np_thread_lock); |
| 3163 | pr_err("ISCSI_NP_THREAD_RESET for isert_accept_np\n"); | 3159 | pr_debug("ISCSI_NP_THREAD_RESET for isert_accept_np\n"); |
| 3164 | return -ENODEV; | 3160 | return -ENODEV; |
| 3165 | } | 3161 | } |
| 3166 | spin_unlock_bh(&np->np_thread_lock); | 3162 | spin_unlock_bh(&np->np_thread_lock); |
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h index 4c072ae34c01..da6612e68000 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h | |||
| @@ -182,7 +182,7 @@ struct isert_device { | |||
| 182 | }; | 182 | }; |
| 183 | 183 | ||
| 184 | struct isert_np { | 184 | struct isert_np { |
| 185 | wait_queue_head_t np_accept_wq; | 185 | struct semaphore np_sem; |
| 186 | struct rdma_cm_id *np_cm_id; | 186 | struct rdma_cm_id *np_cm_id; |
| 187 | struct mutex np_accept_mutex; | 187 | struct mutex np_accept_mutex; |
| 188 | struct list_head np_accept_list; | 188 | struct list_head np_accept_list; |
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 78cab13bbb1b..46588c85d39b 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
| @@ -1593,7 +1593,9 @@ int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, | |||
| 1593 | * Initiator is expecting a NopIN ping reply.. | 1593 | * Initiator is expecting a NopIN ping reply.. |
| 1594 | */ | 1594 | */ |
| 1595 | if (hdr->itt != RESERVED_ITT) { | 1595 | if (hdr->itt != RESERVED_ITT) { |
| 1596 | BUG_ON(!cmd); | 1596 | if (!cmd) |
| 1597 | return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, | ||
| 1598 | (unsigned char *)hdr); | ||
| 1597 | 1599 | ||
| 1598 | spin_lock_bh(&conn->cmd_lock); | 1600 | spin_lock_bh(&conn->cmd_lock); |
| 1599 | list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); | 1601 | list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); |
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h index 6960f22909ae..302eb3b78715 100644 --- a/drivers/target/iscsi/iscsi_target_core.h +++ b/drivers/target/iscsi/iscsi_target_core.h | |||
| @@ -775,6 +775,7 @@ struct iscsi_np { | |||
| 775 | int np_ip_proto; | 775 | int np_ip_proto; |
| 776 | int np_sock_type; | 776 | int np_sock_type; |
| 777 | enum np_thread_state_table np_thread_state; | 777 | enum np_thread_state_table np_thread_state; |
| 778 | bool enabled; | ||
| 778 | enum iscsi_timer_flags_table np_login_timer_flags; | 779 | enum iscsi_timer_flags_table np_login_timer_flags; |
| 779 | u32 np_exports; | 780 | u32 np_exports; |
| 780 | enum np_flags_table np_flags; | 781 | enum np_flags_table np_flags; |
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 8739b98f6f93..ca31fa1b8a4b 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c | |||
| @@ -436,7 +436,7 @@ static int iscsi_login_zero_tsih_s2( | |||
| 436 | } | 436 | } |
| 437 | off = mrdsl % PAGE_SIZE; | 437 | off = mrdsl % PAGE_SIZE; |
| 438 | if (!off) | 438 | if (!off) |
| 439 | return 0; | 439 | goto check_prot; |
| 440 | 440 | ||
| 441 | if (mrdsl < PAGE_SIZE) | 441 | if (mrdsl < PAGE_SIZE) |
| 442 | mrdsl = PAGE_SIZE; | 442 | mrdsl = PAGE_SIZE; |
| @@ -452,6 +452,31 @@ static int iscsi_login_zero_tsih_s2( | |||
| 452 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | 452 | ISCSI_LOGIN_STATUS_NO_RESOURCES); |
| 453 | return -1; | 453 | return -1; |
| 454 | } | 454 | } |
| 455 | /* | ||
| 456 | * ISER currently requires that ImmediateData + Unsolicited | ||
| 457 | * Data be disabled when protection / signature MRs are enabled. | ||
| 458 | */ | ||
| 459 | check_prot: | ||
| 460 | if (sess->se_sess->sup_prot_ops & | ||
| 461 | (TARGET_PROT_DOUT_STRIP | TARGET_PROT_DOUT_PASS | | ||
| 462 | TARGET_PROT_DOUT_INSERT)) { | ||
| 463 | |||
| 464 | sprintf(buf, "ImmediateData=No"); | ||
| 465 | if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { | ||
| 466 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, | ||
| 467 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | ||
| 468 | return -1; | ||
| 469 | } | ||
| 470 | |||
| 471 | sprintf(buf, "InitialR2T=Yes"); | ||
| 472 | if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { | ||
| 473 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, | ||
| 474 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | ||
| 475 | return -1; | ||
| 476 | } | ||
| 477 | pr_debug("Forcing ImmediateData=No + InitialR2T=Yes for" | ||
| 478 | " T10-PI enabled ISER session\n"); | ||
| 479 | } | ||
| 455 | } | 480 | } |
| 456 | 481 | ||
| 457 | return 0; | 482 | return 0; |
| @@ -984,6 +1009,7 @@ int iscsi_target_setup_login_socket( | |||
| 984 | } | 1009 | } |
| 985 | 1010 | ||
| 986 | np->np_transport = t; | 1011 | np->np_transport = t; |
| 1012 | np->enabled = true; | ||
| 987 | return 0; | 1013 | return 0; |
| 988 | } | 1014 | } |
| 989 | 1015 | ||
diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c index eb96b20dc09e..ca1811858afd 100644 --- a/drivers/target/iscsi/iscsi_target_tpg.c +++ b/drivers/target/iscsi/iscsi_target_tpg.c | |||
| @@ -184,6 +184,7 @@ static void iscsit_clear_tpg_np_login_thread( | |||
| 184 | return; | 184 | return; |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | tpg_np->tpg_np->enabled = false; | ||
| 187 | iscsit_reset_np_thread(tpg_np->tpg_np, tpg_np, tpg, shutdown); | 188 | iscsit_reset_np_thread(tpg_np->tpg_np, tpg_np, tpg, shutdown); |
| 188 | } | 189 | } |
| 189 | 190 | ||
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 65001e133670..26416c15d65c 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
| @@ -798,10 +798,10 @@ int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) | |||
| 798 | pr_err("emulate_write_cache not supported for pSCSI\n"); | 798 | pr_err("emulate_write_cache not supported for pSCSI\n"); |
| 799 | return -EINVAL; | 799 | return -EINVAL; |
| 800 | } | 800 | } |
| 801 | if (dev->transport->get_write_cache) { | 801 | if (flag && |
| 802 | pr_warn("emulate_write_cache cannot be changed when underlying" | 802 | dev->transport->get_write_cache) { |
| 803 | " HW reports WriteCacheEnabled, ignoring request\n"); | 803 | pr_err("emulate_write_cache not supported for this device\n"); |
| 804 | return 0; | 804 | return -EINVAL; |
| 805 | } | 805 | } |
| 806 | 806 | ||
| 807 | dev->dev_attrib.emulate_write_cache = flag; | 807 | dev->dev_attrib.emulate_write_cache = flag; |
| @@ -936,6 +936,10 @@ int se_dev_set_pi_prot_type(struct se_device *dev, int flag) | |||
| 936 | return 0; | 936 | return 0; |
| 937 | } | 937 | } |
| 938 | if (!dev->transport->init_prot || !dev->transport->free_prot) { | 938 | if (!dev->transport->init_prot || !dev->transport->free_prot) { |
| 939 | /* 0 is only allowed value for non-supporting backends */ | ||
| 940 | if (flag == 0) | ||
| 941 | return 0; | ||
| 942 | |||
| 939 | pr_err("DIF protection not supported by backend: %s\n", | 943 | pr_err("DIF protection not supported by backend: %s\n", |
| 940 | dev->transport->name); | 944 | dev->transport->name); |
| 941 | return -ENOSYS; | 945 | return -ENOSYS; |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index d4b98690a736..789aa9eb0a1e 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
| @@ -1113,6 +1113,7 @@ void transport_init_se_cmd( | |||
| 1113 | init_completion(&cmd->cmd_wait_comp); | 1113 | init_completion(&cmd->cmd_wait_comp); |
| 1114 | init_completion(&cmd->task_stop_comp); | 1114 | init_completion(&cmd->task_stop_comp); |
| 1115 | spin_lock_init(&cmd->t_state_lock); | 1115 | spin_lock_init(&cmd->t_state_lock); |
| 1116 | kref_init(&cmd->cmd_kref); | ||
| 1116 | cmd->transport_state = CMD_T_DEV_ACTIVE; | 1117 | cmd->transport_state = CMD_T_DEV_ACTIVE; |
| 1117 | 1118 | ||
| 1118 | cmd->se_tfo = tfo; | 1119 | cmd->se_tfo = tfo; |
| @@ -2357,7 +2358,6 @@ int target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd, | |||
| 2357 | unsigned long flags; | 2358 | unsigned long flags; |
| 2358 | int ret = 0; | 2359 | int ret = 0; |
| 2359 | 2360 | ||
| 2360 | kref_init(&se_cmd->cmd_kref); | ||
| 2361 | /* | 2361 | /* |
| 2362 | * Add a second kref if the fabric caller is expecting to handle | 2362 | * Add a second kref if the fabric caller is expecting to handle |
| 2363 | * fabric acknowledgement that requires two target_put_sess_cmd() | 2363 | * fabric acknowledgement that requires two target_put_sess_cmd() |
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 01cf37f212c3..f5fd515b2bee 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c | |||
| @@ -90,18 +90,18 @@ static void ft_free_cmd(struct ft_cmd *cmd) | |||
| 90 | { | 90 | { |
| 91 | struct fc_frame *fp; | 91 | struct fc_frame *fp; |
| 92 | struct fc_lport *lport; | 92 | struct fc_lport *lport; |
| 93 | struct se_session *se_sess; | 93 | struct ft_sess *sess; |
| 94 | 94 | ||
| 95 | if (!cmd) | 95 | if (!cmd) |
| 96 | return; | 96 | return; |
| 97 | se_sess = cmd->sess->se_sess; | 97 | sess = cmd->sess; |
| 98 | fp = cmd->req_frame; | 98 | fp = cmd->req_frame; |
| 99 | lport = fr_dev(fp); | 99 | lport = fr_dev(fp); |
| 100 | if (fr_seq(fp)) | 100 | if (fr_seq(fp)) |
| 101 | lport->tt.seq_release(fr_seq(fp)); | 101 | lport->tt.seq_release(fr_seq(fp)); |
| 102 | fc_frame_free(fp); | 102 | fc_frame_free(fp); |
| 103 | percpu_ida_free(&se_sess->sess_tag_pool, cmd->se_cmd.map_tag); | 103 | percpu_ida_free(&sess->se_sess->sess_tag_pool, cmd->se_cmd.map_tag); |
| 104 | ft_sess_put(cmd->sess); /* undo get from lookup at recv */ | 104 | ft_sess_put(sess); /* undo get from lookup at recv */ |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | void ft_release_cmd(struct se_cmd *se_cmd) | 107 | void ft_release_cmd(struct se_cmd *se_cmd) |
