lib/nbd: remove spdk prefix from internal functions.
Signed-off-by: Seth Howell <seth.howell@intel.com> Change-Id: If4fc856c33d6c0f50b60363664846b8f4e79ffb1 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2239 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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
c096b64f53
commit
17b53caab4
112
lib/nbd/nbd.c
112
lib/nbd/nbd.c
@ -141,7 +141,7 @@ spdk_nbd_fini(void)
|
||||
/*
|
||||
* Stop running spdk_nbd_disk.
|
||||
* Here, nbd removing are unnecessary, but _SAFE variant
|
||||
* is needed, since internal spdk_nbd_disk_unregister will
|
||||
* is needed, since internal nbd_disk_unregister will
|
||||
* remove nbd from TAILQ.
|
||||
*/
|
||||
TAILQ_FOREACH_SAFE(nbd_idx, &g_spdk_nbd.disk_head, tailq, nbd_tmp) {
|
||||
@ -150,9 +150,9 @@ spdk_nbd_fini(void)
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nbd_disk_register(struct spdk_nbd_disk *nbd)
|
||||
nbd_disk_register(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
if (spdk_nbd_disk_find_by_nbd_path(nbd->nbd_path)) {
|
||||
if (nbd_disk_find_by_nbd_path(nbd->nbd_path)) {
|
||||
SPDK_NOTICELOG("%s is already exported\n", nbd->nbd_path);
|
||||
return -EBUSY;
|
||||
}
|
||||
@ -163,7 +163,7 @@ spdk_nbd_disk_register(struct spdk_nbd_disk *nbd)
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_nbd_disk_unregister(struct spdk_nbd_disk *nbd)
|
||||
nbd_disk_unregister(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
struct spdk_nbd_disk *nbd_idx, *nbd_tmp;
|
||||
|
||||
@ -180,7 +180,7 @@ spdk_nbd_disk_unregister(struct spdk_nbd_disk *nbd)
|
||||
}
|
||||
|
||||
struct spdk_nbd_disk *
|
||||
spdk_nbd_disk_find_by_nbd_path(const char *nbd_path)
|
||||
nbd_disk_find_by_nbd_path(const char *nbd_path)
|
||||
{
|
||||
struct spdk_nbd_disk *nbd;
|
||||
|
||||
@ -196,24 +196,24 @@ spdk_nbd_disk_find_by_nbd_path(const char *nbd_path)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct spdk_nbd_disk *spdk_nbd_disk_first(void)
|
||||
struct spdk_nbd_disk *nbd_disk_first(void)
|
||||
{
|
||||
return TAILQ_FIRST(&g_spdk_nbd.disk_head);
|
||||
}
|
||||
|
||||
struct spdk_nbd_disk *spdk_nbd_disk_next(struct spdk_nbd_disk *prev)
|
||||
struct spdk_nbd_disk *nbd_disk_next(struct spdk_nbd_disk *prev)
|
||||
{
|
||||
return TAILQ_NEXT(prev, tailq);
|
||||
}
|
||||
|
||||
const char *
|
||||
spdk_nbd_disk_get_nbd_path(struct spdk_nbd_disk *nbd)
|
||||
nbd_disk_get_nbd_path(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
return nbd->nbd_path;
|
||||
}
|
||||
|
||||
const char *
|
||||
spdk_nbd_disk_get_bdev_name(struct spdk_nbd_disk *nbd)
|
||||
nbd_disk_get_bdev_name(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
return spdk_bdev_get_name(nbd->bdev);
|
||||
}
|
||||
@ -231,8 +231,8 @@ spdk_nbd_write_config_json(struct spdk_json_write_ctx *w)
|
||||
spdk_json_write_named_string(w, "method", "nbd_start_disk");
|
||||
|
||||
spdk_json_write_named_object_begin(w, "params");
|
||||
spdk_json_write_named_string(w, "nbd_device", spdk_nbd_disk_get_nbd_path(nbd));
|
||||
spdk_json_write_named_string(w, "bdev_name", spdk_nbd_disk_get_bdev_name(nbd));
|
||||
spdk_json_write_named_string(w, "nbd_device", nbd_disk_get_nbd_path(nbd));
|
||||
spdk_json_write_named_string(w, "bdev_name", nbd_disk_get_bdev_name(nbd));
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
@ -253,7 +253,7 @@ nbd_disconnect(struct spdk_nbd_disk *nbd)
|
||||
}
|
||||
|
||||
static struct nbd_io *
|
||||
spdk_get_nbd_io(struct spdk_nbd_disk *nbd)
|
||||
nbd_get_io(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
struct nbd_io *io;
|
||||
|
||||
@ -271,7 +271,7 @@ spdk_get_nbd_io(struct spdk_nbd_disk *nbd)
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_put_nbd_io(struct spdk_nbd_disk *nbd, struct nbd_io *io)
|
||||
nbd_put_io(struct spdk_nbd_disk *nbd, struct nbd_io *io)
|
||||
{
|
||||
if (io->payload) {
|
||||
spdk_free(io->payload);
|
||||
@ -288,7 +288,7 @@ spdk_put_nbd_io(struct spdk_nbd_disk *nbd, struct nbd_io *io)
|
||||
* 0 all nbd_io received are transmitted.
|
||||
*/
|
||||
static int
|
||||
spdk_nbd_io_xmit_check(struct spdk_nbd_disk *nbd)
|
||||
nbd_io_xmit_check(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
if (nbd->io_count == 0) {
|
||||
return 0;
|
||||
@ -307,13 +307,13 @@ spdk_nbd_io_xmit_check(struct spdk_nbd_disk *nbd)
|
||||
* 0 all nbd_io gotten are freed.
|
||||
*/
|
||||
static int
|
||||
spdk_nbd_cleanup_io(struct spdk_nbd_disk *nbd)
|
||||
nbd_cleanup_io(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
struct nbd_io *io, *io_tmp;
|
||||
|
||||
/* free io_in_recv */
|
||||
if (nbd->io_in_recv != NULL) {
|
||||
spdk_put_nbd_io(nbd, nbd->io_in_recv);
|
||||
nbd_put_io(nbd, nbd->io_in_recv);
|
||||
nbd->io_in_recv = NULL;
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ spdk_nbd_cleanup_io(struct spdk_nbd_disk *nbd)
|
||||
if (!TAILQ_EMPTY(&nbd->received_io_list)) {
|
||||
TAILQ_FOREACH_SAFE(io, &nbd->received_io_list, tailq, io_tmp) {
|
||||
TAILQ_REMOVE(&nbd->received_io_list, io, tailq);
|
||||
spdk_put_nbd_io(nbd, io);
|
||||
nbd_put_io(nbd, io);
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,7 +329,7 @@ spdk_nbd_cleanup_io(struct spdk_nbd_disk *nbd)
|
||||
if (!TAILQ_EMPTY(&nbd->executed_io_list)) {
|
||||
TAILQ_FOREACH_SAFE(io, &nbd->executed_io_list, tailq, io_tmp) {
|
||||
TAILQ_REMOVE(&nbd->executed_io_list, io, tailq);
|
||||
spdk_put_nbd_io(nbd, io);
|
||||
nbd_put_io(nbd, io);
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,7 +365,7 @@ _nbd_stop(struct spdk_nbd_disk *nbd)
|
||||
|
||||
if (nbd->dev_fd >= 0) {
|
||||
/* Clear nbd device only if it is occupied by SPDK app */
|
||||
if (nbd->nbd_path && spdk_nbd_disk_find_by_nbd_path(nbd->nbd_path)) {
|
||||
if (nbd->nbd_path && nbd_disk_find_by_nbd_path(nbd->nbd_path)) {
|
||||
ioctl(nbd->dev_fd, NBD_CLEAR_QUE);
|
||||
ioctl(nbd->dev_fd, NBD_CLEAR_SOCK);
|
||||
}
|
||||
@ -380,7 +380,7 @@ _nbd_stop(struct spdk_nbd_disk *nbd)
|
||||
spdk_poller_unregister(&nbd->nbd_poller);
|
||||
}
|
||||
|
||||
spdk_nbd_disk_unregister(nbd);
|
||||
nbd_disk_unregister(nbd);
|
||||
|
||||
free(nbd);
|
||||
}
|
||||
@ -397,7 +397,7 @@ spdk_nbd_stop(struct spdk_nbd_disk *nbd)
|
||||
/*
|
||||
* Stop action should be called only after all nbd_io are executed.
|
||||
*/
|
||||
if (!spdk_nbd_cleanup_io(nbd)) {
|
||||
if (!nbd_cleanup_io(nbd)) {
|
||||
_nbd_stop(nbd);
|
||||
}
|
||||
}
|
||||
@ -457,7 +457,7 @@ nbd_io_done(struct spdk_bdev_io *bdev_io, bool success, void *cb_arg)
|
||||
spdk_bdev_free_io(bdev_io);
|
||||
}
|
||||
|
||||
if (nbd->state == NBD_DISK_STATE_HARDDISC && !spdk_nbd_cleanup_io(nbd)) {
|
||||
if (nbd->state == NBD_DISK_STATE_HARDDISC && !nbd_cleanup_io(nbd)) {
|
||||
_nbd_stop(nbd);
|
||||
}
|
||||
}
|
||||
@ -472,7 +472,7 @@ nbd_resubmit_io(void *arg)
|
||||
rc = nbd_submit_bdev_io(nbd, io);
|
||||
if (rc) {
|
||||
SPDK_INFOLOG(SPDK_LOG_NBD, "nbd: io resubmit for dev %s , io_type %d, returned %d.\n",
|
||||
spdk_nbd_disk_get_bdev_name(nbd), from_be32(&io->req.type), rc);
|
||||
nbd_disk_get_bdev_name(nbd), from_be32(&io->req.type), rc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -523,7 +523,7 @@ nbd_submit_bdev_io(struct spdk_nbd_disk *nbd, struct nbd_io *io)
|
||||
break;
|
||||
#endif
|
||||
case NBD_CMD_DISC:
|
||||
spdk_put_nbd_io(nbd, io);
|
||||
nbd_put_io(nbd, io);
|
||||
nbd->state = NBD_DISK_STATE_SOFTDISC;
|
||||
break;
|
||||
default:
|
||||
@ -544,7 +544,7 @@ nbd_submit_bdev_io(struct spdk_nbd_disk *nbd, struct nbd_io *io)
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nbd_io_exec(struct spdk_nbd_disk *nbd)
|
||||
nbd_io_exec(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
struct nbd_io *io, *io_tmp;
|
||||
int ret = 0;
|
||||
@ -571,13 +571,13 @@ spdk_nbd_io_exec(struct spdk_nbd_disk *nbd)
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
||||
nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
struct nbd_io *io;
|
||||
int ret = 0;
|
||||
|
||||
if (nbd->io_in_recv == NULL) {
|
||||
nbd->io_in_recv = spdk_get_nbd_io(nbd);
|
||||
nbd->io_in_recv = nbd_get_io(nbd);
|
||||
if (!nbd->io_in_recv) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -589,7 +589,7 @@ spdk_nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
||||
ret = read_from_socket(nbd->spdk_sp_fd, (char *)&io->req + io->offset,
|
||||
sizeof(io->req) - io->offset);
|
||||
if (ret < 0) {
|
||||
spdk_put_nbd_io(nbd, io);
|
||||
nbd_put_io(nbd, io);
|
||||
nbd->io_in_recv = NULL;
|
||||
return ret;
|
||||
}
|
||||
@ -603,7 +603,7 @@ spdk_nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
||||
/* req magic check */
|
||||
if (from_be32(&io->req.magic) != NBD_REQUEST_MAGIC) {
|
||||
SPDK_ERRLOG("invalid request magic\n");
|
||||
spdk_put_nbd_io(nbd, io);
|
||||
nbd_put_io(nbd, io);
|
||||
nbd->io_in_recv = NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -622,7 +622,7 @@ spdk_nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
||||
SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
|
||||
if (io->payload == NULL) {
|
||||
SPDK_ERRLOG("could not allocate io->payload of size %d\n", io->payload_size);
|
||||
spdk_put_nbd_io(nbd, io);
|
||||
nbd_put_io(nbd, io);
|
||||
nbd->io_in_recv = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -644,7 +644,7 @@ spdk_nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
||||
if (io->state == NBD_IO_RECV_PAYLOAD) {
|
||||
ret = read_from_socket(nbd->spdk_sp_fd, io->payload + io->offset, io->payload_size - io->offset);
|
||||
if (ret < 0) {
|
||||
spdk_put_nbd_io(nbd, io);
|
||||
nbd_put_io(nbd, io);
|
||||
nbd->io_in_recv = NULL;
|
||||
return ret;
|
||||
}
|
||||
@ -665,7 +665,7 @@ spdk_nbd_io_recv_internal(struct spdk_nbd_disk *nbd)
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nbd_io_recv(struct spdk_nbd_disk *nbd)
|
||||
nbd_io_recv(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
int i, ret = 0;
|
||||
|
||||
@ -678,7 +678,7 @@ spdk_nbd_io_recv(struct spdk_nbd_disk *nbd)
|
||||
}
|
||||
|
||||
for (i = 0; i < GET_IO_LOOP_COUNT; i++) {
|
||||
ret = spdk_nbd_io_recv_internal(nbd);
|
||||
ret = nbd_io_recv_internal(nbd);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -688,7 +688,7 @@ spdk_nbd_io_recv(struct spdk_nbd_disk *nbd)
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nbd_io_xmit_internal(struct spdk_nbd_disk *nbd)
|
||||
nbd_io_xmit_internal(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
struct nbd_io *io;
|
||||
int ret = 0;
|
||||
@ -721,7 +721,7 @@ spdk_nbd_io_xmit_internal(struct spdk_nbd_disk *nbd)
|
||||
|
||||
/* transmit payload only when NBD_CMD_READ with no resp error */
|
||||
if (from_be32(&io->req.type) != NBD_CMD_READ || io->resp.error != 0) {
|
||||
spdk_put_nbd_io(nbd, io);
|
||||
nbd_put_io(nbd, io);
|
||||
return 0;
|
||||
} else {
|
||||
io->state = NBD_IO_XMIT_PAYLOAD;
|
||||
@ -739,7 +739,7 @@ spdk_nbd_io_xmit_internal(struct spdk_nbd_disk *nbd)
|
||||
|
||||
/* read payload is fully transmitted */
|
||||
if (io->offset == io->payload_size) {
|
||||
spdk_put_nbd_io(nbd, io);
|
||||
nbd_put_io(nbd, io);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -750,7 +750,7 @@ reinsert:
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nbd_io_xmit(struct spdk_nbd_disk *nbd)
|
||||
nbd_io_xmit(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@ -763,7 +763,7 @@ spdk_nbd_io_xmit(struct spdk_nbd_disk *nbd)
|
||||
}
|
||||
|
||||
while (!TAILQ_EMPTY(&nbd->executed_io_list)) {
|
||||
ret = spdk_nbd_io_xmit_internal(nbd);
|
||||
ret = nbd_io_xmit_internal(nbd);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -773,7 +773,7 @@ spdk_nbd_io_xmit(struct spdk_nbd_disk *nbd)
|
||||
* For soft disconnection, nbd server can close connection after all
|
||||
* outstanding request are transmitted.
|
||||
*/
|
||||
if (nbd->state == NBD_DISK_STATE_SOFTDISC && !spdk_nbd_io_xmit_check(nbd)) {
|
||||
if (nbd->state == NBD_DISK_STATE_SOFTDISC && !nbd_io_xmit_check(nbd)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -786,35 +786,35 @@ spdk_nbd_io_xmit(struct spdk_nbd_disk *nbd)
|
||||
* \return 0 on success or negated errno values on error (e.g. connection closed).
|
||||
*/
|
||||
static int
|
||||
_spdk_nbd_poll(struct spdk_nbd_disk *nbd)
|
||||
_nbd_poll(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
int rc;
|
||||
|
||||
/* transmit executed io first */
|
||||
rc = spdk_nbd_io_xmit(nbd);
|
||||
rc = nbd_io_xmit(nbd);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = spdk_nbd_io_recv(nbd);
|
||||
rc = nbd_io_recv(nbd);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = spdk_nbd_io_exec(nbd);
|
||||
rc = nbd_io_exec(nbd);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nbd_poll(void *arg)
|
||||
nbd_poll(void *arg)
|
||||
{
|
||||
struct spdk_nbd_disk *nbd = arg;
|
||||
int rc;
|
||||
|
||||
rc = _spdk_nbd_poll(nbd);
|
||||
rc = _nbd_poll(nbd);
|
||||
if (rc < 0) {
|
||||
SPDK_INFOLOG(SPDK_LOG_NBD, "spdk_nbd_poll() returned %s (%d); closing connection\n",
|
||||
SPDK_INFOLOG(SPDK_LOG_NBD, "nbd_poll() returned %s (%d); closing connection\n",
|
||||
spdk_strerror(-rc), rc);
|
||||
spdk_nbd_stop(nbd);
|
||||
}
|
||||
@ -836,7 +836,7 @@ nbd_start_kernel(void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_nbd_bdev_hot_remove(void *remove_ctx)
|
||||
nbd_bdev_hot_remove(void *remove_ctx)
|
||||
{
|
||||
struct spdk_nbd_disk *nbd = remove_ctx;
|
||||
|
||||
@ -852,14 +852,14 @@ struct spdk_nbd_start_ctx {
|
||||
};
|
||||
|
||||
static void
|
||||
spdk_nbd_start_complete(struct spdk_nbd_start_ctx *ctx)
|
||||
nbd_start_complete(struct spdk_nbd_start_ctx *ctx)
|
||||
{
|
||||
int rc;
|
||||
pthread_t tid;
|
||||
int flag;
|
||||
|
||||
/* Add nbd_disk to the end of disk list */
|
||||
rc = spdk_nbd_disk_register(ctx->nbd);
|
||||
rc = nbd_disk_register(ctx->nbd);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("Failed to register %s, it should not happen.\n", ctx->nbd->nbd_path);
|
||||
assert(false);
|
||||
@ -911,7 +911,7 @@ spdk_nbd_start_complete(struct spdk_nbd_start_ctx *ctx)
|
||||
goto err;
|
||||
}
|
||||
|
||||
ctx->nbd->nbd_poller = SPDK_POLLER_REGISTER(spdk_nbd_poll, ctx->nbd, 0);
|
||||
ctx->nbd->nbd_poller = SPDK_POLLER_REGISTER(nbd_poll, ctx->nbd, 0);
|
||||
|
||||
if (ctx->cb_fn) {
|
||||
ctx->cb_fn(ctx->cb_arg, ctx->nbd, 0);
|
||||
@ -929,7 +929,7 @@ err:
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nbd_enable_kernel(void *arg)
|
||||
nbd_enable_kernel(void *arg)
|
||||
{
|
||||
struct spdk_nbd_start_ctx *ctx = arg;
|
||||
int rc;
|
||||
@ -939,7 +939,7 @@ spdk_nbd_enable_kernel(void *arg)
|
||||
if (rc == -1) {
|
||||
if (errno == EBUSY && ctx->polling_count-- > 0) {
|
||||
if (ctx->poller == NULL) {
|
||||
ctx->poller = SPDK_POLLER_REGISTER(spdk_nbd_enable_kernel, ctx,
|
||||
ctx->poller = SPDK_POLLER_REGISTER(nbd_enable_kernel, ctx,
|
||||
NBD_BUSY_POLLING_INTERVAL_US);
|
||||
}
|
||||
/* If the kernel is busy, check back later */
|
||||
@ -965,7 +965,7 @@ spdk_nbd_enable_kernel(void *arg)
|
||||
spdk_poller_unregister(&ctx->poller);
|
||||
}
|
||||
|
||||
spdk_nbd_start_complete(ctx);
|
||||
nbd_start_complete(ctx);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1008,7 +1008,7 @@ spdk_nbd_start(const char *bdev_name, const char *nbd_path,
|
||||
ctx->cb_arg = cb_arg;
|
||||
ctx->polling_count = NBD_BUSY_WAITING_MS * 1000ULL / NBD_BUSY_POLLING_INTERVAL_US;
|
||||
|
||||
rc = spdk_bdev_open(bdev, true, spdk_nbd_bdev_hot_remove, nbd, &nbd->bdev_desc);
|
||||
rc = spdk_bdev_open(bdev, true, nbd_bdev_hot_remove, nbd, &nbd->bdev_desc);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("could not open bdev %s, error=%d\n", spdk_bdev_get_name(bdev), rc);
|
||||
goto err;
|
||||
@ -1039,7 +1039,7 @@ spdk_nbd_start(const char *bdev_name, const char *nbd_path,
|
||||
TAILQ_INIT(&nbd->executed_io_list);
|
||||
|
||||
/* Make sure nbd_path is not used in this SPDK app */
|
||||
if (spdk_nbd_disk_find_by_nbd_path(nbd->nbd_path)) {
|
||||
if (nbd_disk_find_by_nbd_path(nbd->nbd_path)) {
|
||||
SPDK_NOTICELOG("%s is already exported\n", nbd->nbd_path);
|
||||
rc = -EBUSY;
|
||||
goto err;
|
||||
@ -1055,7 +1055,7 @@ spdk_nbd_start(const char *bdev_name, const char *nbd_path,
|
||||
SPDK_INFOLOG(SPDK_LOG_NBD, "Enabling kernel access to bdev %s via %s\n",
|
||||
spdk_bdev_get_name(bdev), nbd_path);
|
||||
|
||||
spdk_nbd_enable_kernel(ctx);
|
||||
nbd_enable_kernel(ctx);
|
||||
return;
|
||||
|
||||
err:
|
||||
|
@ -37,15 +37,15 @@
|
||||
#include "spdk/stdinc.h"
|
||||
#include "spdk/nbd.h"
|
||||
|
||||
struct spdk_nbd_disk *spdk_nbd_disk_find_by_nbd_path(const char *nbd_path);
|
||||
struct spdk_nbd_disk *nbd_disk_find_by_nbd_path(const char *nbd_path);
|
||||
|
||||
struct spdk_nbd_disk *spdk_nbd_disk_first(void);
|
||||
struct spdk_nbd_disk *nbd_disk_first(void);
|
||||
|
||||
struct spdk_nbd_disk *spdk_nbd_disk_next(struct spdk_nbd_disk *prev);
|
||||
struct spdk_nbd_disk *nbd_disk_next(struct spdk_nbd_disk *prev);
|
||||
|
||||
const char *spdk_nbd_disk_get_nbd_path(struct spdk_nbd_disk *nbd);
|
||||
const char *nbd_disk_get_nbd_path(struct spdk_nbd_disk *nbd);
|
||||
|
||||
const char *spdk_nbd_disk_get_bdev_name(struct spdk_nbd_disk *nbd);
|
||||
const char *nbd_disk_get_bdev_name(struct spdk_nbd_disk *nbd);
|
||||
|
||||
void nbd_disconnect(struct spdk_nbd_disk *nbd);
|
||||
|
||||
|
@ -82,7 +82,7 @@ check_available_nbd_disk(char *nbd_device)
|
||||
}
|
||||
|
||||
/* make sure nbd_device is not registered inside SPDK */
|
||||
nbd = spdk_nbd_disk_find_by_nbd_path(nbd_device);
|
||||
nbd = nbd_disk_find_by_nbd_path(nbd_device);
|
||||
if (nbd) {
|
||||
/* nbd_device is in using */
|
||||
return -EBUSY;
|
||||
@ -296,7 +296,7 @@ spdk_rpc_nbd_stop_disk(struct spdk_jsonrpc_request *request,
|
||||
}
|
||||
|
||||
/* make sure nbd_device is registered */
|
||||
nbd = spdk_nbd_disk_find_by_nbd_path(req.nbd_device);
|
||||
nbd = nbd_disk_find_by_nbd_path(req.nbd_device);
|
||||
if (!nbd) {
|
||||
spdk_jsonrpc_send_error_response(request, -ENODEV, spdk_strerror(ENODEV));
|
||||
goto out;
|
||||
@ -347,9 +347,9 @@ spdk_rpc_dump_nbd_info(struct spdk_json_write_ctx *w,
|
||||
{
|
||||
spdk_json_write_object_begin(w);
|
||||
|
||||
spdk_json_write_named_string(w, "nbd_device", spdk_nbd_disk_get_nbd_path(nbd));
|
||||
spdk_json_write_named_string(w, "nbd_device", nbd_disk_get_nbd_path(nbd));
|
||||
|
||||
spdk_json_write_named_string(w, "bdev_name", spdk_nbd_disk_get_bdev_name(nbd));
|
||||
spdk_json_write_named_string(w, "bdev_name", nbd_disk_get_bdev_name(nbd));
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
@ -387,7 +387,7 @@ spdk_rpc_nbd_get_disks(struct spdk_jsonrpc_request *request,
|
||||
}
|
||||
|
||||
if (req.nbd_device) {
|
||||
nbd = spdk_nbd_disk_find_by_nbd_path(req.nbd_device);
|
||||
nbd = nbd_disk_find_by_nbd_path(req.nbd_device);
|
||||
if (nbd == NULL) {
|
||||
SPDK_ERRLOG("nbd device '%s' does not exist\n", req.nbd_device);
|
||||
spdk_jsonrpc_send_error_response(request, -ENODEV, spdk_strerror(ENODEV));
|
||||
@ -404,7 +404,7 @@ spdk_rpc_nbd_get_disks(struct spdk_jsonrpc_request *request,
|
||||
if (nbd != NULL) {
|
||||
spdk_rpc_dump_nbd_info(w, nbd);
|
||||
} else {
|
||||
for (nbd = spdk_nbd_disk_first(); nbd != NULL; nbd = spdk_nbd_disk_next(nbd)) {
|
||||
for (nbd = nbd_disk_first(); nbd != NULL; nbd = nbd_disk_next(nbd)) {
|
||||
spdk_rpc_dump_nbd_info(w, nbd);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user