Skip to content

Commit a2948b1

Browse files
vaibhav92djbw
authored andcommitted
libnvdimm/region: Fix nvdimm_has_flush() to handle ND_REGION_ASYNC
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 [1] Fixes: c5d4355 ("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>
1 parent 2361db8 commit a2948b1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/nvdimm/region_devs.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,11 @@ int nvdimm_has_flush(struct nd_region *nd_region)
12461246
|| !IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API))
12471247
return -ENXIO;
12481248

1249+
/* Test if an explicit flush function is defined */
1250+
if (test_bit(ND_REGION_ASYNC, &nd_region->flags) && nd_region->flush)
1251+
return 1;
1252+
1253+
/* Test if any flush hints for the region are available */
12491254
for (i = 0; i < nd_region->ndr_mappings; i++) {
12501255
struct nd_mapping *nd_mapping = &nd_region->mapping[i];
12511256
struct nvdimm *nvdimm = nd_mapping->nvdimm;
@@ -1256,8 +1261,8 @@ int nvdimm_has_flush(struct nd_region *nd_region)
12561261
}
12571262

12581263
/*
1259-
* The platform defines dimm devices without hints, assume
1260-
* platform persistence mechanism like ADR
1264+
* The platform defines dimm devices without hints nor explicit flush,
1265+
* assume platform persistence mechanism like ADR
12611266
*/
12621267
return 0;
12631268
}

0 commit comments

Comments
 (0)