lib/iscsi: Add wait parameter to iscsi_create_portal_group RPC

Add an new optional parameter wait to the RPC, iscsi_create_portal_group
not to listen on portals until it is started explicitly.

Fixes the issue #1676.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ic217f1ccceb618e70fdb2aff3f710d262a8a9bdb
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5091
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-11-12 13:42:35 +09:00 committed by Tomasz Zawadzki
parent 024d286527
commit d4ad1f9cc1
6 changed files with 22 additions and 4 deletions

View File

@ -16,6 +16,14 @@ be notified of any discovery log changes.
A new API `spdk_jsonrpc_send_bool_response` was added to allow sending response for
writing json bool results into one function.
### rpc
An new optional parameter `wait` was added to the RPC `iscsi_create_portal_group`,
and an new RPC `iscsi_start_portal_group` was added. They will be used not to start
listening on portals for a portal group until all associated target nodes are created
at startup, otherwise some iSCSI initiators may fail to re-login when SPDK iSCSI
target application restarts.
## v20.10:
### accel

View File

@ -4433,6 +4433,7 @@ Name | Optional | Type | Description
tag | Required | number | Portal group tag
portals | Required | array | Not empty array of portals
private | Optional | boolean | When true, portals in this group are not returned by a discovery session. Used for login redirection. (default: `false`)
wait | Optional | boolean | When true, do not listen on portals until it is started explicitly. (default: `false`)
Portal object

View File

@ -706,6 +706,7 @@ struct rpc_portal_group {
int32_t tag;
struct rpc_portal_list portal_list;
bool is_private;
bool wait;
};
static void
@ -760,6 +761,7 @@ static const struct spdk_json_object_decoder rpc_portal_group_decoders[] = {
{"tag", offsetof(struct rpc_portal_group, tag), spdk_json_decode_int32},
{"portals", offsetof(struct rpc_portal_group, portal_list), decode_rpc_portal_list},
{"private", offsetof(struct rpc_portal_group, is_private), spdk_json_decode_bool, true},
{"wait", offsetof(struct rpc_portal_group, wait), spdk_json_decode_bool, true},
};
static void
@ -794,7 +796,7 @@ rpc_iscsi_create_portal_group(struct spdk_jsonrpc_request *request,
iscsi_portal_grp_add_portal(pg, portal);
}
rc = iscsi_portal_grp_open(pg, false);
rc = iscsi_portal_grp_open(pg, req.wait);
if (rc != 0) {
SPDK_ERRLOG("portal_grp_open failed\n");
goto out;

View File

@ -1183,7 +1183,8 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
args.client,
portals=portals,
tag=args.tag,
private=args.private)
private=args.private,
wait=args.wait)
p = subparsers.add_parser('iscsi_create_portal_group', aliases=['add_portal_group'],
help='Add a portal group')
@ -1195,6 +1196,9 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
Private portal groups do not have their portals returned by a discovery session. A public
portal group may optionally specify a redirect portal for non-discovery logins. This redirect
portal must be from a private portal group.""", action='store_true')
p.add_argument('-w', '--wait', help="""Do not listening on portals until it is started explicitly.
One major iSCSI initiator may not retry login once it failed. Hence for such initiator, listening
on portals should be allowed after all associated target nodes are created.""", action='store_true')
p.set_defaults(func=iscsi_create_portal_group)
def iscsi_start_portal_group(args):

View File

@ -424,13 +424,14 @@ def iscsi_target_node_request_logout(client, name, pg_tag):
@deprecated_alias('add_portal_group')
def iscsi_create_portal_group(client, portals, tag, private):
def iscsi_create_portal_group(client, portals, tag, private, wait):
"""Add a portal group.
Args:
portals: List of portals, e.g. [{'host': ip, 'port': port}]
tag: Initiator group tag (unique, integer > 0)
private: Public (false) or private (true) portal group for login redirection.
wait: Do not listen on portals until it is allowed explictly.
Returns:
True or False
@ -439,6 +440,8 @@ def iscsi_create_portal_group(client, portals, tag, private):
if private:
params['private'] = private
if wait:
params['wait'] = wait
return client.call('iscsi_create_portal_group', params)

View File

@ -315,7 +315,7 @@ class UIPortalGroups(UINode):
if cpumask:
print("WARNING: Specifying a CPU mask for portal groups is no longer supported. Ignoring.")
tag = self.ui_eval_param(tag, "number", None)
self.get_root().construct_portal_group(tag=tag, portals=portals, private=None)
self.get_root().construct_portal_group(tag=tag, portals=portals, private=None, wait=None)
def ui_command_delete(self, tag):
"""Delete a portal group with given tag (unique, integer > 0))"""