vhost-blk: process VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP correctly
Flag VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP is only used for WRITE ZEROES command, vhost-blk target may tell VM via 'write_zeroes_may_unmap' configuration that the backend can support this flag, however, Linux generic block driver doesn't have such logic, it will enable this flag by default(without REQ_NOUNMAP) with WRITE ZEROES command, so the backend may choose to ignore this flag, because WRITE ZEROES with this flag isn't mandatory. Fix issue #1714. Change-Id: Ic9388f39269720a23c00d41cba585d2a5abc3cfb Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5565 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: <dongx.yi@intel.com>
This commit is contained in:
parent
dffb272c1a
commit
e18788d30e
@ -464,6 +464,12 @@ process_blk_request(struct spdk_vhost_blk_task *task,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (desc->flags & VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP) {
|
||||
SPDK_ERRLOG("UNMAP flag is only used for WRITE ZEROES command\n");
|
||||
invalid_blk_request(task, VIRTIO_BLK_S_UNSUPP);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = spdk_bdev_unmap(bvdev->bdev_desc, bvsession->io_channel,
|
||||
desc->sector * 512, desc->num_sectors * 512,
|
||||
blk_request_complete_cb, task);
|
||||
@ -485,11 +491,13 @@ process_blk_request(struct spdk_vhost_blk_task *task,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Zeroed and Unmap the range, SPDK doen't support it. */
|
||||
/* Unmap this range, SPDK doesn't support it, kernel will enable this flag by default
|
||||
* without checking unmap feature is negociated or not, the flag isn't mandatory, so
|
||||
* just print a warning.
|
||||
*/
|
||||
if (desc->flags & VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP) {
|
||||
SPDK_NOTICELOG("Can't support Write Zeroes with Unmap flag\n");
|
||||
invalid_blk_request(task, VIRTIO_BLK_S_UNSUPP);
|
||||
return -1;
|
||||
SPDK_WARNLOG("Ignore the unmap flag for WRITE ZEROES from %"PRIx64", len %"PRIx64"\n",
|
||||
(uint64_t)desc->sector * 512, (uint64_t)desc->num_sectors * 512);
|
||||
}
|
||||
|
||||
rc = spdk_bdev_write_zeroes(bvdev->bdev_desc, bvsession->io_channel,
|
||||
|
Loading…
Reference in New Issue
Block a user