lib/blob: serialize extents in new function

This change moves the code related to serializing
extents into serparate function, in order to allow
more clear changes in further patches.

There are no functional changes in this patch.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: If8d7c90a5b01f1608d20fd00c3e4ff6a340ce305
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466919
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Tomasz Zawadzki 2019-07-09 09:38:50 -04:00 committed by Jim Harris
parent fcaabb48fa
commit 41f2d0e448

View File

@ -732,6 +732,36 @@ _spdk_blob_serialize_extent(const struct spdk_blob *blob,
return;
}
static int
_spdk_blob_serialize_extents(const struct spdk_blob *blob,
struct spdk_blob_md_page **pages,
struct spdk_blob_md_page *cur_page,
uint32_t *page_count, uint8_t **buf,
size_t *remaining_sz)
{
uint64_t last_cluster;
int rc;
last_cluster = 0;
while (last_cluster < blob->active.num_clusters) {
_spdk_blob_serialize_extent(blob, last_cluster, &last_cluster, *buf, *remaining_sz);
if (last_cluster == blob->active.num_clusters) {
break;
}
rc = _spdk_blob_serialize_add_page(blob, pages, page_count, &cur_page);
if (rc < 0) {
return rc;
}
*buf = (uint8_t *)cur_page->descriptors;
*remaining_sz = sizeof(cur_page->descriptors);
}
return 0;
}
static void
_spdk_blob_serialize_flags(const struct spdk_blob *blob,
uint8_t *buf, size_t *buf_sz)
@ -814,7 +844,6 @@ _spdk_blob_serialize(const struct spdk_blob *blob, struct spdk_blob_md_page **pa
int rc;
uint8_t *buf;
size_t remaining_sz;
uint64_t last_cluster;
assert(pages != NULL);
assert(page_count != NULL);
@ -852,26 +881,9 @@ _spdk_blob_serialize(const struct spdk_blob *blob, struct spdk_blob_md_page **pa
}
/* Serialize extents */
last_cluster = 0;
while (last_cluster < blob->active.num_clusters) {
_spdk_blob_serialize_extent(blob, last_cluster, &last_cluster,
buf, remaining_sz);
rc = _spdk_blob_serialize_extents(blob, pages, cur_page, page_count, &buf, &remaining_sz);
if (last_cluster == blob->active.num_clusters) {
break;
}
rc = _spdk_blob_serialize_add_page(blob, pages, page_count,
&cur_page);
if (rc < 0) {
return rc;
}
buf = (uint8_t *)cur_page->descriptors;
remaining_sz = sizeof(cur_page->descriptors);
}
return 0;
return rc;
}
struct spdk_blob_load_ctx {