lib/blob: update buf and buf_sz when serializing extent_rle

Originally serializing extent_rle was always done as last step.
There was no need to update the buffer pointer,
since it went unused.

Next patches in series expand serialization to new descriptors,
so here the assumption is removed and buf/buf_sz is updated.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I7ccfb500d64e4276359cc98c5587c6301272d728
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468232
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Tomasz Zawadzki 2019-09-11 04:54:06 -04:00 committed by Jim Harris
parent be45e54a99
commit 074413c556

View File

@ -675,7 +675,7 @@ _spdk_blob_serialize_xattr(const struct spdk_xattr *xattr,
static void
_spdk_blob_serialize_extent_rle(const struct spdk_blob *blob,
uint64_t start_cluster, uint64_t *next_cluster,
uint8_t *buf, size_t buf_sz)
uint8_t **buf, size_t *buf_sz)
{
struct spdk_blob_md_descriptor_extent_rle *desc_extent_rle;
size_t cur_sz;
@ -684,12 +684,12 @@ _spdk_blob_serialize_extent_rle(const struct spdk_blob *blob,
/* The buffer must have room for at least one extent */
cur_sz = sizeof(struct spdk_blob_md_descriptor) + sizeof(desc_extent_rle->extents[0]);
if (buf_sz < cur_sz) {
if (*buf_sz < cur_sz) {
*next_cluster = start_cluster;
return;
}
desc_extent_rle = (struct spdk_blob_md_descriptor_extent_rle *)buf;
desc_extent_rle = (struct spdk_blob_md_descriptor_extent_rle *)*buf;
desc_extent_rle->type = SPDK_MD_DESCRIPTOR_TYPE_EXTENT_RLE;
lba_per_cluster = _spdk_bs_cluster_to_lba(blob->bs, 1);
@ -711,7 +711,7 @@ _spdk_blob_serialize_extent_rle(const struct spdk_blob *blob,
cur_sz += sizeof(desc_extent_rle->extents[extent_idx]);
if (buf_sz < cur_sz) {
if (*buf_sz < cur_sz) {
/* If we ran out of buffer space, return */
*next_cluster = i;
goto finish;
@ -729,6 +729,8 @@ _spdk_blob_serialize_extent_rle(const struct spdk_blob *blob,
finish:
desc_extent_rle->length = sizeof(desc_extent_rle->extents[0]) * extent_idx;
*buf_sz -= sizeof(struct spdk_blob_md_descriptor) + desc_extent_rle->length;
*buf += sizeof(struct spdk_blob_md_descriptor) + desc_extent_rle->length;
return;
}
@ -745,7 +747,7 @@ _spdk_blob_serialize_extents_rle(const struct spdk_blob *blob,
last_cluster = 0;
while (last_cluster < blob->active.num_clusters) {
_spdk_blob_serialize_extent_rle(blob, last_cluster, &last_cluster, *buf, *remaining_sz);
_spdk_blob_serialize_extent_rle(blob, last_cluster, &last_cluster, buf, remaining_sz);
if (last_cluster == blob->active.num_clusters) {
break;