Skip to content
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
16 changes: 0 additions & 16 deletions include/spdk/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,6 @@ uint64_t spdk_blob_get_next_allocated_io_unit(struct spdk_blob *blob, uint64_t o
*/
uint64_t spdk_blob_get_next_unallocated_io_unit(struct spdk_blob *blob, uint64_t offset);

/**
* Calculate the number of clusters used by the blob. Equal to number of allocated clusters for thick provisioned
* blobs, less or equal to number of allocated clusters for thin provisioned blobs.
*
* \param blob Blob struct to query.
*
* \return the number of allocated clusters.
*/
uint64_t spdk_blob_calc_used_clusters(struct spdk_blob *blob);

struct spdk_blob_xattr_opts {
/* Number of attributes */
size_t count;
Expand Down Expand Up @@ -1343,12 +1333,6 @@ struct spdk_bs_dev *spdk_blob_get_esnap_bs_dev(const struct spdk_blob *blob);
*/
bool spdk_blob_is_degraded(const struct spdk_blob *blob);

/**
* Reset num_used_clusters_cache, if blob is thin provisioned.
* \param blob for which need to reset the usage cache.
*/
void spdk_blob_reset_used_clusters_cache(struct spdk_blob *blob);

/**
* Blob get cluster bitmap completion callback.
*
Expand Down
7 changes: 0 additions & 7 deletions include/spdk_internal/lvolstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,4 @@ void spdk_lvs_esnap_missing_remove(struct spdk_lvol *lvol);
bool spdk_lvs_notify_hotplug(const void *esnap_id, uint32_t id_len,
spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg);

/**
* Reset num_used_clusters_cache, if blob is thin provisioned and snapshot is
* created from it. New snapshot will own the data, hence the clusted information
* present in the blob cache can be cleared.
*/
void blob_reset_used_clusters_cache(struct spdk_blob *blob);

#endif /* SPDK_INTERNAL_LVOLSTORE_H */
49 changes: 1 addition & 48 deletions lib/blob/blobstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ bs_allocate_cluster(struct spdk_blob *blob, uint32_t cluster_num,

assert(spdk_spin_held(&blob->bs->used_lock));

/* Reset cache of used clusters */
blob->num_used_clusters_cache = 0;

*cluster = bs_claim_cluster(blob->bs);
if (*cluster == UINT32_MAX) {
/* No more free clusters. Cannot satisfy the request */
Expand Down Expand Up @@ -274,7 +271,7 @@ spdk_blob_get_num_clusters_ancestors(struct spdk_blob_store *bs, struct spdk_blo
return -ENXIO;
}

clusters += spdk_blob_calc_used_clusters(b);
clusters += b->active.num_allocated_clusters;
}

*num_clusters = clusters;
Expand Down Expand Up @@ -6356,50 +6353,6 @@ spdk_blob_get_next_unallocated_io_unit(struct spdk_blob *blob, uint64_t offset)
return blob_find_io_unit(blob, offset, false);
}

uint64_t
spdk_blob_calc_used_clusters(struct spdk_blob *blob)
{
size_t i;
uint64_t num;

assert(blob != NULL);

if (!spdk_blob_is_thin_provisioned(blob)) {
return spdk_blob_get_num_clusters(blob);
}

spdk_spin_lock(&blob->bs->used_lock);

if (blob->num_used_clusters_cache > 0) {
num = blob->num_used_clusters_cache;
spdk_spin_unlock(&blob->bs->used_lock);
return num;
}

num = 0;
for (i = 0; i < blob->active.cluster_array_size; ++i) {
if (blob->active.clusters[i] != 0) {
++num;
}
}
blob->num_used_clusters_cache = num;

spdk_spin_unlock(&blob->bs->used_lock);

return num;
}

void
spdk_blob_reset_used_clusters_cache(struct spdk_blob *blob)
{
assert(blob != NULL);
if (spdk_blob_is_thin_provisioned(blob)) {
spdk_spin_lock(&blob->bs->used_lock);
blob->num_used_clusters_cache = 0;
spdk_spin_unlock(&blob->bs->used_lock);
}
}

struct spdk_blob_bitmap_ctx {
spdk_blob_cluster_bitmap_complete cb_fn;
void *cb_arg;
Expand Down
3 changes: 0 additions & 3 deletions lib/blob/blobstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ struct spdk_blob {
/* Number of data clusters retrieved from extent table,
* that many have to be read from extent pages. */
uint64_t remaining_clusters_in_et;

/* Cache number of used cluster for a thin provisioned blob. */
uint64_t num_used_clusters_cache;
};

struct spdk_blob_store {
Expand Down
3 changes: 0 additions & 3 deletions lib/lvol/lvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1171,9 +1171,6 @@ lvol_create_snapshot_cb(void *cb_arg, spdk_blob_id blobid, int lvolerrno)
{
struct spdk_lvol_snapshot_req *snap_req = cb_arg;

if (lvolerrno == 0) {
spdk_blob_reset_used_clusters_cache(snap_req->parent->blob);
}
snap_req->orig_cb_fn(snap_req->orig_cb_arg, blobid, lvolerrno);
free(cb_arg);
}
Expand Down
Loading