Skip to content

Commit

Permalink
fix(snapshot): reset num_used_clusters_cache when snapshot created fr…
Browse files Browse the repository at this point in the history
…om thin provisioned lvol

Signed-off-by: Hrudaya <[email protected]>
  • Loading branch information
hrudaya21 committed Jul 12, 2023
1 parent 4b3b937 commit ebdea84
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
9 changes: 9 additions & 0 deletions include/spdk/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,15 @@ uint64_t spdk_blob_get_next_unallocated_io_unit(struct spdk_blob *blob, uint64_t
*/
uint64_t spdk_blob_calc_used_clusters(struct spdk_blob *blob);

/**
* 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.
* \param blob Blob struct to query
* \return void
*/
void spdk_blob_reset_used_clusters_cache(struct spdk_blob *blob);

struct spdk_blob_xattr_opts {
/* Number of attributes */
size_t count;
Expand Down
18 changes: 15 additions & 3 deletions lib/blob/blobstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -5789,6 +5789,15 @@ spdk_blob_calc_used_clusters(struct spdk_blob *blob)
return num;
}

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

/* START spdk_bs_create_blob */

static void
Expand Down Expand Up @@ -7845,15 +7854,17 @@ spdk_blob_io_writev(struct spdk_blob *blob, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length,
spdk_blob_op_complete cb_fn, void *cb_arg)
{
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, 0, cb_fn, cb_arg, false, NULL);
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, 0, cb_fn, cb_arg, false,
NULL);
}

void
spdk_blob_io_readv(struct spdk_blob *blob, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length, uint32_t ext_io_flags,
spdk_blob_op_complete cb_fn, void *cb_arg)
{
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, ext_io_flags, cb_fn, cb_arg, true, NULL);
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, ext_io_flags, cb_fn, cb_arg,
true, NULL);
}

void
Expand All @@ -7870,7 +7881,8 @@ spdk_blob_io_readv_ext(struct spdk_blob *blob, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt, uint64_t offset, uint64_t length, uint32_t ext_io_flags,
spdk_blob_op_complete cb_fn, void *cb_arg, struct spdk_blob_ext_io_opts *io_opts)
{
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, ext_io_flags, cb_fn, cb_arg, true,
blob_request_submit_rw_iov(blob, channel, iov, iovcnt, offset, length, ext_io_flags, cb_fn, cb_arg,
true,
io_opts);
}

Expand Down
6 changes: 6 additions & 0 deletions lib/lvol/lvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,12 @@ create_lvol_snapshot(struct spdk_lvol *origlvol, const char *snapshot_name,
}

origblob = origlvol->blob;
/*
* Reset used clusters cache if blob is thin provisioned and new snapshot
* is created from it.
*/
spdk_blob_reset_used_clusters_cache(origblob);

lvs = origlvol->lvol_store;
if (lvs == NULL) {
SPDK_ERRLOG("lvol store does not exist\n");
Expand Down

0 comments on commit ebdea84

Please sign in to comment.