blobstore: on init write zeroes to metadata and unmap rest

Currently on blobstore creation we use write zeros everytime.
Some drives does not support write zeros, but support unmap.
We should do write zeroes only on metadata and try to unmap
data clusters

Signed-off-by: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: Iae36c1ccacc08340e79ad40c4c9a2c53dda920ba
Reviewed-on: https://review.gerrithub.io/387152
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Maciej Szwed 2017-11-22 15:34:27 +01:00 committed by Jim Harris
parent b81550158d
commit b9d123b814

View File

@ -2069,6 +2069,8 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
struct spdk_blob_store *bs;
struct spdk_bs_cpl cpl;
spdk_bs_sequence_t *seq;
spdk_bs_batch_t *batch;
uint64_t num_md_lba;
uint64_t num_md_pages;
uint64_t num_md_clusters;
uint32_t i;
@ -2177,6 +2179,7 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
ctx->super->md_start = bs->md_start = num_md_pages;
ctx->super->md_len = bs->md_len;
num_md_pages += bs->md_len;
num_md_lba = _spdk_bs_page_to_lba(bs, num_md_pages);
ctx->super->crc = _spdk_blob_md_page_calc_crc(ctx->super);
@ -2212,8 +2215,14 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
return;
}
/* Zero the entire device */
spdk_bs_sequence_write_zeroes(seq, 0, bs->dev->blockcnt, _spdk_bs_init_trim_cpl, ctx);
batch = spdk_bs_sequence_to_batch(seq, _spdk_bs_init_trim_cpl, ctx);
/* Clear metadata space */
spdk_bs_batch_write_zeroes(batch, 0, num_md_lba);
/* Trim data clusters */
spdk_bs_batch_unmap(batch, num_md_lba, ctx->bs->dev->blockcnt - num_md_lba);
spdk_bs_batch_close(batch);
}
/* END spdk_bs_init */