Commit b82fd48a authored by Jim Harris's avatar Jim Harris
Browse files

thread: remove pool parameter from spdk_iobuf_for_each_entry



We always want to iterate across the entire iobuf_channel, so just
make the iterator do exactly that, rather than requiring the caller
to have to iterate both of the pools itself.

This both simplifies the calling logic, and prepares for upcoming
changes which will support multiple NUMA node caches in one channel.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: Ieed144671e7ee7cb4d7b7b28e803ea3cae641fee
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24515


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
parent d182ee1d
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -1190,17 +1190,16 @@ typedef int (*spdk_iobuf_for_each_entry_fn)(struct spdk_iobuf_channel *ch,
		struct spdk_iobuf_entry *entry, void *ctx);

/**
 * Iterate over all entries on a given queue and execute a callback on those that were requested
 * using `ch`.  The iteration is stopped if the callback returns non-zero status.
 * Iterate over all entries on a given channel and execute a callback on those that were requested.
 * The iteration is stopped if the callback returns non-zero status.
 *
 * \param ch iobuf channel to iterate over.
 * \param pool Pool to iterate over (`small` or `large`).
 * \param cb_fn Callback to execute on each entry on the queue that was requested using `ch`.
 * \param cb_fn Callback to execute on each entry on the channel that was requested.
 * \param cb_ctx Argument passed to `cb_fn`.
 *
 * \return status of the last callback.
 */
int spdk_iobuf_for_each_entry(struct spdk_iobuf_channel *ch, struct spdk_iobuf_pool *pool,
int spdk_iobuf_for_each_entry(struct spdk_iobuf_channel *ch,
			      spdk_iobuf_for_each_entry_fn cb_fn, void *cb_ctx);

/**
+2 −12
Original line number Diff line number Diff line
@@ -4318,10 +4318,7 @@ bdev_abort_all_buf_io_cb(struct spdk_iobuf_channel *ch, struct spdk_iobuf_entry
static void
bdev_abort_all_buf_io(struct spdk_bdev_mgmt_channel *mgmt_ch, struct spdk_bdev_channel *ch)
{
	spdk_iobuf_for_each_entry(&mgmt_ch->iobuf, &mgmt_ch->iobuf.small,
				  bdev_abort_all_buf_io_cb, ch);
	spdk_iobuf_for_each_entry(&mgmt_ch->iobuf, &mgmt_ch->iobuf.large,
				  bdev_abort_all_buf_io_cb, ch);
	spdk_iobuf_for_each_entry(&mgmt_ch->iobuf, bdev_abort_all_buf_io_cb, ch);
}

/*
@@ -4388,14 +4385,7 @@ bdev_abort_buf_io(struct spdk_bdev_mgmt_channel *mgmt_ch, struct spdk_bdev_io *b
{
	int rc;

	rc = spdk_iobuf_for_each_entry(&mgmt_ch->iobuf, &mgmt_ch->iobuf.small,
				       bdev_abort_buf_io_cb, bio_to_abort);
	if (rc == 1) {
		return true;
	}

	rc = spdk_iobuf_for_each_entry(&mgmt_ch->iobuf, &mgmt_ch->iobuf.large,
				       bdev_abort_buf_io_cb, bio_to_abort);
	rc = spdk_iobuf_for_each_entry(&mgmt_ch->iobuf, bdev_abort_buf_io_cb, bio_to_abort);
	return rc == 1;
}

+1 −8
Original line number Diff line number Diff line
@@ -974,14 +974,7 @@ nvmf_request_get_buffers_abort(struct spdk_nvmf_request *req)

	assert(tgroup != NULL);

	rc = spdk_iobuf_for_each_entry(tgroup->buf_cache, &tgroup->buf_cache->small,
				       nvmf_request_get_buffers_abort_cb, req);
	if (rc == 1) {
		return true;
	}

	rc = spdk_iobuf_for_each_entry(tgroup->buf_cache, &tgroup->buf_cache->large,
				       nvmf_request_get_buffers_abort_cb, req);
	rc = spdk_iobuf_for_each_entry(tgroup->buf_cache, nvmf_request_get_buffers_abort_cb, req);
	return rc == 1;
}

+2 −2
Original line number Diff line number Diff line
@@ -6,8 +6,8 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 10
SO_MINOR := 2
SO_VER := 11
SO_MINOR := 0

C_SRCS = thread.c iobuf.c
LIBNAME = thread
+15 −2
Original line number Diff line number Diff line
@@ -476,8 +476,8 @@ spdk_iobuf_unregister_module(const char *name)
	return -ENOENT;
}

int
spdk_iobuf_for_each_entry(struct spdk_iobuf_channel *ch, struct spdk_iobuf_pool *pool,
static int
iobuf_pool_for_each_entry(struct spdk_iobuf_channel *ch, struct spdk_iobuf_pool *pool,
			  spdk_iobuf_for_each_entry_fn cb_fn, void *cb_ctx)
{
	struct spdk_iobuf_entry *entry, *tmp;
@@ -498,6 +498,19 @@ spdk_iobuf_for_each_entry(struct spdk_iobuf_channel *ch, struct spdk_iobuf_pool
	return 0;
}

int
spdk_iobuf_for_each_entry(struct spdk_iobuf_channel *ch,
			  spdk_iobuf_for_each_entry_fn cb_fn, void *cb_ctx)
{
	int rc;

	rc = iobuf_pool_for_each_entry(ch, &ch->small, cb_fn, cb_ctx);
	if (rc != 0) {
		return rc;
	}
	return iobuf_pool_for_each_entry(ch, &ch->large, cb_fn, cb_ctx);
}

void
spdk_iobuf_entry_abort(struct spdk_iobuf_channel *ch, struct spdk_iobuf_entry *entry,
		       uint64_t len)
Loading