Commit 298f2bc5 authored by Dan Williams's avatar Dan Williams

libnvdimm, pmem: kill pmem->ndns

We can derive the common namespace from other information.  We also do
not need to cache it because all the usages are in slow paths.
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent c3b46c73
...@@ -336,7 +336,7 @@ static int nd_blk_remove(struct device *dev) ...@@ -336,7 +336,7 @@ static int nd_blk_remove(struct device *dev)
struct nd_blk_device *blk_dev = dev_get_drvdata(dev); struct nd_blk_device *blk_dev = dev_get_drvdata(dev);
if (is_nd_btt(dev)) if (is_nd_btt(dev))
nvdimm_namespace_detach_btt(to_nd_btt(dev)->ndns); nvdimm_namespace_detach_btt(to_nd_btt(dev));
else else
nd_blk_detach_disk(blk_dev); nd_blk_detach_disk(blk_dev);
kfree(blk_dev); kfree(blk_dev);
......
...@@ -1406,9 +1406,8 @@ int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns) ...@@ -1406,9 +1406,8 @@ int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns)
} }
EXPORT_SYMBOL(nvdimm_namespace_attach_btt); EXPORT_SYMBOL(nvdimm_namespace_attach_btt);
int nvdimm_namespace_detach_btt(struct nd_namespace_common *ndns) int nvdimm_namespace_detach_btt(struct nd_btt *nd_btt)
{ {
struct nd_btt *nd_btt = to_nd_btt(ndns->claim);
struct btt *btt = nd_btt->btt; struct btt *btt = nd_btt->btt;
btt_fini(btt); btt_fini(btt);
......
...@@ -263,7 +263,7 @@ struct resource *nvdimm_allocate_dpa(struct nvdimm_drvdata *ndd, ...@@ -263,7 +263,7 @@ struct resource *nvdimm_allocate_dpa(struct nvdimm_drvdata *ndd,
resource_size_t nvdimm_namespace_capacity(struct nd_namespace_common *ndns); resource_size_t nvdimm_namespace_capacity(struct nd_namespace_common *ndns);
struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev); struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev);
int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns); int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns);
int nvdimm_namespace_detach_btt(struct nd_namespace_common *ndns); int nvdimm_namespace_detach_btt(struct nd_btt *nd_btt);
const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns, const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns,
char *name); char *name);
void nvdimm_badblocks_populate(struct nd_region *nd_region, void nvdimm_badblocks_populate(struct nd_region *nd_region,
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
struct pmem_device { struct pmem_device {
struct request_queue *pmem_queue; struct request_queue *pmem_queue;
struct gendisk *pmem_disk; struct gendisk *pmem_disk;
struct nd_namespace_common *ndns;
/* One contiguous memory region per device */ /* One contiguous memory region per device */
phys_addr_t phys_addr; phys_addr_t phys_addr;
...@@ -436,9 +435,8 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) ...@@ -436,9 +435,8 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
return -ENXIO; return -ENXIO;
} }
static int nvdimm_namespace_detach_pfn(struct nd_namespace_common *ndns) static int nvdimm_namespace_detach_pfn(struct nd_pfn *nd_pfn)
{ {
struct nd_pfn *nd_pfn = to_nd_pfn(ndns->claim);
struct pmem_device *pmem; struct pmem_device *pmem;
/* free pmem disk */ /* free pmem disk */
...@@ -537,7 +535,7 @@ static int __nvdimm_namespace_attach_pfn(struct nd_pfn *nd_pfn) ...@@ -537,7 +535,7 @@ static int __nvdimm_namespace_attach_pfn(struct nd_pfn *nd_pfn)
return rc; return rc;
err: err:
nvdimm_namespace_detach_pfn(ndns); nvdimm_namespace_detach_pfn(nd_pfn);
return rc; return rc;
} }
...@@ -573,7 +571,6 @@ static int nd_pmem_probe(struct device *dev) ...@@ -573,7 +571,6 @@ static int nd_pmem_probe(struct device *dev)
if (IS_ERR(pmem)) if (IS_ERR(pmem))
return PTR_ERR(pmem); return PTR_ERR(pmem);
pmem->ndns = ndns;
dev_set_drvdata(dev, pmem); dev_set_drvdata(dev, pmem);
ndns->rw_bytes = pmem_rw_bytes; ndns->rw_bytes = pmem_rw_bytes;
if (devm_init_badblocks(dev, &pmem->bb)) if (devm_init_badblocks(dev, &pmem->bb))
...@@ -607,9 +604,9 @@ static int nd_pmem_remove(struct device *dev) ...@@ -607,9 +604,9 @@ static int nd_pmem_remove(struct device *dev)
struct pmem_device *pmem = dev_get_drvdata(dev); struct pmem_device *pmem = dev_get_drvdata(dev);
if (is_nd_btt(dev)) if (is_nd_btt(dev))
nvdimm_namespace_detach_btt(pmem->ndns); nvdimm_namespace_detach_btt(to_nd_btt(dev));
else if (is_nd_pfn(dev)) else if (is_nd_pfn(dev))
nvdimm_namespace_detach_pfn(pmem->ndns); nvdimm_namespace_detach_pfn(to_nd_pfn(dev));
else else
pmem_detach_disk(pmem); pmem_detach_disk(pmem);
...@@ -618,26 +615,33 @@ static int nd_pmem_remove(struct device *dev) ...@@ -618,26 +615,33 @@ static int nd_pmem_remove(struct device *dev)
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 nd_namespace_common *ndns = pmem->ndns;
struct nd_region *nd_region = to_nd_region(dev->parent); struct nd_region *nd_region = to_nd_region(dev->parent);
struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev); struct pmem_device *pmem = dev_get_drvdata(dev);
struct resource res = { resource_size_t offset = 0, end_trunc = 0;
.start = nsio->res.start + pmem->data_offset, struct nd_namespace_common *ndns;
.end = nsio->res.end, struct nd_namespace_io *nsio;
}; struct resource res;
if (event != NVDIMM_REVALIDATE_POISON) if (event != NVDIMM_REVALIDATE_POISON)
return; return;
if (is_nd_pfn(dev)) { if (is_nd_btt(dev)) {
struct nd_btt *nd_btt = to_nd_btt(dev);
ndns = nd_btt->ndns;
} else if (is_nd_pfn(dev)) {
struct nd_pfn *nd_pfn = to_nd_pfn(dev); struct nd_pfn *nd_pfn = to_nd_pfn(dev);
struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb; struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb;
res.start += __le32_to_cpu(pfn_sb->start_pad); ndns = nd_pfn->ndns;
res.end -= __le32_to_cpu(pfn_sb->end_trunc); offset = pmem->data_offset + __le32_to_cpu(pfn_sb->start_pad);
} end_trunc = __le32_to_cpu(pfn_sb->end_trunc);
} else
ndns = to_ndns(dev);
nsio = to_nd_namespace_io(&ndns->dev);
res.start = nsio->res.start + offset;
res.end = nsio->res.end - end_trunc;
nvdimm_badblocks_populate(nd_region, &pmem->bb, &res); nvdimm_badblocks_populate(nd_region, &pmem->bb, &res);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment