Commit 515419ac authored by Aleksey Marchuk's avatar Aleksey Marchuk Committed by Tomasz Zawadzki
Browse files

rpc: Add API to get method state mask



The new API will be used in the next patch
to prevent calling metods for the seconds time
when subsystem is initialized with config file

Signed-off-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Change-Id: I60ac8196e46ccb3b22b3af0607e1ba35a11a66a6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14406


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 67bb3316
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ Added warning message for `bdev_rbd_create`, if it is used without -c.
Renamed `enable_vmd` RPC to `vmd_enable` to make it consistent with our naming scheme of
`<subsystem>_<action>`.  For now, the old name is still available, but is marked as deprecated.

New function `spdk_rpc_get_method_state_mask` was added to RPC library.

### raid

Renamed the `raid5` module to `raid5f` to reflect that it is not a traditional
+11 −0
Original line number Diff line number Diff line
/*   SPDX-License-Identifier: BSD-3-Clause
 *   Copyright (c) Intel Corporation.
 *   All rights reserved.
 *   Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 */

#ifndef SPDK_RPC_CONFIG_H_
@@ -84,6 +85,16 @@ void spdk_rpc_register_alias_deprecated(const char *method, const char *alias);
 */
int spdk_rpc_is_method_allowed(const char *method, uint32_t state_mask);

/**
 * Return state mask of the method
 *
 * \param method Method name
 * \param[out] state_mask State mask of the method
 * \retval 0 if method is found and \b state_mask is filled
 * \retval -ENOENT if method is not found
 */
int spdk_rpc_get_method_state_mask(const char *method, uint32_t *state_mask);

#define SPDK_RPC_STARTUP	0x1
#define SPDK_RPC_RUNTIME	0x2

+2 −1
Original line number Diff line number Diff line
#  SPDX-License-Identifier: BSD-3-Clause
#  Copyright (c) Intel Corporation.
#  All rights reserved.
#  Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#

SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 4
SO_MINOR := 0
SO_MINOR := 1

C_SRCS = rpc.c
LIBNAME = rpc
+16 −0
Original line number Diff line number Diff line
/*   SPDX-License-Identifier: BSD-3-Clause
 *   Copyright (c) Intel Corporation. All rights reserved.
 *   Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved.
 *   Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 */

#include <sys/file.h>
@@ -273,6 +274,21 @@ spdk_rpc_is_method_allowed(const char *method, uint32_t state_mask)
	return -ENOENT;
}

int
spdk_rpc_get_method_state_mask(const char *method, uint32_t *state_mask)
{
	struct spdk_rpc_method *m;

	SLIST_FOREACH(m, &g_rpc_methods, slist) {
		if (strcmp(m->name, method) == 0) {
			*state_mask = m->state_mask;
			return 0;
		}
	}

	return -ENOENT;
}

void
spdk_rpc_close(void)
{
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
	spdk_rpc_register_method;
	spdk_rpc_register_alias_deprecated;
	spdk_rpc_is_method_allowed;
	spdk_rpc_get_method_state_mask;
	spdk_rpc_set_state;
	spdk_rpc_get_state;

Loading