fix a bug of clear extents during blob persist md

Signed-off-by: guozhihong <guozhihong@bytedance.com>
Change-Id: Ief3fbc1754dedf424419dc98bebac8d73196377e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5106
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
guozhihong 2020-11-16 09:54:14 +08:00 committed by Tomasz Zawadzki
parent e663dc82ad
commit 750cfa17ab

View File

@ -1651,7 +1651,7 @@ blob_persist_clear_extents(spdk_bs_sequence_t *seq, struct spdk_blob_persist_ctx
for (i = blob->active.num_extent_pages; i < blob->active.extent_pages_array_size; i++) { for (i = blob->active.num_extent_pages; i < blob->active.extent_pages_array_size; i++) {
/* Nothing to clear if it was not allocated */ /* Nothing to clear if it was not allocated */
if (blob->active.extent_pages[i] != 0) { if (blob->active.extent_pages[i] != 0) {
lba = bs_md_page_to_lba(bs, blob->clean.extent_pages[i]); lba = bs_md_page_to_lba(bs, blob->active.extent_pages[i]);
bs_batch_write_zeroes_dev(batch, lba, lba_count); bs_batch_write_zeroes_dev(batch, lba, lba_count);
} }
} }
@ -5539,22 +5539,23 @@ bs_snapshot_newblob_sync_cpl(void *cb_arg, int bserrno)
if (bserrno != 0) { if (bserrno != 0) {
/* return cluster map back to original */ /* return cluster map back to original */
bs_snapshot_swap_cluster_maps(newblob, origblob); bs_snapshot_swap_cluster_maps(newblob, origblob);
blob_set_thin_provision(newblob);
bs_clone_snapshot_newblob_cleanup(ctx, bserrno); bs_clone_snapshot_newblob_cleanup(ctx, bserrno);
return; return;
} }
bs_blob_list_remove(origblob);
origblob->parent_id = newblob->id;
/* Create new back_bs_dev for snapshot */ /* Create new back_bs_dev for snapshot */
origblob->back_bs_dev = bs_create_blob_bs_dev(newblob); origblob->back_bs_dev = bs_create_blob_bs_dev(newblob);
if (origblob->back_bs_dev == NULL) { if (origblob->back_bs_dev == NULL) {
/* return cluster map back to original */ /* return cluster map back to original */
bs_snapshot_swap_cluster_maps(newblob, origblob); bs_snapshot_swap_cluster_maps(newblob, origblob);
blob_set_thin_provision(newblob);
bs_clone_snapshot_newblob_cleanup(ctx, -EINVAL); bs_clone_snapshot_newblob_cleanup(ctx, -EINVAL);
return; return;
} }
bs_blob_list_remove(origblob);
origblob->parent_id = newblob->id;
/* set clone blob as thin provisioned */ /* set clone blob as thin provisioned */
blob_set_thin_provision(origblob); blob_set_thin_provision(origblob);