Commit 44770c2a authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

bdev: Remove poller abstraction



Use the new one from io_channel.h.

Change-Id: I7bf6729caf6eeebcb58450a36119601957ad5da4
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/388290


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 3aba1a56
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,11 @@ framework (include/spdk/event.h) to the I/O channel library
(include/spdk/io_channel.h). This allows code that doesn't depend on the event
framework to request registration and unregistration of pollers.

### Block Device Abstraction Layer (bdev)

The poller abstraction was removed from the bdev layer. There is now a general purpose
abstraction for pollers available in include/spdk/io_channel.h

## v17.10: Logical Volumes

### New dependencies
+7 −41
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ struct spdk_fio_msg {

/* A polling function */
struct spdk_fio_poller {
	spdk_bdev_poller_fn	cb_fn;
	spdk_poller_fn		cb_fn;
	void			*cb_arg;
	uint64_t		period_microseconds;

@@ -93,7 +93,7 @@ struct spdk_fio_thread {
	unsigned int		iocq_size;	// number of iocq entries allocated
};

static __thread struct spdk_fio_thread *g_thread;
static struct spdk_fio_thread *g_init_thread = NULL;
static bool g_spdk_env_initialized = false;

static int spdk_fio_init(struct thread_data *td);
@@ -131,15 +131,9 @@ spdk_fio_start_poller(void *thread_ctx,
		      void *arg,
		      uint64_t period_microseconds)
{
	struct spdk_fio_thread *fio_thread;
	struct spdk_fio_thread *fio_thread = thread_ctx;
	struct spdk_fio_poller *fio_poller;

	fio_thread = g_thread;
	if (!fio_thread) {
		SPDK_ERRLOG("Expected local thread to be initialized, but it was not.\n");
		return NULL;
	}

	fio_poller = calloc(1, sizeof(*fio_poller));
	if (!fio_poller) {
		SPDK_ERRLOG("Unable to allocate poller\n");
@@ -155,40 +149,19 @@ spdk_fio_start_poller(void *thread_ctx,
	return (struct spdk_poller *)fio_poller;
}

static void
spdk_fio_bdev_start_poller(struct spdk_bdev_poller **ppoller,
			   spdk_bdev_poller_fn fn,
			   void *arg,
			   uint64_t period_microseconds)
{
	*ppoller = (struct spdk_bdev_poller *)spdk_poller_register(fn, arg, period_microseconds);
}

static void
spdk_fio_stop_poller(struct spdk_poller *poller, void *thread_ctx)
{
	struct spdk_fio_poller *fio_poller;
	struct spdk_fio_thread *fio_thread;
	struct spdk_fio_thread *fio_thread = thread_ctx;

	fio_poller = (struct spdk_fio_poller *)poller;

	fio_thread = g_thread;
	if (!fio_thread) {
		SPDK_ERRLOG("Expected local thread to be initialized, but it was not.\n");
		return;
	}

	TAILQ_REMOVE(&fio_thread->pollers, fio_poller, link);

	free(fio_poller);
}

static void
spdk_fio_bdev_stop_poller(struct spdk_bdev_poller **ppoller)
{
	spdk_poller_unregister((struct spdk_poller **)ppoller);
}

static int
spdk_fio_init_thread(struct thread_data *td)
{
@@ -230,9 +203,6 @@ spdk_fio_init_thread(struct thread_data *td)

	TAILQ_INIT(&fio_thread->targets);

	/* Cache the thread in a thread-local variable for easy access */
	g_thread = fio_thread;

	return 0;
}

@@ -291,15 +261,13 @@ spdk_fio_init_env(struct thread_data *td)
		return -1;
	}

	fio_thread = td->io_ops_data;
	g_init_thread = fio_thread = td->io_ops_data;

	/* Initialize the copy engine */
	spdk_copy_engine_initialize();

	/* Initialize the bdev layer */
	spdk_bdev_initialize(spdk_fio_bdev_init_done, &done,
			     spdk_fio_bdev_start_poller,
			     spdk_fio_bdev_stop_poller);
	spdk_bdev_initialize(spdk_fio_bdev_init_done, &done);

	do {
		/* Handle init and all cleanup events */
@@ -421,8 +389,6 @@ spdk_fio_cleanup_thread(struct spdk_fio_thread *fio_thread)

	while (spdk_fio_poll_thread(fio_thread) > 0) {}

	g_thread = NULL;

	spdk_free_thread();
	spdk_ring_free(fio_thread->ring);
	free(fio_thread->iocq);
@@ -700,7 +666,7 @@ spdk_fio_finish_env(void)
	size_t				count;

	/* the same thread that called spdk_fio_init_env */
	fio_thread = g_thread;
	fio_thread = g_init_thread;

	spdk_bdev_finish(spdk_fio_module_finish_done, &done);

+1 −14
Original line number Diff line number Diff line
@@ -113,29 +113,16 @@ struct spdk_bdev_io_stat {
	uint64_t num_write_ops;
};

struct spdk_bdev_poller;

typedef void (*spdk_bdev_init_cb)(void *cb_arg, int rc);
typedef void (*spdk_bdev_fini_cb)(void *cb_arg);

typedef void (*spdk_bdev_poller_fn)(void *arg);
typedef void (*spdk_bdev_poller_start_cb)(struct spdk_bdev_poller **ppoller,
		spdk_bdev_poller_fn fn,
		void *arg,
		uint64_t period_microseconds);
typedef void (*spdk_bdev_poller_stop_cb)(struct spdk_bdev_poller **ppoller);

/**
 * Initialize block device modules.
 *
 * \param cb_fn Called when the initialization is complete.
 * \param cb_arg Argument passed to function cb_fn.
 * \param start_poller_fn This function is called to request starting a poller.
 * \param stop_poller_fn This function is called to request stopping a poller.
 */
void spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg,
			  spdk_bdev_poller_start_cb start_poller_fn,
			  spdk_bdev_poller_stop_cb stop_poller_fn);
void spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg);

/**
 * Perform cleanup work to remove the registered block device modules.
+0 −23
Original line number Diff line number Diff line
@@ -396,29 +396,6 @@ int spdk_bdev_module_claim_bdev(struct spdk_bdev *bdev, struct spdk_bdev_desc *d
				struct spdk_bdev_module_if *module);
void spdk_bdev_module_release_bdev(struct spdk_bdev *bdev);

/**
 * Start a poller on the current thread to periodically call fn.
 *
 * \param[out] ppoller Will be filled with initialized poller pointer.
 * \param fn Function to run periodically.
 * \param arg Argument to be passed to fn.
 * \param period_microseconds Delay between calls of the poller function,
 *                            or 0 to call as frequently as possible.
 *
 * The user must call spdk_bdev_poller_stop() to clean up the resources allocated by this function.
 */
void spdk_bdev_poller_start(struct spdk_bdev_poller **ppoller,
			    spdk_bdev_poller_fn fn,
			    void *arg,
			    uint64_t period_microseconds);

/**
 * Stop a poller started by spdk_bdev_poller_start().
 *
 * \param ppoller Poller to stop.
 */
void spdk_bdev_poller_stop(struct spdk_bdev_poller **ppoller);

/**
 * Allocate a buffer for given bdev_io.  Allocation will happen
 * only if the bdev_io has no assigned SGL yet. The buffer will be
+2 −2
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ bdev_aio_create_cb(void *io_device, void *ctx_buf)
		return -1;
	}

	spdk_bdev_poller_start(&ch->poller, bdev_aio_poll, ch, 0);
	ch->poller = spdk_poller_register(bdev_aio_poll, ch, 0);
	return 0;
}

@@ -322,7 +322,7 @@ bdev_aio_destroy_cb(void *io_device, void *ctx_buf)
	struct bdev_aio_io_channel *io_channel = ctx_buf;

	io_destroy(io_channel->io_ctx);
	spdk_bdev_poller_stop(&io_channel->poller);
	spdk_poller_unregister(&io_channel->poller);
}

static struct spdk_io_channel *
Loading