]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
libnvdimm, pmem: Do not flush power-fail protected CPU caches
authorRoss Zwisler <ross.zwisler@linux.intel.com>
Wed, 6 Jun 2018 16:45:15 +0000 (10:45 -0600)
committerDan Williams <dan.j.williams@intel.com>
Wed, 6 Jun 2018 18:02:32 +0000 (11:02 -0700)
This commit:

5fdf8e5ba566 ("libnvdimm: re-enable deep flush for pmem devices via fsync()")

intended to make sure that deep flush was always available even on
platforms which support a power-fail protected CPU cache.  An unintended
side effect of this change was that we also lost the ability to skip
flushing CPU caches on those power-fail protected CPU cache.

Fix this by skipping the low level cache flushing in dax_flush() if we have
CPU caches which are power-fail protected.  The user can still override this
behavior by manually setting the write_cache state of a namespace.  See
libndctl's ndctl_namespace_write_cache_is_enabled(),
ndctl_namespace_enable_write_cache() and
ndctl_namespace_disable_write_cache() functions.

Cc: <stable@vger.kernel.org>
Fixes: 5fdf8e5ba566 ("libnvdimm: re-enable deep flush for pmem devices via fsync()")
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/nvdimm/region_devs.c

index a612be6f019d49b1ce08da99e981493b1f9e22d7..ec3543b83330f25e040894599c44b3898d6bd66b 100644 (file)
@@ -1132,7 +1132,8 @@ EXPORT_SYMBOL_GPL(nvdimm_has_flush);
 
 int nvdimm_has_cache(struct nd_region *nd_region)
 {
-       return is_nd_pmem(&nd_region->dev);
+       return is_nd_pmem(&nd_region->dev) &&
+               !test_bit(ND_REGION_PERSIST_CACHE, &nd_region->flags);
 }
 EXPORT_SYMBOL_GPL(nvdimm_has_cache);