drivers/nvdimm/namespace_devs.c
Source file repositories/reference/linux-study-clean/drivers/nvdimm/namespace_devs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvdimm/namespace_devs.c- Extension
.c- Size
- 56294 bytes
- Lines
- 2232
- Domain
- Driver Families
- Bucket
- drivers/nvdimm
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kstrtox.hlinux/module.hlinux/device.hlinux/sort.hlinux/slab.hlinux/list.hlinux/nd.hnd-core.hpmem.hpfn.hnd.h
Detected Declarations
enum alloc_locfunction Copyrightfunction namespace_pmem_releasefunction is_uuid_busyfunction is_namespace_uuid_busyfunction nd_is_uuid_uniquefunction pmem_should_map_pagesfunction pmem_sector_sizefunction nstype_showfunction __alt_name_storefunction nd_namespace_label_updatefunction alt_name_storefunction alt_name_showfunction scan_freefunction adjust_resourcefunction init_dpa_allocationfunction space_validfunction scan_allocatefunction merge_dpafunction __reserve_free_pmemfunction release_free_pmemfunction grow_dpa_allocationfunction nd_namespace_pmem_set_resourcefunction for_each_dpa_resourcefunction uuid_not_setfunction __size_storefunction size_storefunction __nvdimm_namespace_capacityfunction nvdimm_namespace_capacityfunction nvdimm_namespace_lockedfunction size_showfunction uuid_showfunction namespace_update_uuidfunction list_for_each_entryfunction uuid_storefunction resource_showfunction sector_size_showfunction sector_size_storefunction dpa_extents_showfunction btt_claim_classfunction holder_showfunction __holder_class_storefunction holder_class_storefunction holder_class_showfunction mode_showfunction force_raw_storefunction force_raw_showfunction namespace_visible
Annotated Snippet
if (is_namespace_pmem(&ndns->dev)) {
struct nd_namespace_pmem *nspm;
nspm = to_nd_namespace_pmem(&ndns->dev);
nsidx = nspm->id;
}
if (nsidx)
sprintf(name, "pmem%d.%d%s", nd_region->id, nsidx,
suffix ? suffix : "");
else
sprintf(name, "pmem%d%s", nd_region->id,
suffix ? suffix : "");
} else {
return NULL;
}
return name;
}
EXPORT_SYMBOL(nvdimm_namespace_disk_name);
const uuid_t *nd_dev_to_uuid(struct device *dev)
{
if (dev && is_namespace_pmem(dev)) {
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
return nspm->uuid;
}
return &uuid_null;
}
EXPORT_SYMBOL(nd_dev_to_uuid);
static ssize_t nstype_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct nd_region *nd_region = to_nd_region(dev->parent);
return sprintf(buf, "%d\n", nd_region_to_nstype(nd_region));
}
static DEVICE_ATTR_RO(nstype);
static ssize_t __alt_name_store(struct device *dev, const char *buf,
const size_t len)
{
char *input, *pos, *alt_name, **ns_altname;
ssize_t rc;
if (is_namespace_pmem(dev)) {
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
ns_altname = &nspm->alt_name;
} else
return -ENXIO;
if (dev->driver || to_ndns(dev)->claim)
return -EBUSY;
input = kstrndup(buf, len, GFP_KERNEL);
if (!input)
return -ENOMEM;
pos = strim(input);
if (strlen(pos) + 1 > NSLABEL_NAME_LEN) {
rc = -EINVAL;
goto out;
}
alt_name = kzalloc(NSLABEL_NAME_LEN, GFP_KERNEL);
if (!alt_name) {
rc = -ENOMEM;
goto out;
}
kfree(*ns_altname);
*ns_altname = alt_name;
sprintf(*ns_altname, "%s", pos);
rc = len;
out:
kfree(input);
return rc;
}
static int nd_namespace_label_update(struct nd_region *nd_region,
struct device *dev)
{
dev_WARN_ONCE(dev, dev->driver || to_ndns(dev)->claim,
"namespace must be idle during label update\n");
if (dev->driver || to_ndns(dev)->claim)
return 0;
Annotation
- Immediate include surface: `linux/kstrtox.h`, `linux/module.h`, `linux/device.h`, `linux/sort.h`, `linux/slab.h`, `linux/list.h`, `linux/nd.h`, `nd-core.h`.
- Detected declarations: `enum alloc_loc`, `function Copyright`, `function namespace_pmem_release`, `function is_uuid_busy`, `function is_namespace_uuid_busy`, `function nd_is_uuid_unique`, `function pmem_should_map_pages`, `function pmem_sector_size`, `function nstype_show`, `function __alt_name_store`.
- Atlas domain: Driver Families / drivers/nvdimm.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.