]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/include/spdk/nbd.h
4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * Network block device layer
47 struct spdk_json_write_ctx
;
50 * Initialize the network block device layer.
52 * \return 0 on success.
54 int spdk_nbd_init(void);
57 * Stop and close all the running network block devices.
59 void spdk_nbd_fini(void);
62 * Called when an NBD device has been started.
63 * On success, rc is assigned 0; On failure, rc is assigned negated errno.
65 typedef void (*spdk_nbd_start_cb
)(void *cb_arg
, struct spdk_nbd_disk
*nbd
,
69 * Start a network block device backed by the bdev.
71 * \param bdev_name Name of bdev exposed as a network block device.
72 * \param nbd_path Path to the registered network block device.
73 * \param cb_fn Callback to be always called.
74 * \param cb_arg Passed to cb_fn.
76 void spdk_nbd_start(const char *bdev_name
, const char *nbd_path
,
77 spdk_nbd_start_cb cb_fn
, void *cb_arg
);
80 * Stop the running network block device safely.
82 * \param nbd A pointer to the network block device to stop.
84 void spdk_nbd_stop(struct spdk_nbd_disk
*nbd
);
87 * Get the local filesystem path used for the network block device.
89 const char *spdk_nbd_get_path(struct spdk_nbd_disk
*nbd
);
92 * Write NBD subsystem configuration into provided JSON context.
94 * \param w JSON write context
96 void spdk_nbd_write_config_json(struct spdk_json_write_ctx
*w
);