Skip to content

Commit

Permalink
feat(snapshot): blob iteration to get the parent blob
Browse files Browse the repository at this point in the history
Signed-off-by: Hrudaya <[email protected]>
  • Loading branch information
hrudaya21 committed Dec 21, 2023
1 parent 226fad7 commit 2d94be9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/spdk/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,14 @@ void spdk_bs_iter_first(struct spdk_blob_store *bs,
void spdk_bs_iter_next(struct spdk_blob_store *bs, struct spdk_blob *blob,
spdk_blob_op_with_handle_complete cb_fn, void *cb_arg);

/**
* Get the parent blob by using the current blob.
*
* \param blob The current blob.
*
* \return if parent blob exist send blob else NULL.
*/
struct spdk_blob *spdk_bs_iter_parent(struct spdk_blob *blob);
/**
* Set an extended attribute for the given blob.
*
Expand Down
18 changes: 18 additions & 0 deletions lib/blob/blobstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -8459,6 +8459,24 @@ spdk_bs_iter_next(struct spdk_blob_store *bs, struct spdk_blob *blob,
spdk_blob_close(blob, bs_iter_close_cpl, ctx);
}

struct spdk_blob *spdk_bs_iter_parent(struct spdk_blob *blob) {
spdk_blob_id blob_id;
struct spdk_blob *parent_blob;

assert(blob != NULL);

if (blob->parent_id == SPDK_BLOBID_INVALID) {
return NULL;
}

blob_id = blob->parent_id;
parent_blob = blob_lookup(blob->bs, blob_id);

if (parent_blob == NULL) {
return NULL;
}
return parent_blob;
}
static int
blob_set_xattr(struct spdk_blob *blob, const char *name, const void *value,
uint16_t value_len, bool internal)
Expand Down

0 comments on commit 2d94be9

Please sign in to comment.