qcow: clear WCE and use O_SYNC
qcow does not implement a flush callback for SYNCHRONIZE CACHE
support, so we must report WCE=0 to avoid failed commands.
But, we use O_SYNC to make sure data is written to the medium.
@@ -1405,7 +1405,12 @@ static int qcow_open(struct tcmu_device *dev)
tcmu_dbg("%s\n", tcmu_get_dev_cfgstring(dev));
tcmu_dbg("%s\n", config);
- if (bdev_open(bdev, AT_FDCWD, config, O_RDWR) == -1)
+ /*
+ * We do not implement flush, so set WCE=0 and do sync IO.
+ */
+ tcmu_set_dev_write_cache_enabled(dev, 0);
+
+ if (bdev_open(bdev, AT_FDCWD, config, O_RDWR | O_SYNC) == -1)
goto err;
return 0;
err:
