Skip to content

Commit

Permalink
blobstore: allow to disable cluster release on unmap
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Savitskiy <[email protected]>
  • Loading branch information
dsavitskiy committed Jul 24, 2024
1 parent df6caca commit 981a969
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/spdk/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,14 @@ int
spdk_blob_get_cluster_bitmap(struct spdk_blob *blob, spdk_blob_cluster_bitmap_complete cb_fn,
void *cb_arg);

/**
* Enables or disables globally cluster release on unmap.
*
* \param is_enabled If true, cluster release on unmap is enabled.
*/
void
spdk_blob_enable_cluster_unmap(bool is_enabled);

#ifdef __cplusplus
}
#endif
Expand Down
28 changes: 27 additions & 1 deletion lib/blob/blobstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#define BLOB_CRC32C_INITIAL 0xffffffffUL

static bool g_cluster_unmap_enabled = true;

static int bs_register_md_thread(struct spdk_blob_store *bs);
static int bs_unregister_md_thread(struct spdk_blob_store *bs);
static void blob_close_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno);
Expand Down Expand Up @@ -3292,7 +3294,7 @@ blob_request_submit_op_single(struct spdk_io_channel *_ch, struct spdk_blob *blo

/* if aligned with cluster release cluster */
if (spdk_blob_is_thin_provisioned(blob) && is_allocated &&
bs_io_units_per_cluster(blob) == length) {
bs_io_units_per_cluster(blob) == length && g_cluster_unmap_enabled) {
struct spdk_bs_channel *bs_channel = spdk_io_channel_get_ctx(_ch);
uint32_t cluster_start_page;
uint32_t cluster_number;
Expand Down Expand Up @@ -3337,6 +3339,24 @@ blob_request_submit_op_single(struct spdk_io_channel *_ch, struct spdk_blob *blo
cpl.u.blob_basic.cb_arg = ctx;
}


/* OLD
spdk_bs_batch_t *batch;
batch = bs_batch_open(_ch, &cpl, blob);
if (!batch) {
cb_fn(cb_arg, -ENOMEM);
return;
}
if (is_allocated) {
bs_batch_unmap_dev(batch, lba, lba_count);
}
bs_batch_close(batch);
break;
*/

batch = bs_batch_open(_ch, &cpl, blob);
if (!batch) {
free(ctx);
Expand Down Expand Up @@ -10570,5 +10590,11 @@ spdk_blob_is_degraded(const struct spdk_blob *blob)
return blob->back_bs_dev->is_degraded(blob->back_bs_dev);
}

void
spdk_blob_enable_cluster_unmap(bool is_enabled)
{
g_cluster_unmap_enabled = is_enabled;
}

SPDK_LOG_REGISTER_COMPONENT(blob)
SPDK_LOG_REGISTER_COMPONENT(blob_esnap)

0 comments on commit 981a969

Please sign in to comment.