Commit a591161c authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

bdev: make struct spdk_bdev contents private



Change-Id: If203e82f8cd10d5998a565ad490ef11e2916687f
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent eaf90197
Loading
Loading
Loading
Loading
+1 −52
Original line number Diff line number Diff line
@@ -42,15 +42,11 @@
#include "spdk/stdinc.h"

#include "spdk/event.h"
#include "spdk/queue.h"
#include "spdk/scsi_spec.h"

#define SPDK_BDEV_SMALL_BUF_MAX_SIZE 8192
#define SPDK_BDEV_LARGE_BUF_MAX_SIZE (64 * 1024)

#define SPDK_BDEV_MAX_NAME_LENGTH		16
#define SPDK_BDEV_MAX_PRODUCT_NAME_LENGTH	50

typedef void (*spdk_bdev_remove_cb_t)(void *remove_ctx);

/**
@@ -77,54 +73,7 @@ enum spdk_bdev_status {
 *
 * This is a virtual representation of a block device that is exported by the backend.
 */
struct spdk_bdev {
	/** User context passed in by the backend */
	void *ctxt;

	/** Unique name for this block device. */
	char name[SPDK_BDEV_MAX_NAME_LENGTH];

	/** Unique product name for this kind of block device. */
	char product_name[SPDK_BDEV_MAX_PRODUCT_NAME_LENGTH];

	/** Size in bytes of a logical block for the backend */
	uint32_t blocklen;

	/** Number of blocks */
	uint64_t blockcnt;

	/** write cache enabled, not used at the moment */
	int write_cache;

	/**
	 * This is used to make sure buffers are sector aligned.
	 * This causes double buffering on writes.
	 */
	int need_aligned_buffer;

	/** function table for all LUN ops */
	const struct spdk_bdev_fn_table *fn_table;

	/** Represents maximum unmap block descriptor count */
	uint32_t max_unmap_bdesc_count;

	/** generation value used by block device reset */
	uint32_t gencnt;

	/** Mutex protecting claimed */
	pthread_mutex_t mutex;

	/** The bdev status */
	enum spdk_bdev_status status;

	/** Remove callback function pointer to upper level stack */
	spdk_bdev_remove_cb_t remove_cb;

	/** Callback context for hot remove the device */
	void *remove_ctx;

	TAILQ_ENTRY(spdk_bdev) link;
};
struct spdk_bdev;

/** Blockdev I/O type */
enum spdk_bdev_io_type {
+52 −0
Original line number Diff line number Diff line
@@ -79,6 +79,9 @@
 * must be passed to the bdev database via spdk_bdev_register().
 */

#define SPDK_BDEV_MAX_NAME_LENGTH		16
#define SPDK_BDEV_MAX_PRODUCT_NAME_LENGTH	50

/** Block device module */
struct spdk_bdev_module_if {
	/**
@@ -145,6 +148,55 @@ struct spdk_bdev_fn_table {
	int (*dump_config_json)(void *ctx, struct spdk_json_write_ctx *w);
};

struct spdk_bdev {
	/** User context passed in by the backend */
	void *ctxt;

	/** Unique name for this block device. */
	char name[SPDK_BDEV_MAX_NAME_LENGTH];

	/** Unique product name for this kind of block device. */
	char product_name[SPDK_BDEV_MAX_PRODUCT_NAME_LENGTH];

	/** Size in bytes of a logical block for the backend */
	uint32_t blocklen;

	/** Number of blocks */
	uint64_t blockcnt;

	/** write cache enabled, not used at the moment */
	int write_cache;

	/**
	 * This is used to make sure buffers are sector aligned.
	 * This causes double buffering on writes.
	 */
	int need_aligned_buffer;

	/** function table for all LUN ops */
	const struct spdk_bdev_fn_table *fn_table;

	/** Represents maximum unmap block descriptor count */
	uint32_t max_unmap_bdesc_count;

	/** generation value used by block device reset */
	uint32_t gencnt;

	/** Mutex protecting claimed */
	pthread_mutex_t mutex;

	/** The bdev status */
	enum spdk_bdev_status status;

	/** Remove callback function pointer to upper level stack */
	spdk_bdev_remove_cb_t remove_cb;

	/** Callback context for hot remove the device */
	void *remove_ctx;

	TAILQ_ENTRY(spdk_bdev) link;
};

typedef void (*spdk_bdev_io_get_buf_cb)(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io);

struct spdk_bdev_io {
+1 −1
Original line number Diff line number Diff line
@@ -31,10 +31,10 @@
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "spdk/bdev.h"
#include "spdk/rpc.h"
#include "spdk/util.h"

#include "spdk_internal/bdev.h"
#include "spdk_internal/log.h"

#include "blockdev_null.h"
+2 −1
Original line number Diff line number Diff line
@@ -31,10 +31,11 @@
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "spdk/bdev.h"
#include "spdk/log.h"
#include "spdk/rpc.h"

#include "spdk_internal/bdev.h"

static void
spdk_rpc_get_bdevs(struct spdk_jsonrpc_server_conn *conn,
		   const struct spdk_json_val *params,
+5 −0
Original line number Diff line number Diff line
@@ -39,6 +39,11 @@
#include "dev.c"
#include "port.c"

/* Unit test bdev mockup */
struct spdk_bdev {
	char name[100];
};

static struct spdk_bdev g_bdev = {};

struct lun_entry {
Loading