libnvdimm: nd_region flush callback support
This patch adds functionality to perform flush from guest to host over VIRTIO. We are registering a callback based on 'nd_region' type. virtio_pmem driver requires this special flush function. For rest of the region types we are registering existing flush function. Report error returned by host fsync failure to userspace. Signed-off-by: Pankaj Gupta <pagupta@redhat.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
committed by
Dan Williams
parent
db5d00c93e
commit
c5d4355d10
@@ -287,7 +287,9 @@ static ssize_t deep_flush_store(struct device *dev, struct device_attribute *att
|
||||
return rc;
|
||||
if (!flush)
|
||||
return -EINVAL;
|
||||
nvdimm_flush(nd_region);
|
||||
rc = nvdimm_flush(nd_region, NULL);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -1077,6 +1079,11 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
|
||||
dev->of_node = ndr_desc->of_node;
|
||||
nd_region->ndr_size = resource_size(ndr_desc->res);
|
||||
nd_region->ndr_start = ndr_desc->res->start;
|
||||
if (ndr_desc->flush)
|
||||
nd_region->flush = ndr_desc->flush;
|
||||
else
|
||||
nd_region->flush = NULL;
|
||||
|
||||
nd_device_register(dev);
|
||||
|
||||
return nd_region;
|
||||
@@ -1117,11 +1124,24 @@ struct nd_region *nvdimm_volatile_region_create(struct nvdimm_bus *nvdimm_bus,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nvdimm_volatile_region_create);
|
||||
|
||||
int nvdimm_flush(struct nd_region *nd_region, struct bio *bio)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (!nd_region->flush)
|
||||
rc = generic_nvdimm_flush(nd_region);
|
||||
else {
|
||||
if (nd_region->flush(nd_region, bio))
|
||||
rc = -EIO;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
/**
|
||||
* nvdimm_flush - flush any posted write queues between the cpu and pmem media
|
||||
* @nd_region: blk or interleaved pmem region
|
||||
*/
|
||||
void nvdimm_flush(struct nd_region *nd_region)
|
||||
int generic_nvdimm_flush(struct nd_region *nd_region)
|
||||
{
|
||||
struct nd_region_data *ndrd = dev_get_drvdata(&nd_region->dev);
|
||||
int i, idx;
|
||||
@@ -1145,6 +1165,8 @@ void nvdimm_flush(struct nd_region *nd_region)
|
||||
if (ndrd_get_flush_wpq(ndrd, i, 0))
|
||||
writeq(1, ndrd_get_flush_wpq(ndrd, i, idx));
|
||||
wmb();
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nvdimm_flush);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user