Commit 9ed6bedd authored by Maciej Szwed's avatar Maciej Szwed Committed by Ben Walker
Browse files

lvol: enable creation of thin provisioned lvols



Signed-off-by: default avatarMaciej Szwed <maciej.szwed@intel.com>
Change-Id: Ie6a651d0238d09729e28d5456a84ba090faeb465
Reviewed-on: https://review.gerrithub.io/391568


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 9103821d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -143,12 +143,13 @@ int spdk_lvs_destroy(struct spdk_lvol_store *lvol_store,
 * \param lvs Handle to lvolstore
 * \param name Name of lvol
 * \param sz size of lvol in bytes
 * \param thin_provisioned Enables thin provisioning
 * \param cb_fn Completion callback
 * \param cb_arg Completion callback custom arguments
 * \return error
 */
int spdk_lvol_create(struct spdk_lvol_store *lvs, const char *name, uint64_t sz,
		     spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg);
		     bool thin_provisioned, spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg);

/**
 * \brief Closes lvol and removes information about lvol from its lvolstore.
+2 −2
Original line number Diff line number Diff line
@@ -725,7 +725,7 @@ end:

int
vbdev_lvol_create(struct spdk_lvol_store *lvs, const char *name, size_t sz,
		  spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
		  bool thin_provision, spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
{
	struct spdk_lvol_with_handle_req *req;
	int rc;
@@ -737,7 +737,7 @@ vbdev_lvol_create(struct spdk_lvol_store *lvs, const char *name, size_t sz,
	req->cb_fn = cb_fn;
	req->cb_arg = cb_arg;

	rc = spdk_lvol_create(lvs, name, sz, _vbdev_lvol_create_cb, req);
	rc = spdk_lvol_create(lvs, name, sz, thin_provision, _vbdev_lvol_create_cb, req);
	if (rc != 0) {
		free(req);
	}
+1 −2
Original line number Diff line number Diff line
@@ -53,8 +53,7 @@ void vbdev_lvs_destruct(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn,
void vbdev_lvs_unload(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void *cb_arg);

int vbdev_lvol_create(struct spdk_lvol_store *lvs, const char *name, size_t sz,
		      spdk_lvol_op_with_handle_complete cb_fn,
		      void *cb_arg);
		      bool thin_provisioned, spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg);

int vbdev_lvol_resize(char *name, size_t sz, spdk_lvol_op_complete cb_fn, void *cb_arg);

+4 −1
Original line number Diff line number Diff line
@@ -248,6 +248,7 @@ struct rpc_construct_lvol_bdev {
	char *lvs_name;
	char *lvol_name;
	uint64_t size;
	bool thin_provision;
};

static void
@@ -263,6 +264,7 @@ static const struct spdk_json_object_decoder rpc_construct_lvol_bdev_decoders[]
	{"lvs_name", offsetof(struct rpc_construct_lvol_bdev, lvs_name), spdk_json_decode_string, true},
	{"lvol_name", offsetof(struct rpc_construct_lvol_bdev, lvol_name), spdk_json_decode_string, true},
	{"size", offsetof(struct rpc_construct_lvol_bdev, size), spdk_json_decode_uint64},
	{"thin_provision", offsetof(struct rpc_construct_lvol_bdev, thin_provision), spdk_json_decode_bool, true},
};

static void
@@ -323,7 +325,8 @@ spdk_rpc_construct_lvol_bdev(struct spdk_jsonrpc_request *request,

	sz = (size_t)req.size;

	rc = vbdev_lvol_create(lvs, req.lvol_name, sz, _spdk_rpc_construct_lvol_bdev_cb, request);
	rc = vbdev_lvol_create(lvs, req.lvol_name, sz, req.thin_provision,
			       _spdk_rpc_construct_lvol_bdev_cb, request);
	if (rc < 0) {
		goto invalid;
	}
+6 −2
Original line number Diff line number Diff line
@@ -936,11 +936,12 @@ _spdk_lvol_create_cb(void *cb_arg, spdk_blob_id blobid, int lvolerrno)

int
spdk_lvol_create(struct spdk_lvol_store *lvs, const char *name, uint64_t sz,
		 spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
		 bool thin_provision, spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg)
{
	struct spdk_lvol_with_handle_req *req;
	struct spdk_blob_store *bs;
	struct spdk_lvol *lvol, *tmp;
	struct spdk_blob_opts opts;
	uint64_t num_clusters, free_clusters;

	if (lvs == NULL) {
@@ -996,7 +997,10 @@ spdk_lvol_create(struct spdk_lvol_store *lvs, const char *name, uint64_t sz,
	strncpy(lvol->name, name, SPDK_LVS_NAME_MAX);
	req->lvol = lvol;

	spdk_bs_create_blob(lvs->blobstore, _spdk_lvol_create_cb, req);
	spdk_blob_opts_init(&opts);
	opts.thin_provision = thin_provision;

	spdk_bs_create_blob_ext(lvs->blobstore, &opts, _spdk_lvol_create_cb, req);

	return 0;
}
Loading