Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blob): report space allocated by blob ancestors #26

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/spdk/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@ uint64_t spdk_blob_get_num_io_units(struct spdk_blob *blob);
*/
uint64_t spdk_blob_get_num_clusters(struct spdk_blob *blob);

/**
* Get the number of clusters allocated by all ancestors of this blob.
*/
int spdk_blob_get_num_clusters_ancestors(struct spdk_blob_store *bs, struct spdk_blob *blob,
uint64_t *num_clusters);

/**
* Get next allocated io_unit
*
Expand Down
1 change: 1 addition & 0 deletions lib/bdev/spdk_bdev.map
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
spdk_bdev_read_blocks_with_md;
spdk_bdev_readv;
spdk_bdev_readv_blocks;
spdk_bdev_readv_blocks_with_flags;
spdk_bdev_readv_blocks_with_md;
spdk_bdev_write;
spdk_bdev_write_blocks;
Expand Down
25 changes: 25 additions & 0 deletions lib/blob/blobstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static int blob_remove_xattr(struct spdk_blob *blob, const char *name, bool inte

static void blob_write_extent_page(struct spdk_blob *blob, uint32_t extent, uint64_t cluster_num,
struct spdk_blob_md_page *page, spdk_blob_op_complete cb_fn, void *cb_arg);
static struct spdk_blob *blob_lookup(struct spdk_blob_store *bs, spdk_blob_id blobid);

static int
blob_id_cmp(struct spdk_blob *blob1, struct spdk_blob *blob2)
Expand Down Expand Up @@ -196,6 +197,30 @@ blob_xattrs_init(struct spdk_blob_xattr_opts *xattrs)
xattrs->get_value = NULL;
}

int
spdk_blob_get_num_clusters_ancestors(struct spdk_blob_store *bs, struct spdk_blob *blob,
uint64_t *num_clusters)
{
uint64_t clusters = 0;
struct spdk_blob *b = blob;

while (b->parent_id != SPDK_BLOBID_INVALID) {
spdk_blob_id blob_id = b->parent_id;

b = blob_lookup(bs, blob_id);

if (b == NULL) {
SPDK_ERRLOG("Can't lookup parent blob with ID %ld", blob_id);
return -ENXIO;
}

clusters += spdk_blob_calc_used_clusters(b);
}

*num_clusters = clusters;
return 0;
}

void
spdk_blob_opts_init(struct spdk_blob_opts *opts, size_t opts_size)
{
Expand Down
2 changes: 2 additions & 0 deletions lib/blob/spdk_blob.map
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
spdk_bs_free_cluster_count;
spdk_bs_total_data_cluster_count;
spdk_bs_grow;
spdk_blob_calc_used_clusters;
spdk_blob_get_id;
spdk_blob_get_num_pages;
spdk_blob_get_num_io_units;
Expand All @@ -27,6 +28,7 @@
spdk_bs_create_blob;
spdk_bs_create_snapshot;
spdk_bs_create_clone;
spdk_blob_get_ancestor_usage;
spdk_blob_get_clones;
spdk_blob_get_parent_snapshot;
spdk_blob_is_read_only;
Expand Down
1 change: 1 addition & 0 deletions lib/lvol/spdk_lvol.map
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
spdk_lvol_create_snapshot;
spdk_lvol_create_snapshot_ext;
spdk_lvol_create_clone;
spdk_lvol_create_clone_ext;
spdk_lvol_create_snapshot_ext;
spdk_lvol_rename;
spdk_lvol_deletable;
Expand Down
1 change: 1 addition & 0 deletions lib/nvme/spdk_nvme.map
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
spdk_nvme_ctrlr_cmd_admin_raw;
spdk_nvme_ctrlr_process_admin_completions;
spdk_nvme_ctrlr_get_ns;
spdk_nvme_ctrlr_io_qpair_connect_poll_async;
spdk_nvme_ctrlr_cmd_get_log_page;
spdk_nvme_ctrlr_cmd_get_log_page_ext;
spdk_nvme_ctrlr_cmd_abort;
Expand Down