blob: blob_bdev no longer converts unmap to write zeroes

Unmaps are only used within blobstore to improve device performance,
never to zero blocks. Therefore, if the device does not support
unmap, just skip it instead of writing zeroes.

This is different than devices that elect to implement the write
zeroes command as an unmap because they will return 0 for
subsequent reads. That optimization is still in effect.

Change-Id: Ie1bf98fe86d73b4ac40b41c0d2804db325716500
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/390306
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>
This commit is contained in:
Ben Walker 2017-12-04 10:40:17 -07:00 committed by Jim Harris
parent f9f445b6a6
commit 7331affefd

View File

@ -140,12 +140,22 @@ static void
bdev_blob_unmap(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, uint64_t lba,
uint32_t lba_count, struct spdk_bs_dev_cb_args *cb_args)
{
struct blob_bdev *blob_bdev = (struct blob_bdev *)dev;
int rc;
rc = spdk_bdev_unmap_blocks(__get_desc(dev), channel, lba, lba_count,
bdev_blob_io_complete, cb_args);
if (rc) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc);
if (spdk_bdev_io_type_supported(blob_bdev->bdev, SPDK_BDEV_IO_TYPE_UNMAP)) {
rc = spdk_bdev_unmap_blocks(__get_desc(dev), channel, lba, lba_count,
bdev_blob_io_complete, cb_args);
if (rc) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc);
}
} else {
/*
* If the device doesn't support unmap, immediately complete
* the request. Blobstore does not rely on unmap zeroing
* data.
*/
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, 0);
}
}
@ -226,18 +236,7 @@ spdk_bdev_create_bs_dev(struct spdk_bdev *bdev, spdk_bdev_remove_cb_t remove_cb,
b->bs_dev.readv = bdev_blob_readv;
b->bs_dev.writev = bdev_blob_writev;
b->bs_dev.write_zeroes = bdev_blob_write_zeroes;
if (spdk_bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_UNMAP)) {
b->bs_dev.unmap = bdev_blob_unmap;
} else {
/*
* If bdev doesn't support unmap, use write_zeroes as a fallback.
* This will always work, since bdev implements write_zeroes on top of write
* if the device doesn't natively support write_zeroes.
*/
SPDK_NOTICELOG("Bdev %s does not support unmap, write_zeroes will be used instead.\n",
bdev->name);
b->bs_dev.unmap = bdev_blob_write_zeroes;
}
b->bs_dev.unmap = bdev_blob_unmap;
return &b->bs_dev;
}