blob: decouple spdk_blob from its actual data
Moving forward, the spdk_blob returned to users will actually be an I/O channel - not the blob structure itself. So rename the existing spdk_blob to spdk_blob_data. spdk_blob_data will continue to contain global state for the blob. In the future spdk_blob will point to an I/O channel for the blob - for now it effectively still points to the spdk_blob_data, but by changing the structure names here it will reduce the code churn in future patches. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I7d0cbc0553f68f96c24173c833091a80d058eb89 Reviewed-on: https://review.gerrithub.io/390900 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
99a1020f0a
commit
b9b0fee224
@ -465,7 +465,7 @@ show_blob(struct cli_context_t *cli_context)
|
||||
* may be useful for debug of blobstore based applications.
|
||||
*/
|
||||
printf("\nBlob Private Info:\n");
|
||||
switch (cli_context->blob->state) {
|
||||
switch (__blob_to_data(cli_context->blob)->state) {
|
||||
case SPDK_BLOB_STATE_DIRTY:
|
||||
printf("state: DIRTY\n");
|
||||
break;
|
||||
@ -483,7 +483,7 @@ show_blob(struct cli_context_t *cli_context)
|
||||
break;
|
||||
}
|
||||
printf("open ref count: %d\n",
|
||||
cli_context->blob->open_ref);
|
||||
__blob_to_data(cli_context->blob)->open_ref);
|
||||
|
||||
spdk_xattr_names_free(names);
|
||||
}
|
||||
|
@ -79,10 +79,10 @@ _spdk_bs_release_cluster(struct spdk_blob_store *bs, uint32_t cluster_num)
|
||||
bs->num_free_clusters++;
|
||||
}
|
||||
|
||||
static struct spdk_blob *
|
||||
static struct spdk_blob_data *
|
||||
_spdk_blob_alloc(struct spdk_blob_store *bs, spdk_blob_id id)
|
||||
{
|
||||
struct spdk_blob *blob;
|
||||
struct spdk_blob_data *blob;
|
||||
|
||||
blob = calloc(1, sizeof(*blob));
|
||||
if (!blob) {
|
||||
@ -108,7 +108,7 @@ _spdk_blob_alloc(struct spdk_blob_store *bs, spdk_blob_id id)
|
||||
}
|
||||
|
||||
static void
|
||||
_spdk_blob_free(struct spdk_blob *blob)
|
||||
_spdk_blob_free(struct spdk_blob_data *blob)
|
||||
{
|
||||
struct spdk_xattr *xattr, *xattr_tmp;
|
||||
|
||||
@ -130,7 +130,7 @@ _spdk_blob_free(struct spdk_blob *blob)
|
||||
}
|
||||
|
||||
static int
|
||||
_spdk_blob_mark_clean(struct spdk_blob *blob)
|
||||
_spdk_blob_mark_clean(struct spdk_blob_data *blob)
|
||||
{
|
||||
uint64_t *clusters = NULL;
|
||||
uint32_t *pages = NULL;
|
||||
@ -175,7 +175,7 @@ _spdk_blob_mark_clean(struct spdk_blob *blob)
|
||||
}
|
||||
|
||||
static int
|
||||
_spdk_blob_parse_page(const struct spdk_blob_md_page *page, struct spdk_blob *blob)
|
||||
_spdk_blob_parse_page(const struct spdk_blob_md_page *page, struct spdk_blob_data *blob)
|
||||
{
|
||||
struct spdk_blob_md_descriptor *desc;
|
||||
size_t cur_desc = 0;
|
||||
@ -315,7 +315,7 @@ _spdk_blob_parse_page(const struct spdk_blob_md_page *page, struct spdk_blob *bl
|
||||
|
||||
static int
|
||||
_spdk_blob_parse(const struct spdk_blob_md_page *pages, uint32_t page_count,
|
||||
struct spdk_blob *blob)
|
||||
struct spdk_blob_data *blob)
|
||||
{
|
||||
const struct spdk_blob_md_page *page;
|
||||
uint32_t i;
|
||||
@ -353,7 +353,7 @@ _spdk_blob_parse(const struct spdk_blob_md_page *pages, uint32_t page_count,
|
||||
}
|
||||
|
||||
static int
|
||||
_spdk_blob_serialize_add_page(const struct spdk_blob *blob,
|
||||
_spdk_blob_serialize_add_page(const struct spdk_blob_data *blob,
|
||||
struct spdk_blob_md_page **pages,
|
||||
uint32_t *page_count,
|
||||
struct spdk_blob_md_page **last_page)
|
||||
@ -432,7 +432,7 @@ _spdk_blob_serialize_xattr(const struct spdk_xattr *xattr,
|
||||
}
|
||||
|
||||
static void
|
||||
_spdk_blob_serialize_extent(const struct spdk_blob *blob,
|
||||
_spdk_blob_serialize_extent(const struct spdk_blob_data *blob,
|
||||
uint64_t start_cluster, uint64_t *next_cluster,
|
||||
uint8_t *buf, size_t buf_sz)
|
||||
{
|
||||
@ -489,7 +489,7 @@ _spdk_blob_serialize_extent(const struct spdk_blob *blob,
|
||||
}
|
||||
|
||||
static void
|
||||
_spdk_blob_serialize_flags(const struct spdk_blob *blob,
|
||||
_spdk_blob_serialize_flags(const struct spdk_blob_data *blob,
|
||||
uint8_t *buf, size_t *buf_sz)
|
||||
{
|
||||
struct spdk_blob_md_descriptor_flags *desc;
|
||||
@ -511,7 +511,7 @@ _spdk_blob_serialize_flags(const struct spdk_blob *blob,
|
||||
}
|
||||
|
||||
static int
|
||||
_spdk_blob_serialize(const struct spdk_blob *blob, struct spdk_blob_md_page **pages,
|
||||
_spdk_blob_serialize(const struct spdk_blob_data *blob, struct spdk_blob_md_page **pages,
|
||||
uint32_t *page_count)
|
||||
{
|
||||
struct spdk_blob_md_page *cur_page;
|
||||
@ -603,7 +603,7 @@ _spdk_blob_serialize(const struct spdk_blob *blob, struct spdk_blob_md_page **pa
|
||||
}
|
||||
|
||||
struct spdk_blob_load_ctx {
|
||||
struct spdk_blob *blob;
|
||||
struct spdk_blob_data *blob;
|
||||
|
||||
struct spdk_blob_md_page *pages;
|
||||
uint32_t num_pages;
|
||||
@ -629,7 +629,7 @@ static void
|
||||
_spdk_blob_load_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob_load_ctx *ctx = cb_arg;
|
||||
struct spdk_blob *blob = ctx->blob;
|
||||
struct spdk_blob_data *blob = ctx->blob;
|
||||
struct spdk_blob_md_page *page;
|
||||
int rc;
|
||||
uint32_t crc;
|
||||
@ -690,7 +690,7 @@ _spdk_blob_load_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
|
||||
/* Load a blob from disk given a blobid */
|
||||
static void
|
||||
_spdk_blob_load(spdk_bs_sequence_t *seq, struct spdk_blob *blob,
|
||||
_spdk_blob_load(spdk_bs_sequence_t *seq, struct spdk_blob_data *blob,
|
||||
spdk_bs_sequence_cpl cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_blob_load_ctx *ctx;
|
||||
@ -733,7 +733,7 @@ _spdk_blob_load(spdk_bs_sequence_t *seq, struct spdk_blob *blob,
|
||||
}
|
||||
|
||||
struct spdk_blob_persist_ctx {
|
||||
struct spdk_blob *blob;
|
||||
struct spdk_blob_data *blob;
|
||||
|
||||
struct spdk_blob_md_page *pages;
|
||||
|
||||
@ -747,7 +747,7 @@ static void
|
||||
_spdk_blob_persist_complete(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob_persist_ctx *ctx = cb_arg;
|
||||
struct spdk_blob *blob = ctx->blob;
|
||||
struct spdk_blob_data *blob = ctx->blob;
|
||||
|
||||
if (bserrno == 0) {
|
||||
_spdk_blob_mark_clean(blob);
|
||||
@ -765,7 +765,7 @@ static void
|
||||
_spdk_blob_persist_unmap_clusters_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob_persist_ctx *ctx = cb_arg;
|
||||
struct spdk_blob *blob = ctx->blob;
|
||||
struct spdk_blob_data *blob = ctx->blob;
|
||||
struct spdk_blob_store *bs = blob->bs;
|
||||
void *tmp;
|
||||
size_t i;
|
||||
@ -795,7 +795,7 @@ static void
|
||||
_spdk_blob_persist_unmap_clusters(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob_persist_ctx *ctx = cb_arg;
|
||||
struct spdk_blob *blob = ctx->blob;
|
||||
struct spdk_blob_data *blob = ctx->blob;
|
||||
struct spdk_blob_store *bs = blob->bs;
|
||||
spdk_bs_batch_t *batch;
|
||||
size_t i;
|
||||
@ -847,7 +847,7 @@ static void
|
||||
_spdk_blob_persist_zero_pages_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob_persist_ctx *ctx = cb_arg;
|
||||
struct spdk_blob *blob = ctx->blob;
|
||||
struct spdk_blob_data *blob = ctx->blob;
|
||||
struct spdk_blob_store *bs = blob->bs;
|
||||
size_t i;
|
||||
|
||||
@ -874,7 +874,7 @@ static void
|
||||
_spdk_blob_persist_zero_pages(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob_persist_ctx *ctx = cb_arg;
|
||||
struct spdk_blob *blob = ctx->blob;
|
||||
struct spdk_blob_data *blob = ctx->blob;
|
||||
struct spdk_blob_store *bs = blob->bs;
|
||||
uint64_t lba;
|
||||
uint32_t lba_count;
|
||||
@ -913,7 +913,7 @@ static void
|
||||
_spdk_blob_persist_write_page_root(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob_persist_ctx *ctx = cb_arg;
|
||||
struct spdk_blob *blob = ctx->blob;
|
||||
struct spdk_blob_data *blob = ctx->blob;
|
||||
struct spdk_blob_store *bs = blob->bs;
|
||||
uint64_t lba;
|
||||
uint32_t lba_count;
|
||||
@ -939,7 +939,7 @@ static void
|
||||
_spdk_blob_persist_write_page_chain(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob_persist_ctx *ctx = cb_arg;
|
||||
struct spdk_blob *blob = ctx->blob;
|
||||
struct spdk_blob_data *blob = ctx->blob;
|
||||
struct spdk_blob_store *bs = blob->bs;
|
||||
uint64_t lba;
|
||||
uint32_t lba_count;
|
||||
@ -971,7 +971,7 @@ _spdk_blob_persist_write_page_chain(spdk_bs_sequence_t *seq, void *cb_arg, int b
|
||||
}
|
||||
|
||||
static int
|
||||
_spdk_resize_blob(struct spdk_blob *blob, uint64_t sz)
|
||||
_spdk_resize_blob(struct spdk_blob_data *blob, uint64_t sz)
|
||||
{
|
||||
uint64_t i;
|
||||
uint64_t *tmp;
|
||||
@ -1042,7 +1042,7 @@ _spdk_resize_blob(struct spdk_blob *blob, uint64_t sz)
|
||||
|
||||
/* Write a blob to disk */
|
||||
static void
|
||||
_spdk_blob_persist(spdk_bs_sequence_t *seq, struct spdk_blob *blob,
|
||||
_spdk_blob_persist(spdk_bs_sequence_t *seq, struct spdk_blob_data *blob,
|
||||
spdk_bs_sequence_cpl cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_blob_persist_ctx *ctx;
|
||||
@ -1138,10 +1138,11 @@ _spdk_blob_persist(spdk_bs_sequence_t *seq, struct spdk_blob *blob,
|
||||
}
|
||||
|
||||
static void
|
||||
_spdk_blob_request_submit_op(struct spdk_blob *blob, struct spdk_io_channel *_channel,
|
||||
_spdk_blob_request_submit_op(struct spdk_blob *_blob, struct spdk_io_channel *_channel,
|
||||
void *payload, uint64_t offset, uint64_t length,
|
||||
spdk_blob_op_complete cb_fn, void *cb_arg, enum spdk_blob_op_type op_type)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
spdk_bs_batch_t *batch;
|
||||
struct spdk_bs_cpl cpl;
|
||||
uint64_t lba;
|
||||
@ -1206,7 +1207,7 @@ _spdk_blob_request_submit_op(struct spdk_blob *blob, struct spdk_io_channel *_ch
|
||||
}
|
||||
|
||||
struct rw_iov_ctx {
|
||||
struct spdk_blob *blob;
|
||||
struct spdk_blob_data *blob;
|
||||
bool read;
|
||||
int iovcnt;
|
||||
struct iovec *orig_iov;
|
||||
@ -1294,10 +1295,11 @@ _spdk_rw_iov_split_next(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
}
|
||||
|
||||
static void
|
||||
_spdk_blob_request_submit_rw_iov(struct spdk_blob *blob, struct spdk_io_channel *_channel,
|
||||
_spdk_blob_request_submit_rw_iov(struct spdk_blob *_blob, struct spdk_io_channel *_channel,
|
||||
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length,
|
||||
spdk_blob_op_complete cb_fn, void *cb_arg, bool read)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
spdk_bs_sequence_t *seq;
|
||||
struct spdk_bs_cpl cpl;
|
||||
|
||||
@ -1372,10 +1374,10 @@ _spdk_blob_request_submit_rw_iov(struct spdk_blob *blob, struct spdk_io_channel
|
||||
}
|
||||
}
|
||||
|
||||
static struct spdk_blob *
|
||||
static struct spdk_blob_data *
|
||||
_spdk_blob_lookup(struct spdk_blob_store *bs, spdk_blob_id blobid)
|
||||
{
|
||||
struct spdk_blob *blob;
|
||||
struct spdk_blob_data *blob;
|
||||
|
||||
TAILQ_FOREACH(blob, &bs->blobs, link) {
|
||||
if (blob->id == blobid) {
|
||||
@ -1455,7 +1457,7 @@ static void
|
||||
_spdk_bs_dev_destroy(void *io_device)
|
||||
{
|
||||
struct spdk_blob_store *bs;
|
||||
struct spdk_blob *blob, *blob_tmp;
|
||||
struct spdk_blob_data *blob, *blob_tmp;
|
||||
|
||||
bs = SPDK_CONTAINEROF(io_device, struct spdk_blob_store, md_target);
|
||||
bs->dev->destroy(bs->dev);
|
||||
@ -2548,22 +2550,28 @@ int spdk_bs_unregister_md_thread(struct spdk_blob_store *bs)
|
||||
return 0;
|
||||
}
|
||||
|
||||
spdk_blob_id spdk_blob_get_id(struct spdk_blob *blob)
|
||||
spdk_blob_id spdk_blob_get_id(struct spdk_blob *_blob)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
|
||||
assert(blob != NULL);
|
||||
|
||||
return blob->id;
|
||||
}
|
||||
|
||||
uint64_t spdk_blob_get_num_pages(struct spdk_blob *blob)
|
||||
uint64_t spdk_blob_get_num_pages(struct spdk_blob *_blob)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
|
||||
assert(blob != NULL);
|
||||
|
||||
return _spdk_bs_cluster_to_page(blob->bs, blob->active.num_clusters);
|
||||
}
|
||||
|
||||
uint64_t spdk_blob_get_num_clusters(struct spdk_blob *blob)
|
||||
uint64_t spdk_blob_get_num_clusters(struct spdk_blob *_blob)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
|
||||
assert(blob != NULL);
|
||||
|
||||
return blob->active.num_clusters;
|
||||
@ -2574,7 +2582,7 @@ uint64_t spdk_blob_get_num_clusters(struct spdk_blob *blob)
|
||||
static void
|
||||
_spdk_bs_md_create_blob_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob *blob = cb_arg;
|
||||
struct spdk_blob_data *blob = cb_arg;
|
||||
|
||||
_spdk_blob_free(blob);
|
||||
|
||||
@ -2584,7 +2592,7 @@ _spdk_bs_md_create_blob_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
void spdk_bs_md_create_blob(struct spdk_blob_store *bs,
|
||||
spdk_blob_op_with_id_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_blob *blob;
|
||||
struct spdk_blob_data *blob;
|
||||
uint32_t page_idx;
|
||||
struct spdk_bs_cpl cpl;
|
||||
spdk_bs_sequence_t *seq;
|
||||
@ -2626,8 +2634,9 @@ void spdk_bs_md_create_blob(struct spdk_blob_store *bs,
|
||||
|
||||
/* START spdk_bs_md_resize_blob */
|
||||
int
|
||||
spdk_bs_md_resize_blob(struct spdk_blob *blob, uint64_t sz)
|
||||
spdk_bs_md_resize_blob(struct spdk_blob *_blob, uint64_t sz)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
int rc;
|
||||
|
||||
assert(blob != NULL);
|
||||
@ -2658,7 +2667,7 @@ spdk_bs_md_resize_blob(struct spdk_blob *blob, uint64_t sz)
|
||||
static void
|
||||
_spdk_bs_md_delete_blob_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob *blob = cb_arg;
|
||||
struct spdk_blob_data *blob = cb_arg;
|
||||
|
||||
_spdk_blob_free(blob);
|
||||
|
||||
@ -2668,7 +2677,7 @@ _spdk_bs_md_delete_blob_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
static void
|
||||
_spdk_bs_md_delete_open_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob *blob = cb_arg;
|
||||
struct spdk_blob_data *blob = cb_arg;
|
||||
|
||||
/* If the blob have crc error, we just return NULL. */
|
||||
if (blob == NULL) {
|
||||
@ -2686,7 +2695,7 @@ void
|
||||
spdk_bs_md_delete_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
|
||||
spdk_blob_op_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_blob *blob;
|
||||
struct spdk_blob_data *blob;
|
||||
struct spdk_bs_cpl cpl;
|
||||
spdk_bs_sequence_t *seq;
|
||||
|
||||
@ -2726,7 +2735,7 @@ spdk_bs_md_delete_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
|
||||
static void
|
||||
_spdk_bs_md_open_blob_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob *blob = cb_arg;
|
||||
struct spdk_blob_data *blob = cb_arg;
|
||||
|
||||
/* If the blob have crc error, we just return NULL. */
|
||||
if (blob == NULL) {
|
||||
@ -2745,7 +2754,7 @@ _spdk_bs_md_open_blob_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
void spdk_bs_md_open_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
|
||||
spdk_blob_op_with_handle_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_blob *blob;
|
||||
struct spdk_blob_data *blob;
|
||||
struct spdk_bs_cpl cpl;
|
||||
spdk_bs_sequence_t *seq;
|
||||
uint32_t page_num;
|
||||
@ -2755,7 +2764,7 @@ void spdk_bs_md_open_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
|
||||
blob = _spdk_blob_lookup(bs, blobid);
|
||||
if (blob) {
|
||||
blob->open_ref++;
|
||||
cb_fn(cb_arg, blob, 0);
|
||||
cb_fn(cb_arg, __data_to_blob(blob), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2775,7 +2784,7 @@ void spdk_bs_md_open_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
|
||||
cpl.type = SPDK_BS_CPL_TYPE_BLOB_HANDLE;
|
||||
cpl.u.blob_handle.cb_fn = cb_fn;
|
||||
cpl.u.blob_handle.cb_arg = cb_arg;
|
||||
cpl.u.blob_handle.blob = blob;
|
||||
cpl.u.blob_handle.blob = __data_to_blob(blob);
|
||||
|
||||
seq = spdk_bs_sequence_start(bs->md_target.md_channel, &cpl);
|
||||
if (!seq) {
|
||||
@ -2794,9 +2803,10 @@ _spdk_blob_sync_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
spdk_bs_sequence_finish(seq, bserrno);
|
||||
}
|
||||
|
||||
void spdk_bs_md_sync_blob(struct spdk_blob *blob,
|
||||
void spdk_bs_md_sync_blob(struct spdk_blob *_blob,
|
||||
spdk_blob_op_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
struct spdk_bs_cpl cpl;
|
||||
spdk_bs_sequence_t *seq;
|
||||
|
||||
@ -2837,7 +2847,7 @@ void spdk_bs_md_sync_blob(struct spdk_blob *blob,
|
||||
static void
|
||||
_spdk_blob_close_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_blob **blob = cb_arg;
|
||||
struct spdk_blob_data **blob = cb_arg;
|
||||
|
||||
if ((*blob)->open_ref == 0) {
|
||||
TAILQ_REMOVE(&(*blob)->bs->blobs, (*blob), link);
|
||||
@ -2853,11 +2863,11 @@ void spdk_bs_md_close_blob(struct spdk_blob **b,
|
||||
spdk_blob_op_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_bs_cpl cpl;
|
||||
struct spdk_blob *blob;
|
||||
struct spdk_blob_data *blob;
|
||||
spdk_bs_sequence_t *seq;
|
||||
|
||||
assert(b != NULL);
|
||||
blob = *b;
|
||||
blob = __blob_to_data(*b);
|
||||
assert(blob != NULL);
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_BLOB, "Closing blob %lu\n", blob->id);
|
||||
@ -2963,14 +2973,15 @@ struct spdk_bs_iter_ctx {
|
||||
};
|
||||
|
||||
static void
|
||||
_spdk_bs_iter_cpl(void *cb_arg, struct spdk_blob *blob, int bserrno)
|
||||
_spdk_bs_iter_cpl(void *cb_arg, struct spdk_blob *_blob, int bserrno)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
struct spdk_bs_iter_ctx *ctx = cb_arg;
|
||||
struct spdk_blob_store *bs = ctx->bs;
|
||||
spdk_blob_id id;
|
||||
|
||||
if (bserrno == 0) {
|
||||
ctx->cb_fn(ctx->cb_arg, blob, bserrno);
|
||||
ctx->cb_fn(ctx->cb_arg, _blob, bserrno);
|
||||
free(ctx);
|
||||
return;
|
||||
}
|
||||
@ -2988,7 +2999,7 @@ _spdk_bs_iter_cpl(void *cb_arg, struct spdk_blob *blob, int bserrno)
|
||||
blob = _spdk_blob_lookup(bs, id);
|
||||
if (blob) {
|
||||
blob->open_ref++;
|
||||
ctx->cb_fn(ctx->cb_arg, blob, 0);
|
||||
ctx->cb_fn(ctx->cb_arg, _blob, 0);
|
||||
free(ctx);
|
||||
return;
|
||||
}
|
||||
@ -3029,10 +3040,10 @@ spdk_bs_md_iter_next(struct spdk_blob_store *bs, struct spdk_blob **b,
|
||||
spdk_blob_op_with_handle_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_bs_iter_ctx *ctx;
|
||||
struct spdk_blob *blob;
|
||||
struct spdk_blob_data *blob;
|
||||
|
||||
assert(b != NULL);
|
||||
blob = *b;
|
||||
blob = __blob_to_data(*b);
|
||||
assert(blob != NULL);
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
@ -3051,9 +3062,10 @@ spdk_bs_md_iter_next(struct spdk_blob_store *bs, struct spdk_blob **b,
|
||||
}
|
||||
|
||||
int
|
||||
spdk_blob_md_set_xattr(struct spdk_blob *blob, const char *name, const void *value,
|
||||
spdk_blob_md_set_xattr(struct spdk_blob *_blob, const char *name, const void *value,
|
||||
uint16_t value_len)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
struct spdk_xattr *xattr;
|
||||
|
||||
assert(blob != NULL);
|
||||
@ -3094,8 +3106,9 @@ spdk_blob_md_set_xattr(struct spdk_blob *blob, const char *name, const void *val
|
||||
}
|
||||
|
||||
int
|
||||
spdk_blob_md_remove_xattr(struct spdk_blob *blob, const char *name)
|
||||
spdk_blob_md_remove_xattr(struct spdk_blob *_blob, const char *name)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
struct spdk_xattr *xattr;
|
||||
|
||||
assert(blob != NULL);
|
||||
@ -3124,9 +3137,10 @@ spdk_blob_md_remove_xattr(struct spdk_blob *blob, const char *name)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_bs_md_get_xattr_value(struct spdk_blob *blob, const char *name,
|
||||
spdk_bs_md_get_xattr_value(struct spdk_blob *_blob, const char *name,
|
||||
const void **value, size_t *value_len)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
struct spdk_xattr *xattr;
|
||||
|
||||
TAILQ_FOREACH(xattr, &blob->xattrs, link) {
|
||||
@ -3146,9 +3160,10 @@ struct spdk_xattr_names {
|
||||
};
|
||||
|
||||
int
|
||||
spdk_bs_md_get_xattr_names(struct spdk_blob *blob,
|
||||
spdk_bs_md_get_xattr_names(struct spdk_blob *_blob,
|
||||
struct spdk_xattr_names **names)
|
||||
{
|
||||
struct spdk_blob_data *blob = __blob_to_data(_blob);
|
||||
struct spdk_xattr *xattr;
|
||||
int count = 0;
|
||||
|
||||
|
@ -108,7 +108,7 @@ enum spdk_blob_state {
|
||||
SPDK_BLOB_STATE_SYNCING,
|
||||
};
|
||||
|
||||
struct spdk_blob {
|
||||
struct spdk_blob_data {
|
||||
struct spdk_blob_store *bs;
|
||||
|
||||
uint32_t open_ref;
|
||||
@ -138,9 +138,12 @@ struct spdk_blob {
|
||||
*/
|
||||
TAILQ_HEAD(, spdk_xattr) xattrs;
|
||||
|
||||
TAILQ_ENTRY(spdk_blob) link;
|
||||
TAILQ_ENTRY(spdk_blob_data) link;
|
||||
};
|
||||
|
||||
#define __blob_to_data(x) ((struct spdk_blob_data *)(x))
|
||||
#define __data_to_blob(x) ((struct spdk_blob *)(x))
|
||||
|
||||
struct spdk_blob_store {
|
||||
uint64_t md_start; /* Offset from beginning of disk, in pages */
|
||||
uint32_t md_len; /* Count, in pages */
|
||||
@ -172,7 +175,7 @@ struct spdk_blob_store {
|
||||
struct spdk_bs_cpl unload_cpl;
|
||||
int unload_err;
|
||||
|
||||
TAILQ_HEAD(, spdk_blob) blobs;
|
||||
TAILQ_HEAD(, spdk_blob_data) blobs;
|
||||
};
|
||||
|
||||
struct spdk_bs_channel {
|
||||
@ -418,7 +421,7 @@ _spdk_bs_page_to_blobid(uint32_t page_idx)
|
||||
* start of that page.
|
||||
*/
|
||||
static inline uint64_t
|
||||
_spdk_bs_blob_page_to_lba(struct spdk_blob *blob, uint32_t page)
|
||||
_spdk_bs_blob_page_to_lba(struct spdk_blob_data *blob, uint32_t page)
|
||||
{
|
||||
uint64_t lba;
|
||||
uint32_t pages_per_cluster;
|
||||
@ -437,7 +440,7 @@ _spdk_bs_blob_page_to_lba(struct spdk_blob *blob, uint32_t page)
|
||||
* next cluster boundary.
|
||||
*/
|
||||
static inline uint32_t
|
||||
_spdk_bs_num_pages_to_cluster_boundary(struct spdk_blob *blob, uint32_t page)
|
||||
_spdk_bs_num_pages_to_cluster_boundary(struct spdk_blob_data *blob, uint32_t page)
|
||||
{
|
||||
uint32_t pages_per_cluster;
|
||||
|
||||
|
@ -329,10 +329,10 @@ blob_resize(void)
|
||||
blob = g_blob;
|
||||
|
||||
/* Confirm that resize fails if blob is marked read-only. */
|
||||
blob->md_ro = true;
|
||||
__blob_to_data(blob)->md_ro = true;
|
||||
rc = spdk_bs_md_resize_blob(blob, 5);
|
||||
CU_ASSERT(rc == -EPERM);
|
||||
blob->md_ro = false;
|
||||
__blob_to_data(blob)->md_ro = false;
|
||||
|
||||
/* The blob started at 0 clusters. Resize it to be 5. */
|
||||
rc = spdk_bs_md_resize_blob(blob, 5);
|
||||
@ -435,10 +435,10 @@ blob_write(void)
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
/* Confirm that write fails if blob is marked read-only. */
|
||||
blob->data_ro = true;
|
||||
__blob_to_data(blob)->data_ro = true;
|
||||
spdk_bs_io_write_blob(blob, channel, payload, 0, 1, blob_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == -EPERM);
|
||||
blob->data_ro = false;
|
||||
__blob_to_data(blob)->data_ro = false;
|
||||
|
||||
/* Write to the blob */
|
||||
spdk_bs_io_write_blob(blob, channel, payload, 0, 1, blob_op_complete, NULL);
|
||||
@ -507,10 +507,10 @@ blob_read(void)
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
/* Confirm that read passes if blob is marked read-only. */
|
||||
blob->data_ro = true;
|
||||
__blob_to_data(blob)->data_ro = true;
|
||||
spdk_bs_io_read_blob(blob, channel, payload, 0, 1, blob_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
blob->data_ro = false;
|
||||
__blob_to_data(blob)->data_ro = false;
|
||||
|
||||
/* Read from the blob */
|
||||
spdk_bs_io_read_blob(blob, channel, payload, 0, 1, blob_op_complete, NULL);
|
||||
@ -635,9 +635,9 @@ blob_rw_verify_iov(void)
|
||||
* that cross cluster boundaries. Start by asserting that the allocated
|
||||
* clusters are where we expect before modifying the second cluster.
|
||||
*/
|
||||
CU_ASSERT(blob->active.clusters[0] == 1 * 256);
|
||||
CU_ASSERT(blob->active.clusters[1] == 2 * 256);
|
||||
blob->active.clusters[1] = 3 * 256;
|
||||
CU_ASSERT(__blob_to_data(blob)->active.clusters[0] == 1 * 256);
|
||||
CU_ASSERT(__blob_to_data(blob)->active.clusters[1] == 2 * 256);
|
||||
__blob_to_data(blob)->active.clusters[1] = 3 * 256;
|
||||
|
||||
memset(payload_write, 0xE5, sizeof(payload_write));
|
||||
iov_write[0].iov_base = payload_write;
|
||||
@ -797,7 +797,7 @@ blob_rw_iov_read_only(void)
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
/* Verify that writev failed if read_only flag is set. */
|
||||
blob->data_ro = true;
|
||||
__blob_to_data(blob)->data_ro = true;
|
||||
iov_write.iov_base = payload_write;
|
||||
iov_write.iov_len = sizeof(payload_write);
|
||||
spdk_bs_io_writev_blob(blob, channel, &iov_write, 1, 0, 1, blob_op_complete, NULL);
|
||||
@ -890,11 +890,11 @@ blob_xattr(void)
|
||||
blob = g_blob;
|
||||
|
||||
/* Test that set_xattr fails if md_ro flag is set. */
|
||||
blob->md_ro = true;
|
||||
__blob_to_data(blob)->md_ro = true;
|
||||
rc = spdk_blob_md_set_xattr(blob, "name", "log.txt", strlen("log.txt") + 1);
|
||||
CU_ASSERT(rc == -EPERM);
|
||||
|
||||
blob->md_ro = false;
|
||||
__blob_to_data(blob)->md_ro = false;
|
||||
rc = spdk_blob_md_set_xattr(blob, "name", "log.txt", strlen("log.txt") + 1);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
@ -909,13 +909,13 @@ blob_xattr(void)
|
||||
|
||||
/* get_xattr should still work even if md_ro flag is set. */
|
||||
value = NULL;
|
||||
blob->md_ro = true;
|
||||
__blob_to_data(blob)->md_ro = true;
|
||||
rc = spdk_bs_md_get_xattr_value(blob, "length", &value, &value_len);
|
||||
CU_ASSERT(rc == 0);
|
||||
SPDK_CU_ASSERT_FATAL(value != NULL);
|
||||
CU_ASSERT(*(uint64_t *)value == length);
|
||||
CU_ASSERT(value_len == 8);
|
||||
blob->md_ro = false;
|
||||
__blob_to_data(blob)->md_ro = false;
|
||||
|
||||
rc = spdk_bs_md_get_xattr_value(blob, "foobar", &value, &value_len);
|
||||
CU_ASSERT(rc == -ENOENT);
|
||||
@ -935,11 +935,11 @@ blob_xattr(void)
|
||||
spdk_xattr_names_free(names);
|
||||
|
||||
/* Confirm that remove_xattr fails if md_ro is set to true. */
|
||||
blob->md_ro = true;
|
||||
__blob_to_data(blob)->md_ro = true;
|
||||
rc = spdk_blob_md_remove_xattr(blob, "name");
|
||||
CU_ASSERT(rc == -EPERM);
|
||||
|
||||
blob->md_ro = false;
|
||||
__blob_to_data(blob)->md_ro = false;
|
||||
rc = spdk_blob_md_remove_xattr(blob, "name");
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
@ -2030,12 +2030,12 @@ blob_flags(void)
|
||||
CU_ASSERT(g_blob != NULL);
|
||||
blob_md_ro = g_blob;
|
||||
|
||||
blob_invalid->invalid_flags = (1ULL << 63);
|
||||
blob_invalid->state = SPDK_BLOB_STATE_DIRTY;
|
||||
blob_data_ro->data_ro_flags = (1ULL << 62);
|
||||
blob_data_ro->state = SPDK_BLOB_STATE_DIRTY;
|
||||
blob_md_ro->md_ro_flags = (1ULL << 61);
|
||||
blob_md_ro->state = SPDK_BLOB_STATE_DIRTY;
|
||||
__blob_to_data(blob_invalid)->invalid_flags = (1ULL << 63);
|
||||
__blob_to_data(blob_invalid)->state = SPDK_BLOB_STATE_DIRTY;
|
||||
__blob_to_data(blob_data_ro)->data_ro_flags = (1ULL << 62);
|
||||
__blob_to_data(blob_data_ro)->state = SPDK_BLOB_STATE_DIRTY;
|
||||
__blob_to_data(blob_md_ro)->md_ro_flags = (1ULL << 61);
|
||||
__blob_to_data(blob_md_ro)->state = SPDK_BLOB_STATE_DIRTY;
|
||||
|
||||
g_bserrno = -1;
|
||||
spdk_bs_md_sync_blob(blob_invalid, blob_op_complete, NULL);
|
||||
@ -2087,8 +2087,8 @@ blob_flags(void)
|
||||
SPDK_CU_ASSERT_FATAL(g_blob != NULL);
|
||||
blob_data_ro = g_blob;
|
||||
/* If an unknown data_ro flag was found, the blob should be marked both data and md read-only. */
|
||||
CU_ASSERT(blob_data_ro->data_ro == true);
|
||||
CU_ASSERT(blob_data_ro->md_ro == true);
|
||||
CU_ASSERT(__blob_to_data(blob_data_ro)->data_ro == true);
|
||||
CU_ASSERT(__blob_to_data(blob_data_ro)->md_ro == true);
|
||||
|
||||
g_blob = NULL;
|
||||
g_bserrno = -1;
|
||||
@ -2096,8 +2096,8 @@ blob_flags(void)
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_blob != NULL);
|
||||
blob_md_ro = g_blob;
|
||||
CU_ASSERT(blob_md_ro->data_ro == false);
|
||||
CU_ASSERT(blob_md_ro->md_ro == true);
|
||||
CU_ASSERT(__blob_to_data(blob_md_ro)->data_ro == false);
|
||||
CU_ASSERT(__blob_to_data(blob_md_ro)->md_ro == true);
|
||||
|
||||
spdk_bs_md_close_blob(&blob_data_ro, blob_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
|
Loading…
Reference in New Issue
Block a user