Add changes
Signed-off-by: Keith Lucas <keith.lucas@suse.com>
This commit is contained in:
parent
7843af57fc
commit
6405c45b19
@ -6,6 +6,7 @@
|
|||||||
#include "spdk_internal/lvolstore.h"
|
#include "spdk_internal/lvolstore.h"
|
||||||
#include "bdev_longhorn_replica.h"
|
#include "bdev_longhorn_replica.h"
|
||||||
#include "bdev_longhorn_lvol.h"
|
#include "bdev_longhorn_lvol.h"
|
||||||
|
#include "bdev_longhorn_nvmf.h"
|
||||||
|
|
||||||
struct rpc_longhorn_replica {
|
struct rpc_longhorn_replica {
|
||||||
char *name;
|
char *name;
|
||||||
@ -60,6 +61,79 @@ rpc_longhorn_replica_create(struct spdk_jsonrpc_request *request,
|
|||||||
SPDK_RPC_REGISTER("longhorn_replica_create", rpc_longhorn_replica_create, SPDK_RPC_RUNTIME)
|
SPDK_RPC_REGISTER("longhorn_replica_create", rpc_longhorn_replica_create, SPDK_RPC_RUNTIME)
|
||||||
|
|
||||||
|
|
||||||
|
struct rpc_longhorn_replica_stop {
|
||||||
|
char *name;
|
||||||
|
char *lvs;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct spdk_json_object_decoder rpc_longhorn_replica_stop_decoders[] = {
|
||||||
|
{"name", offsetof(struct rpc_longhorn_replica_stop, name), spdk_json_decode_string, false},
|
||||||
|
{"lvs", offsetof(struct rpc_longhorn_replica_stop, lvs), spdk_json_decode_string, false},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
rpc_longhorn_replica_stop_cb(struct spdk_nvmf_subsystem *subsystem,
|
||||||
|
void *arg, int status) {
|
||||||
|
struct spdk_jsonrpc_request *request = arg;
|
||||||
|
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rpc_longhorn_replica_stop(struct spdk_jsonrpc_request *request,
|
||||||
|
const struct spdk_json_val *params)
|
||||||
|
{
|
||||||
|
struct rpc_longhorn_replica_stop req = {};
|
||||||
|
struct spdk_nvmf_tgt *tgt;
|
||||||
|
struct spdk_nvmf_subsystem *subsystem;
|
||||||
|
char *nqn = NULL;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (spdk_json_decode_object(params, rpc_longhorn_replica_stop_decoders,
|
||||||
|
SPDK_COUNTOF(rpc_longhorn_replica_stop_decoders),
|
||||||
|
&req)) {
|
||||||
|
SPDK_ERRLOG("spdk_json_decode_object failed\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tgt = spdk_nvmf_get_tgt(NULL);
|
||||||
|
nqn = longhorn_generate_replica_nqn(req.lvs, req.name);
|
||||||
|
|
||||||
|
|
||||||
|
subsystem = spdk_nvmf_tgt_find_subsystem(tgt, nqn);
|
||||||
|
|
||||||
|
if (subsystem != NULL) {
|
||||||
|
SPDK_DEBUGLOG("Removing subsystem: %s\n", nqn);
|
||||||
|
rc = spdk_nvmf_subsystem_stop(subsystem,
|
||||||
|
rpc_longhorn_replica_stop_cb,
|
||||||
|
request);
|
||||||
|
|
||||||
|
if (rc == -EBUSY) {
|
||||||
|
SPDK_ERRLOG("Subsystem currently in another state change try again later.\n");
|
||||||
|
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
|
||||||
|
"Subsystem currently in another state change try again later.");
|
||||||
|
} else if (rc != 0) {
|
||||||
|
SPDK_ERRLOG("Unable to change state on subsystem. rc=%d\n", rc);
|
||||||
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
|
||||||
|
"Unable to change state on subsystem. rc=%d", rc);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SPDK_DEBUGLOG("%s/%s not published on NVMeOF\n", req.lvs, req.name);
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
free(nqn);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SPDK_RPC_REGISTER("longhorn_replica_stop", rpc_longhorn_replica_stop, SPDK_RPC_RUNTIME)
|
||||||
|
|
||||||
|
//SPDK_RPC_REGISTER("longhorn_replica_remove", rpc_longhorn_replica_remove, SPDK_RPC_RUNTIME)
|
||||||
|
|
||||||
|
|
||||||
struct rpc_longhorn_replica_snapshot {
|
struct rpc_longhorn_replica_snapshot {
|
||||||
char *name;
|
char *name;
|
||||||
|
Loading…
Reference in New Issue
Block a user