Esempio n. 1
0
static int
bdevio_construct_targets(void)
{
	struct spdk_bdev *bdev;
	struct io_target *target;

	bdev = spdk_bdev_first();
	while (bdev != NULL) {

		if (bdev->claimed) {
			bdev = spdk_bdev_next(bdev);
			continue;
		}

		target = malloc(sizeof(struct io_target));
		if (target == NULL) {
			return -ENOMEM;
		}
		target->bdev = bdev;
		target->next = g_io_targets;
		g_io_targets = target;

		bdev = spdk_bdev_next(bdev);
	}

	return 0;
}
Esempio n. 2
0
static void
spdk_rpc_get_bdevs(struct spdk_jsonrpc_server_conn *conn,
		   const struct spdk_json_val *params,
		   const struct spdk_json_val *id)
{
	struct spdk_json_write_ctx *w;
	struct spdk_bdev *bdev;

	if (params != NULL) {
		spdk_jsonrpc_send_error_response(conn, id, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
						 "get_bdevs requires no parameters");
		return;
	}

	if (id == NULL) {
		return;
	}

	w = spdk_jsonrpc_begin_result(conn, id);
	spdk_json_write_array_begin(w);

	for (bdev = spdk_bdev_first(); bdev != NULL; bdev = spdk_bdev_next(bdev)) {
		spdk_json_write_object_begin(w);

		spdk_json_write_name(w, "name");
		spdk_json_write_string(w, bdev->name);

		spdk_json_write_name(w, "product_name");
		spdk_json_write_string(w, bdev->product_name);

		spdk_json_write_name(w, "block_size");
		spdk_json_write_uint32(w, bdev->blocklen);

		spdk_json_write_name(w, "num_blocks");
		spdk_json_write_uint64(w, bdev->blockcnt);

		spdk_json_write_name(w, "claimed");
		spdk_json_write_bool(w, bdev->claimed);

		spdk_json_write_name(w, "driver_specific");
		spdk_json_write_object_begin(w);
		spdk_bdev_dump_config_json(bdev, w);
		spdk_json_write_object_end(w);

		spdk_json_write_object_end(w);
	}
	spdk_json_write_array_end(w);

	spdk_jsonrpc_end_result(conn, w);
}