mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
libnvdimm, pmem: flush posted-write queues on shutdown
Commit writes to media on system shutdown or pmem driver unload. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
7e267a8c79
commit
476f848aae
3 changed files with 25 additions and 0 deletions
|
@ -136,6 +136,21 @@ static int nvdimm_bus_remove(struct device *dev)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nvdimm_bus_shutdown(struct device *dev)
|
||||||
|
{
|
||||||
|
struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
|
||||||
|
struct nd_device_driver *nd_drv = NULL;
|
||||||
|
|
||||||
|
if (dev->driver)
|
||||||
|
nd_drv = to_nd_device_driver(dev->driver);
|
||||||
|
|
||||||
|
if (nd_drv && nd_drv->shutdown) {
|
||||||
|
nd_drv->shutdown(dev);
|
||||||
|
dev_dbg(&nvdimm_bus->dev, "%s.shutdown(%s)\n",
|
||||||
|
dev->driver->name, dev_name(dev));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void nd_device_notify(struct device *dev, enum nvdimm_event event)
|
void nd_device_notify(struct device *dev, enum nvdimm_event event)
|
||||||
{
|
{
|
||||||
device_lock(dev);
|
device_lock(dev);
|
||||||
|
@ -214,6 +229,7 @@ static struct bus_type nvdimm_bus_type = {
|
||||||
.match = nvdimm_bus_match,
|
.match = nvdimm_bus_match,
|
||||||
.probe = nvdimm_bus_probe,
|
.probe = nvdimm_bus_probe,
|
||||||
.remove = nvdimm_bus_remove,
|
.remove = nvdimm_bus_remove,
|
||||||
|
.shutdown = nvdimm_bus_shutdown,
|
||||||
};
|
};
|
||||||
|
|
||||||
static ASYNC_DOMAIN_EXCLUSIVE(nd_async_domain);
|
static ASYNC_DOMAIN_EXCLUSIVE(nd_async_domain);
|
||||||
|
|
|
@ -349,9 +349,16 @@ static int nd_pmem_remove(struct device *dev)
|
||||||
{
|
{
|
||||||
if (is_nd_btt(dev))
|
if (is_nd_btt(dev))
|
||||||
nvdimm_namespace_detach_btt(to_nd_btt(dev));
|
nvdimm_namespace_detach_btt(to_nd_btt(dev));
|
||||||
|
nvdimm_flush(to_nd_region(dev->parent));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nd_pmem_shutdown(struct device *dev)
|
||||||
|
{
|
||||||
|
nvdimm_flush(to_nd_region(dev->parent));
|
||||||
|
}
|
||||||
|
|
||||||
static void nd_pmem_notify(struct device *dev, enum nvdimm_event event)
|
static void nd_pmem_notify(struct device *dev, enum nvdimm_event event)
|
||||||
{
|
{
|
||||||
struct pmem_device *pmem = dev_get_drvdata(dev);
|
struct pmem_device *pmem = dev_get_drvdata(dev);
|
||||||
|
@ -391,6 +398,7 @@ static struct nd_device_driver nd_pmem_driver = {
|
||||||
.probe = nd_pmem_probe,
|
.probe = nd_pmem_probe,
|
||||||
.remove = nd_pmem_remove,
|
.remove = nd_pmem_remove,
|
||||||
.notify = nd_pmem_notify,
|
.notify = nd_pmem_notify,
|
||||||
|
.shutdown = nd_pmem_shutdown,
|
||||||
.drv = {
|
.drv = {
|
||||||
.name = "nd_pmem",
|
.name = "nd_pmem",
|
||||||
},
|
},
|
||||||
|
|
|
@ -26,6 +26,7 @@ struct nd_device_driver {
|
||||||
unsigned long type;
|
unsigned long type;
|
||||||
int (*probe)(struct device *dev);
|
int (*probe)(struct device *dev);
|
||||||
int (*remove)(struct device *dev);
|
int (*remove)(struct device *dev);
|
||||||
|
void (*shutdown)(struct device *dev);
|
||||||
void (*notify)(struct device *dev, enum nvdimm_event event);
|
void (*notify)(struct device *dev, enum nvdimm_event event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue