blobstore: Enable/disable snapshot deletion with CFLAGS
Snapshot delete functionality is targeted for .1 release and therefore should not be enabled by default. Use export CFLAGS=-DSPDK_ENABLE_SNAPSHOT_DELETION to enable this functionality. Signed-off-by: Maciej Szwed <maciej.szwed@intel.com> Change-Id: I2d966b62cd5d7eaf8134962d1a833542edfe2d9f Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458466 Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
3c22b8e41b
commit
84b5ac7dac
@ -49,6 +49,12 @@
|
||||
|
||||
#define BLOB_CRC32C_INITIAL 0xffffffffUL
|
||||
|
||||
#ifdef SPDK_ENABLE_SNAPSHOT_DELETION
|
||||
bool g_delete_snapshot_enabled = true;
|
||||
#else
|
||||
bool g_delete_snapshot_enabled = false;
|
||||
#endif
|
||||
|
||||
static int spdk_bs_register_md_thread(struct spdk_blob_store *bs);
|
||||
static int spdk_bs_unregister_md_thread(struct spdk_blob_store *bs);
|
||||
static void _spdk_blob_close_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno);
|
||||
@ -5507,6 +5513,11 @@ _spdk_bs_is_blob_deletable(struct spdk_blob *blob, bool *update_clone)
|
||||
/* Check if this is a snapshot with clones */
|
||||
snapshot_entry = _spdk_bs_get_snapshot_entry(blob->bs, blob->id);
|
||||
if (snapshot_entry != NULL) {
|
||||
if (snapshot_entry->clone_count > 0 && !g_delete_snapshot_enabled) {
|
||||
SPDK_ERRLOG("Cannot remove snapshot with clones\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
if (snapshot_entry->clone_count > 1) {
|
||||
SPDK_ERRLOG("Cannot remove snapshot with more than one clone\n");
|
||||
return -EBUSY;
|
||||
|
@ -45,6 +45,8 @@
|
||||
#include "blob/zeroes.c"
|
||||
#include "blob/blob_bs_dev.c"
|
||||
|
||||
extern bool g_delete_snapshot_enabled;
|
||||
|
||||
struct spdk_blob_store *g_bs;
|
||||
spdk_blob_id g_blobid;
|
||||
struct spdk_blob *g_blob;
|
||||
@ -5435,7 +5437,13 @@ _blob_inflate_rw(bool decouple_parent)
|
||||
/* Try to delete base snapshot */
|
||||
spdk_bs_delete_blob(bs, snapshotid, blob_op_complete, NULL);
|
||||
poll_threads();
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
|
||||
if (g_delete_snapshot_enabled) {
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
} else {
|
||||
CU_ASSERT(decouple_parent || g_bserrno == 0);
|
||||
CU_ASSERT(!decouple_parent || g_bserrno != 0);
|
||||
}
|
||||
|
||||
/* Reopen blob after snapshot deletion */
|
||||
spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL);
|
||||
@ -5854,6 +5862,10 @@ blob_relations2(void)
|
||||
size_t count;
|
||||
spdk_blob_id ids[10] = {};
|
||||
|
||||
if (!g_delete_snapshot_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
dev = init_dev();
|
||||
spdk_bs_opts_init(&bs_opts);
|
||||
snprintf(bs_opts.bstype.bstype, sizeof(bs_opts.bstype.bstype), "TESTTYPE");
|
||||
|
Loading…
Reference in New Issue
Block a user