libnvdimm/region: Fix nvdimm_has_flush() to handle ND_REGION_ASYNC
authorVaibhav Jain <vaibhav@linux.ibm.com>
Fri, 2 Apr 2021 09:25:55 +0000 (14:55 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Apr 2021 11:00:55 +0000 (13:00 +0200)
commiteb82199e377ad606a2c055435628142504f2b4be
tree96383f00e1379eb7aa379cac9743f61ffda47b65
parenta2af8a0f38e48e0f496870735cd931b69b78f481
libnvdimm/region: Fix nvdimm_has_flush() to handle ND_REGION_ASYNC

commit a2948b17f6b936fc52f86c0f92c46d2f91928b79 upstream.

In case a platform doesn't provide explicit flush-hints but provides an
explicit flush callback via ND_REGION_ASYNC region flag, then
nvdimm_has_flush() still returns '0' indicating that writes do not
require flushing. This happens on PPC64 with patch at [1] applied, where
'deep_flush' of a region was denied even though an explicit flush
function was provided.

Fix this by adding a condition to nvdimm_has_flush() to test for the
ND_REGION_ASYNC flag on the region and see if a 'region->flush' callback
is assigned.

Link: http://lore.kernel.org/r/161703936121.36.7260632399582101498.stgit@e1fbed493c87
Fixes: c5d4355d10d4 ("libnvdimm: nd_region flush callback support")
Reported-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Link: https://lore.kernel.org/r/20210402092555.208590-1-vaibhav@linux.ibm.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvdimm/region_devs.c