lib/blob: minor refactor around clear_method
In prep for storing a clear_method in the blob metadata: * Set the default to DEFAULT and let the switch statement choose UNMAP * Use switch statements to make it clearer which method we are using and why. (ie previously we set the default to UNMAP and then had an UNMAP || DEFAULT condition to choose UNMAP. Later in the patch series it will become clearer why this makes sense. Signed-off-by: paul luse <paul.e.luse@intel.com> Change-Id: I216cb97fd8eaa772437a36c2c7a47e66618bbfbd Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472202 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
27fbf685bb
commit
dc29e75b1c
@ -170,7 +170,7 @@ spdk_blob_opts_init(struct spdk_blob_opts *opts)
|
||||
void
|
||||
spdk_blob_open_opts_init(struct spdk_blob_open_opts *opts)
|
||||
{
|
||||
opts->clear_method = BLOB_CLEAR_WITH_UNMAP;
|
||||
opts->clear_method = BLOB_CLEAR_WITH_DEFAULT;
|
||||
}
|
||||
|
||||
static struct spdk_blob *
|
||||
@ -1108,11 +1108,17 @@ static void
|
||||
spdk_bs_batch_clear_dev(struct spdk_blob_persist_ctx *ctx, spdk_bs_batch_t *batch, uint64_t lba,
|
||||
uint32_t lba_count)
|
||||
{
|
||||
if (ctx->blob->clear_method == BLOB_CLEAR_WITH_DEFAULT ||
|
||||
ctx->blob->clear_method == BLOB_CLEAR_WITH_UNMAP) {
|
||||
switch (ctx->blob->clear_method) {
|
||||
case BLOB_CLEAR_WITH_DEFAULT:
|
||||
case BLOB_CLEAR_WITH_UNMAP:
|
||||
spdk_bs_batch_unmap_dev(batch, lba, lba_count);
|
||||
} else if (ctx->blob->clear_method == BLOB_CLEAR_WITH_WRITE_ZEROES) {
|
||||
break;
|
||||
case BLOB_CLEAR_WITH_WRITE_ZEROES:
|
||||
spdk_bs_batch_write_zeroes_dev(batch, lba, lba_count);
|
||||
break;
|
||||
case BLOB_CLEAR_WITH_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3880,12 +3886,18 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
|
||||
/* Clear metadata space */
|
||||
spdk_bs_batch_write_zeroes_dev(batch, 0, num_md_lba);
|
||||
|
||||
if (opts.clear_method == BS_CLEAR_WITH_UNMAP) {
|
||||
switch (opts.clear_method) {
|
||||
case BS_CLEAR_WITH_UNMAP:
|
||||
/* Trim data clusters */
|
||||
spdk_bs_batch_unmap_dev(batch, num_md_lba, ctx->bs->dev->blockcnt - num_md_lba);
|
||||
} else if (opts.clear_method == BS_CLEAR_WITH_WRITE_ZEROES) {
|
||||
break;
|
||||
case BS_CLEAR_WITH_WRITE_ZEROES:
|
||||
/* Write_zeroes to data clusters */
|
||||
spdk_bs_batch_write_zeroes_dev(batch, num_md_lba, ctx->bs->dev->blockcnt - num_md_lba);
|
||||
break;
|
||||
case BS_CLEAR_WITH_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
spdk_bs_batch_close(batch);
|
||||
|
Loading…
x
Reference in New Issue
Block a user