Commit d4ad1f9c authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

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: default avatarShuhei 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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 024d2865
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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

+3 −1
Original line number Diff line number Diff line
@@ -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;
+5 −1
Original line number Diff line number Diff line
@@ -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):
+4 −1
Original line number Diff line number Diff line
@@ -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)


Loading