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

bdev: add numa.id to spdk_bdev



Note, we also need to add a "numa.id_valid" bit, so that we can
differentiate between bdevs that explicitly set a numa.id of 0, vs.
those that just calloc() the memory and therefore just set 0
implicitly.

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


Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 6ea299df
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -509,6 +509,16 @@ int spdk_bdev_open_async(const char *bdev_name, bool write, spdk_bdev_event_cb_t
 */
void spdk_bdev_close(struct spdk_bdev_desc *desc);

/**
 * Get the NUMA node ID for the specified bdev.
 *
 * \param bdev Block device to get the NUMA node ID for
 *
 * \returns NUMA node ID for the bdev, SPDK_ENV_NODE_ID_ANY if the ID
 *	    ID is unknown.
 */
int32_t spdk_bdev_get_numa_id(struct spdk_bdev *bdev);

/**
 * Callback function for spdk_for_each_bdev() and spdk_for_each_bdev_leaf().
 *
+10 −0
Original line number Diff line number Diff line
@@ -630,6 +630,16 @@ struct spdk_bdev {
	 * sent down to the device, without any delays and waiting for outstanding IO. */
	uint16_t reset_io_drain_timeout;

	struct {
		/** Is numa.id valid? Needed to know whether numa.id == 0 was
		 *  explicitly set by bdev module or implicitly set when
		 *  calloc()'ing the structure.
		 */
		uint32_t id_valid : 1;
		/** NUMA node ID for the bdev */
		int32_t id : 31;
	} numa;

	/**
	 * Pointer to the bdev module that registered this bdev.
	 */
+10 −0
Original line number Diff line number Diff line
@@ -8564,6 +8564,16 @@ spdk_bdev_close(struct spdk_bdev_desc *desc)
	spdk_spin_unlock(&g_bdev_mgr.spinlock);
}

int32_t
spdk_bdev_get_numa_id(struct spdk_bdev *bdev)
{
	if (bdev->numa.id_valid) {
		return bdev->numa.id;
	} else {
		return SPDK_ENV_NUMA_ID_ANY;
	}
}

static void
bdev_register_finished(void *arg)
{
+3 −0
Original line number Diff line number Diff line
@@ -653,6 +653,9 @@ rpc_dump_bdev_info(void *ctx, struct spdk_bdev *bdev)
	spdk_json_write_named_uint32(w, "block_size", spdk_bdev_get_block_size(bdev));
	spdk_json_write_named_uint64(w, "num_blocks", spdk_bdev_get_num_blocks(bdev));
	spdk_json_write_named_uuid(w, "uuid", &bdev->uuid);
	if (bdev->numa.id_valid) {
		spdk_json_write_named_int32(w, "numa_id", bdev->numa.id);
	}

	if (spdk_bdev_get_md_size(bdev) != 0) {
		spdk_json_write_named_uint32(w, "md_size", spdk_bdev_get_md_size(bdev));
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
	spdk_bdev_open_ext;
	spdk_bdev_open_async;
	spdk_bdev_close;
	spdk_bdev_get_numa_id;
	spdk_bdev_desc_get_bdev;
	spdk_bdev_set_timeout;
	spdk_bdev_io_type_supported;
Loading