Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libnvdimm/pfn_dev: Don't clear device memmap area during generic namespace probe

nvdimm core use nd_pfn_validate when looking for devdax or fsdax namespace. In this
case device resources are allocated against nd_namespace_io dev. In-order to
allow remap of range in nd_pfn_clear_memmap_error(), move the device memmap
area clearing while initializing pfn namespace. With this device
resource are allocated against nd_pfn and we can use nd_pfn->dev for remapping.

This also avoids calling nd_pfn_clear_mmap_errors twice. Once while probing the
namespace and second while initializing a pfn namespace.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Link: https://lore.kernel.org/r/20191101032728.113001-1-aneesh.kumar@linux.ibm.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

authored by

Aneesh Kumar K.V and committed by
Dan Williams
c1f45d86 2f474149

+7 -1
+7 -1
drivers/nvdimm/pfn_devs.c
··· 591 591 return -ENXIO; 592 592 } 593 593 594 - return nd_pfn_clear_memmap_errors(nd_pfn); 594 + return 0; 595 595 } 596 596 EXPORT_SYMBOL(nd_pfn_validate); 597 597 ··· 729 729 sig = PFN_SIG; 730 730 731 731 rc = nd_pfn_validate(nd_pfn, sig); 732 + if (rc == 0) 733 + return nd_pfn_clear_memmap_errors(nd_pfn); 732 734 if (rc != -ENODEV) 733 735 return rc; 734 736 ··· 797 795 pfn_sb->page_size = cpu_to_le32(PAGE_SIZE); 798 796 checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); 799 797 pfn_sb->checksum = cpu_to_le64(checksum); 798 + 799 + rc = nd_pfn_clear_memmap_errors(nd_pfn); 800 + if (rc) 801 + return rc; 800 802 801 803 return nvdimm_write_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb), 0); 802 804 }