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: Denis Barakhtanov <denis.barahtanov@croit.io>
Change-Id: Ia48681832458c2266eb7c3bcae0df2055e59e309
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15006
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Denis Barakhtanov 2022-10-17 16:25:01 +11:00 committed by Tomasz Zawadzki
parent 03b1b86078
commit 3d7851e011
6 changed files with 30 additions and 7 deletions

View File

@ -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",

View File

@ -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");

View File

@ -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);

View File

@ -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));

View File

@ -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)

View File

@ -3083,7 +3083,8 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
name=args.name,
uuid=args.uuid,
pool=args.pool,
cont=args.cont))
cont=args.cont,
oclass=args.oclass))
p = subparsers.add_parser('bdev_daos_create',
help='Create a bdev with DAOS backend')
p.add_argument('name', help="Name of the bdev")
@ -3093,6 +3094,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
'total_size', help='Size of DAOS bdev in MB (float > 0)', type=float)
p.add_argument('block_size', help='Block size for this bdev', type=int)
p.add_argument('-u', '--uuid', help="UUID of the bdev")
p.add_argument('-o', '--oclass', help="DAOS object class")
p.set_defaults(func=bdev_daos_create)
def bdev_daos_delete(args):