Commit 3d7851e0 authored by Denis Barakhtanov's avatar Denis Barakhtanov Committed by Tomasz Zawadzki
Browse files

bdev/daos: Add object class parameter

A new `oclass` parameter allow to specify DAOS DFS object class that is
responsible for data redundancy and protection.

Examples of the object classes could be found here: https://github.com/daos-stack/daos/blob/master/src/include/daos_obj_class.h



The default value is OC_SX for the max IOPS.

Signed-off-by: default avatarDenis Barakhtanov <denis.barahtanov@croit.io>
Change-Id: Ia48681832458c2266eb7c3bcae0df2055e59e309
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15006


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 03b1b860
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -10716,6 +10716,11 @@ cont | Required | string | DAOS cont label or its uuid
block_size              | Required | number      | Block size in bytes -must be multiple of 512
num_blocks              | Required | number      | Number of blocks
uuid                    | Optional | string      | UUID of new bdev
oclass                  | Optional | string      | DAOS object class (default SX)

To find more about various object classes please visit [DAOS documentation](https://github.com/daos-stack/daos/blob/master/src/object/README.md).
Please note, that DAOS bdev module uses the same CLI flag notation as `dmg` and `daos` commmands,
for instance, `SX` or `EC_4P2G2` rather than in DAOS header file `OC_SX` or `OC_EC_4P2G2`.

#### Result

@@ -10733,6 +10738,7 @@ Example request:
    "name": "daosdev0",
    "pool": "test-pool",
    "cont": "test-cont",
    "oclass": "EC_4P2G2"
  },
  "jsonrpc": "2.0",
  "method": "bdev_daos_create",
+13 −3
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ struct bdev_daos_task {

struct bdev_daos {
	struct spdk_bdev disk;
	daos_oclass_id_t oclass;

	char pool_name[DAOS_PROP_MAX_LABEL_BUF_LEN];
	char cont_name[DAOS_PROP_MAX_LABEL_BUF_LEN];
@@ -519,7 +520,6 @@ _bdev_daos_io_channel_create_cb(void *ctx)

	daos_pool_info_t pinfo;
	daos_cont_info_t cinfo;
	daos_oclass_id_t obj_class = OC_SX;

	int fd_oflag = O_CREAT | O_RDWR;
	mode_t mode = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;
@@ -549,7 +549,7 @@ _bdev_daos_io_channel_create_cb(void *ctx)
		goto cleanup_cont;
	}
	SPDK_DEBUGLOG(bdev_daos, "opening dfs object\n");
	if ((rc = dfs_open(ch->dfs, NULL, daos->disk.name, mode, fd_oflag, obj_class,
	if ((rc = dfs_open(ch->dfs, NULL, daos->disk.name, mode, fd_oflag, daos->oclass,
			   0, NULL, &ch->obj))) {
		SPDK_ERRLOG("%s: could not open dfs object: " DF_RC "\n",
			    daos->disk.name, DP_RC(rc));
@@ -628,7 +628,7 @@ bdev_daos_io_channel_destroy_cb(void *io_device, void *ctx_buf)
int
create_bdev_daos(struct spdk_bdev **bdev,
		 const char *name, const struct spdk_uuid *uuid,
		 const char *pool, const char *cont,
		 const char *pool, const char *cont, const char *oclass,
		 uint64_t num_blocks, uint32_t block_size)
{
	int rc;
@@ -667,6 +667,16 @@ create_bdev_daos(struct spdk_bdev **bdev,
		return -ENOMEM;
	}

	if (!oclass) {
		oclass = "SX"; /* Max throughput by default */
	}
	daos->oclass = daos_oclass_name2id(oclass);
	if (daos->oclass == OC_UNKNOWN) {
		SPDK_ERRLOG("could not parse daos oclass: '%s'\n", oclass);
		free(daos);
		return -EINVAL;
	}

	len = strlen(pool);
	if (len > DAOS_PROP_LABEL_MAX_LEN) {
		SPDK_ERRLOG("daos pool name is too long\n");
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
typedef void (*spdk_delete_daos_complete)(void *cb_arg, int bdeverrno);

int create_bdev_daos(struct spdk_bdev **bdev, const char *name, const struct spdk_uuid *uuid,
		     const char *pool, const char *cont,
		     const char *pool, const char *cont, const char *oclass,
		     uint64_t num_blocks, uint32_t block_size);

void delete_bdev_daos(struct spdk_bdev *bdev, spdk_delete_daos_complete cb_fn, void *cb_arg);
+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ struct rpc_construct_daos {
	char *uuid;
	char *pool;
	char *cont;
	char *oclass;
	uint64_t num_blocks;
	uint32_t block_size;
};
@@ -35,6 +36,7 @@ static const struct spdk_json_object_decoder rpc_construct_daos_decoders[] = {
	{"uuid", offsetof(struct rpc_construct_daos, uuid), spdk_json_decode_string, true},
	{"pool", offsetof(struct rpc_construct_daos, pool), spdk_json_decode_string},
	{"cont", offsetof(struct rpc_construct_daos, cont), spdk_json_decode_string},
	{"oclass", offsetof(struct rpc_construct_daos, oclass), spdk_json_decode_string, true},
	{"num_blocks", offsetof(struct rpc_construct_daos, num_blocks), spdk_json_decode_uint64},
	{"block_size", offsetof(struct rpc_construct_daos, block_size), spdk_json_decode_uint32},
};
@@ -68,7 +70,7 @@ rpc_bdev_daos_create(struct spdk_jsonrpc_request *request,
		uuid = &decoded_uuid;
	}

	rc = create_bdev_daos(&bdev, req.name, uuid, req.pool, req.cont,
	rc = create_bdev_daos(&bdev, req.name, uuid, req.pool, req.cont, req.oclass,
			      req.num_blocks, req.block_size);
	if (rc) {
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
+4 −1
Original line number Diff line number Diff line
@@ -1585,7 +1585,7 @@ def bdev_nvme_get_controller_health_info(client, name):
    return client.call('bdev_nvme_get_controller_health_info', params)


def bdev_daos_create(client, num_blocks, block_size, pool, cont, name, uuid=None):
def bdev_daos_create(client, num_blocks, block_size, pool, cont, name, oclass=None, uuid=None):
    """Construct DAOS block device.

    Args:
@@ -1595,6 +1595,7 @@ def bdev_daos_create(client, num_blocks, block_size, pool, cont, name, uuid=None
        pool: UUID of DAOS pool
        cont: UUID of DAOS container
        uuid: UUID of block device (optional)
        oclass: DAOS object class (optional)

    Returns:
        Name of created block device.
@@ -1602,6 +1603,8 @@ def bdev_daos_create(client, num_blocks, block_size, pool, cont, name, uuid=None
    params = {'num_blocks': num_blocks, 'block_size': block_size, 'pool': pool, 'cont': cont, 'name': name}
    if uuid:
        params['uuid'] = uuid
    if oclass:
        params['oclass'] = oclass
    return client.call('bdev_daos_create', params)


Loading