Commit 58bd0c69 authored by Andy Grover's avatar Andy Grover Committed by Nicholas Bellinger

target/iscsi: Fix op=disable + error handling cases in np_store_iser

Writing 0 when iser was not previously enabled, so succeed but do
nothing so that user-space code doesn't need a try: catch block
when ib_isert logic is not available.

Also, return actual error from add_network_portal using PTR_ERR
during op=enable failure.
Signed-off-by: default avatarAndy Grover <agrover@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent b5aff3d2
...@@ -155,7 +155,7 @@ static ssize_t lio_target_np_store_iser( ...@@ -155,7 +155,7 @@ static ssize_t lio_target_np_store_iser(
struct iscsi_tpg_np *tpg_np_iser = NULL; struct iscsi_tpg_np *tpg_np_iser = NULL;
char *endptr; char *endptr;
u32 op; u32 op;
int rc; int rc = 0;
op = simple_strtoul(page, &endptr, 0); op = simple_strtoul(page, &endptr, 0);
if ((op != 1) && (op != 0)) { if ((op != 1) && (op != 0)) {
...@@ -174,23 +174,26 @@ static ssize_t lio_target_np_store_iser( ...@@ -174,23 +174,26 @@ static ssize_t lio_target_np_store_iser(
return -EINVAL; return -EINVAL;
if (op) { if (op) {
int rc = request_module("ib_isert"); rc = request_module("ib_isert");
if (rc != 0) if (rc != 0) {
pr_warn("Unable to request_module for ib_isert\n"); pr_warn("Unable to request_module for ib_isert\n");
rc = 0;
}
tpg_np_iser = iscsit_tpg_add_network_portal(tpg, &np->np_sockaddr, tpg_np_iser = iscsit_tpg_add_network_portal(tpg, &np->np_sockaddr,
np->np_ip, tpg_np, ISCSI_INFINIBAND); np->np_ip, tpg_np, ISCSI_INFINIBAND);
if (!tpg_np_iser || IS_ERR(tpg_np_iser)) if (IS_ERR(tpg_np_iser)) {
rc = PTR_ERR(tpg_np_iser);
goto out; goto out;
}
} else { } else {
tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND); tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND);
if (!tpg_np_iser) if (tpg_np_iser) {
goto out;
rc = iscsit_tpg_del_network_portal(tpg, tpg_np_iser); rc = iscsit_tpg_del_network_portal(tpg, tpg_np_iser);
if (rc < 0) if (rc < 0)
goto out; goto out;
} }
}
printk("lio_target_np_store_iser() done, op: %d\n", op); printk("lio_target_np_store_iser() done, op: %d\n", op);
...@@ -198,7 +201,7 @@ static ssize_t lio_target_np_store_iser( ...@@ -198,7 +201,7 @@ static ssize_t lio_target_np_store_iser(
return count; return count;
out: out:
iscsit_put_tpg(tpg); iscsit_put_tpg(tpg);
return -EINVAL; return rc;
} }
TF_NP_BASE_ATTR(lio_target, iser, S_IRUGO | S_IWUSR); TF_NP_BASE_ATTR(lio_target, iser, S_IRUGO | S_IWUSR);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment