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:
parent
03b1b86078
commit
3d7851e011
@ -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
|
block_size | Required | number | Block size in bytes -must be multiple of 512
|
||||||
num_blocks | Required | number | Number of blocks
|
num_blocks | Required | number | Number of blocks
|
||||||
uuid | Optional | string | UUID of new bdev
|
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
|
#### Result
|
||||||
|
|
||||||
@ -10733,6 +10738,7 @@ Example request:
|
|||||||
"name": "daosdev0",
|
"name": "daosdev0",
|
||||||
"pool": "test-pool",
|
"pool": "test-pool",
|
||||||
"cont": "test-cont",
|
"cont": "test-cont",
|
||||||
|
"oclass": "EC_4P2G2"
|
||||||
},
|
},
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"method": "bdev_daos_create",
|
"method": "bdev_daos_create",
|
||||||
|
@ -47,6 +47,7 @@ struct bdev_daos_task {
|
|||||||
|
|
||||||
struct bdev_daos {
|
struct bdev_daos {
|
||||||
struct spdk_bdev disk;
|
struct spdk_bdev disk;
|
||||||
|
daos_oclass_id_t oclass;
|
||||||
|
|
||||||
char pool_name[DAOS_PROP_MAX_LABEL_BUF_LEN];
|
char pool_name[DAOS_PROP_MAX_LABEL_BUF_LEN];
|
||||||
char cont_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_pool_info_t pinfo;
|
||||||
daos_cont_info_t cinfo;
|
daos_cont_info_t cinfo;
|
||||||
daos_oclass_id_t obj_class = OC_SX;
|
|
||||||
|
|
||||||
int fd_oflag = O_CREAT | O_RDWR;
|
int fd_oflag = O_CREAT | O_RDWR;
|
||||||
mode_t mode = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;
|
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;
|
goto cleanup_cont;
|
||||||
}
|
}
|
||||||
SPDK_DEBUGLOG(bdev_daos, "opening dfs object\n");
|
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))) {
|
0, NULL, &ch->obj))) {
|
||||||
SPDK_ERRLOG("%s: could not open dfs object: " DF_RC "\n",
|
SPDK_ERRLOG("%s: could not open dfs object: " DF_RC "\n",
|
||||||
daos->disk.name, DP_RC(rc));
|
daos->disk.name, DP_RC(rc));
|
||||||
@ -628,7 +628,7 @@ bdev_daos_io_channel_destroy_cb(void *io_device, void *ctx_buf)
|
|||||||
int
|
int
|
||||||
create_bdev_daos(struct spdk_bdev **bdev,
|
create_bdev_daos(struct spdk_bdev **bdev,
|
||||||
const char *name, const struct spdk_uuid *uuid,
|
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)
|
uint64_t num_blocks, uint32_t block_size)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
@ -667,6 +667,16 @@ create_bdev_daos(struct spdk_bdev **bdev,
|
|||||||
return -ENOMEM;
|
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);
|
len = strlen(pool);
|
||||||
if (len > DAOS_PROP_LABEL_MAX_LEN) {
|
if (len > DAOS_PROP_LABEL_MAX_LEN) {
|
||||||
SPDK_ERRLOG("daos pool name is too long\n");
|
SPDK_ERRLOG("daos pool name is too long\n");
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
typedef void (*spdk_delete_daos_complete)(void *cb_arg, int bdeverrno);
|
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,
|
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);
|
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);
|
void delete_bdev_daos(struct spdk_bdev *bdev, spdk_delete_daos_complete cb_fn, void *cb_arg);
|
||||||
|
@ -17,6 +17,7 @@ struct rpc_construct_daos {
|
|||||||
char *uuid;
|
char *uuid;
|
||||||
char *pool;
|
char *pool;
|
||||||
char *cont;
|
char *cont;
|
||||||
|
char *oclass;
|
||||||
uint64_t num_blocks;
|
uint64_t num_blocks;
|
||||||
uint32_t block_size;
|
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},
|
{"uuid", offsetof(struct rpc_construct_daos, uuid), spdk_json_decode_string, true},
|
||||||
{"pool", offsetof(struct rpc_construct_daos, pool), spdk_json_decode_string},
|
{"pool", offsetof(struct rpc_construct_daos, pool), spdk_json_decode_string},
|
||||||
{"cont", offsetof(struct rpc_construct_daos, cont), 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},
|
{"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},
|
{"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;
|
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);
|
req.num_blocks, req.block_size);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
|
spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
|
||||||
|
@ -1585,7 +1585,7 @@ def bdev_nvme_get_controller_health_info(client, name):
|
|||||||
return client.call('bdev_nvme_get_controller_health_info', params)
|
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.
|
"""Construct DAOS block device.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -1595,6 +1595,7 @@ def bdev_daos_create(client, num_blocks, block_size, pool, cont, name, uuid=None
|
|||||||
pool: UUID of DAOS pool
|
pool: UUID of DAOS pool
|
||||||
cont: UUID of DAOS container
|
cont: UUID of DAOS container
|
||||||
uuid: UUID of block device (optional)
|
uuid: UUID of block device (optional)
|
||||||
|
oclass: DAOS object class (optional)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Name of created block device.
|
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}
|
params = {'num_blocks': num_blocks, 'block_size': block_size, 'pool': pool, 'cont': cont, 'name': name}
|
||||||
if uuid:
|
if uuid:
|
||||||
params['uuid'] = uuid
|
params['uuid'] = uuid
|
||||||
|
if oclass:
|
||||||
|
params['oclass'] = oclass
|
||||||
return client.call('bdev_daos_create', params)
|
return client.call('bdev_daos_create', params)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3083,7 +3083,8 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
|||||||
name=args.name,
|
name=args.name,
|
||||||
uuid=args.uuid,
|
uuid=args.uuid,
|
||||||
pool=args.pool,
|
pool=args.pool,
|
||||||
cont=args.cont))
|
cont=args.cont,
|
||||||
|
oclass=args.oclass))
|
||||||
p = subparsers.add_parser('bdev_daos_create',
|
p = subparsers.add_parser('bdev_daos_create',
|
||||||
help='Create a bdev with DAOS backend')
|
help='Create a bdev with DAOS backend')
|
||||||
p.add_argument('name', help="Name of the bdev")
|
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)
|
'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('block_size', help='Block size for this bdev', type=int)
|
||||||
p.add_argument('-u', '--uuid', help="UUID of the bdev")
|
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)
|
p.set_defaults(func=bdev_daos_create)
|
||||||
|
|
||||||
def bdev_daos_delete(args):
|
def bdev_daos_delete(args):
|
||||||
|
Loading…
Reference in New Issue
Block a user