blobstore: move xattr serialization to separate function
Signed-off-by: Piotr Pelplinski <piotr.pelplinski@intel.com> Change-Id: I277f7288427788e7a107b143331753fd5b23f16f Reviewed-on: https://review.gerrithub.io/396571 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
c287b5b4ed
commit
69c9bb0153
@ -590,12 +590,63 @@ _spdk_blob_serialize_flags(const struct spdk_blob_data *blob,
|
||||
*buf_sz -= sizeof(*desc);
|
||||
}
|
||||
|
||||
static int
|
||||
_spdk_blob_serialize_xattrs(const struct spdk_blob_data *blob,
|
||||
const struct spdk_xattr_tailq *xattrs,
|
||||
struct spdk_blob_md_page **pages,
|
||||
struct spdk_blob_md_page *cur_page,
|
||||
uint32_t *page_count, uint8_t **buf,
|
||||
size_t *remaining_sz)
|
||||
{
|
||||
const struct spdk_xattr *xattr;
|
||||
int rc;
|
||||
|
||||
TAILQ_FOREACH(xattr, xattrs, link) {
|
||||
size_t required_sz = 0;
|
||||
|
||||
rc = _spdk_blob_serialize_xattr(xattr,
|
||||
*buf, *remaining_sz,
|
||||
&required_sz);
|
||||
if (rc < 0) {
|
||||
/* Need to add a new page to the chain */
|
||||
rc = _spdk_blob_serialize_add_page(blob, pages, page_count,
|
||||
&cur_page);
|
||||
if (rc < 0) {
|
||||
spdk_dma_free(*pages);
|
||||
*pages = NULL;
|
||||
*page_count = 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
*buf = (uint8_t *)cur_page->descriptors;
|
||||
*remaining_sz = sizeof(cur_page->descriptors);
|
||||
|
||||
/* Try again */
|
||||
required_sz = 0;
|
||||
rc = _spdk_blob_serialize_xattr(xattr,
|
||||
*buf, *remaining_sz,
|
||||
&required_sz);
|
||||
|
||||
if (rc < 0) {
|
||||
spdk_dma_free(*pages);
|
||||
*pages = NULL;
|
||||
*page_count = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
*remaining_sz -= required_sz;
|
||||
*buf += required_sz;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_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;
|
||||
const struct spdk_xattr *xattr;
|
||||
int rc;
|
||||
uint8_t *buf;
|
||||
size_t remaining_sz;
|
||||
@ -623,43 +674,11 @@ _spdk_blob_serialize(const struct spdk_blob_data *blob, struct spdk_blob_md_page
|
||||
buf += sizeof(struct spdk_blob_md_descriptor_flags);
|
||||
|
||||
/* Serialize xattrs */
|
||||
TAILQ_FOREACH(xattr, &blob->xattrs, link) {
|
||||
size_t required_sz = 0;
|
||||
rc = _spdk_blob_serialize_xattr(xattr,
|
||||
buf, remaining_sz,
|
||||
&required_sz);
|
||||
if (rc < 0) {
|
||||
/* Need to add a new page to the chain */
|
||||
rc = _spdk_blob_serialize_add_page(blob, pages, page_count,
|
||||
&cur_page);
|
||||
if (rc < 0) {
|
||||
spdk_dma_free(*pages);
|
||||
*pages = NULL;
|
||||
*page_count = 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
buf = (uint8_t *)cur_page->descriptors;
|
||||
remaining_sz = sizeof(cur_page->descriptors);
|
||||
|
||||
/* Try again */
|
||||
required_sz = 0;
|
||||
rc = _spdk_blob_serialize_xattr(xattr,
|
||||
buf, remaining_sz,
|
||||
&required_sz);
|
||||
|
||||
if (rc < 0) {
|
||||
spdk_dma_free(*pages);
|
||||
*pages = NULL;
|
||||
*page_count = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
remaining_sz -= required_sz;
|
||||
buf += required_sz;
|
||||
rc = _spdk_blob_serialize_xattrs(blob, &blob->xattrs,
|
||||
pages, cur_page, page_count, &buf, &remaining_sz);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Serialize extents */
|
||||
last_cluster = 0;
|
||||
while (last_cluster < blob->active.num_clusters) {
|
||||
|
@ -138,7 +138,7 @@ struct spdk_blob_data {
|
||||
/* TODO: The xattrs are mutable, but we don't want to be
|
||||
* copying them unecessarily. Figure this out.
|
||||
*/
|
||||
TAILQ_HEAD(, spdk_xattr) xattrs;
|
||||
TAILQ_HEAD(spdk_xattr_tailq, spdk_xattr) xattrs;
|
||||
|
||||
TAILQ_ENTRY(spdk_blob_data) link;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user