dm: storage: change DISCARD to synchronous mode

For virtio-blk, when the backend is a regular file, the discard
and
is implemented by fallocate(), but this function will not wait for
the discard command handled by disk.
So, add fdatasync to make sure the DISCARD is executed
synchronously.

Tracked-On: #2547
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Wang Yu <yu1.wang@intel.com>
This commit is contained in:
Conghui Chen 2019-01-23 18:05:51 +00:00 committed by wenlingz
parent b595abcc23
commit a82cafe92d

View File

@ -313,6 +313,8 @@ blockif_process_discard(struct blockif_ctxt *bc, struct blockif_req *br)
*/
err = fallocate(bc->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
arg[i][0], arg[i][1]);
if (!err)
err = fdatasync(bc->fd);
}
if (err) {
WPRINTF(("Failed to discard offset=%ld nbytes=%ld err code: %d\n",