drivers/nvme/target/configfs.c
Source file repositories/reference/linux-study-clean/drivers/nvme/target/configfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvme/target/configfs.c- Extension
.c- Size
- 58958 bytes
- Lines
- 2405
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- 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/hex.hlinux/kstrtox.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/stat.hlinux/ctype.hlinux/pci.hlinux/pci-p2pdma.hlinux/nvme-auth.hlinux/nvme-keyring.hcrypto/kpp.hlinux/nospec.hnvmet.h
Detected Declarations
struct nvmet_type_name_mapfunction nvmet_is_port_enabledfunction nvmet_addr_adrfam_showfunction nvmet_addr_adrfam_storefunction nvmet_addr_portid_showfunction nvmet_addr_portid_storefunction nvmet_addr_traddr_showfunction nvmet_addr_traddr_storefunction nvmet_port_disc_addr_treq_maskfunction nvmet_addr_treq_showfunction nvmet_addr_treq_storefunction nvmet_addr_trsvcid_showfunction nvmet_addr_trsvcid_storefunction nvmet_param_inline_data_size_showfunction nvmet_param_inline_data_size_storefunction nvmet_param_max_queue_size_showfunction nvmet_param_max_queue_size_storefunction nvmet_param_mdts_showfunction nvmet_param_mdts_storefunction nvmet_param_pi_enable_showfunction nvmet_param_pi_enable_storefunction nvmet_addr_trtype_showfunction nvmet_port_init_tsas_rdmafunction nvmet_port_init_tsas_tcpfunction nvmet_addr_trtype_storefunction nvmet_addr_tsas_showfunction nvmet_addr_tsas_rdma_storefunction nvmet_addr_tsas_tcp_storefunction nvmet_addr_tsas_storefunction nvmet_ns_device_path_showfunction nvmet_ns_device_path_storefunction nvmet_ns_p2pmem_showfunction nvmet_ns_p2pmem_storefunction nvmet_ns_device_uuid_showfunction nvmet_ns_device_uuid_storefunction nvmet_ns_device_nguid_showfunction nvmet_ns_device_nguid_storefunction nvmet_ns_ana_grpid_showfunction nvmet_ns_ana_grpid_storefunction nvmet_ns_enable_showfunction nvmet_ns_enable_storefunction nvmet_ns_buffered_io_showfunction nvmet_ns_buffered_io_storefunction nvmet_ns_revalidate_size_storefunction nvmet_ns_resv_enable_showfunction nvmet_ns_resv_enable_storefunction nvmet_ns_releasefunction nvmet_passthru_device_path_show
Annotated Snippet
struct nvmet_type_name_map {
u8 type;
const char *name;
};
static struct nvmet_type_name_map nvmet_transport[] = {
{ NVMF_TRTYPE_RDMA, "rdma" },
{ NVMF_TRTYPE_FC, "fc" },
{ NVMF_TRTYPE_TCP, "tcp" },
{ NVMF_TRTYPE_PCI, "pci" },
{ NVMF_TRTYPE_LOOP, "loop" },
};
static const struct nvmet_type_name_map nvmet_addr_family[] = {
{ NVMF_ADDR_FAMILY_PCI, "pcie" },
{ NVMF_ADDR_FAMILY_IP4, "ipv4" },
{ NVMF_ADDR_FAMILY_IP6, "ipv6" },
{ NVMF_ADDR_FAMILY_IB, "ib" },
{ NVMF_ADDR_FAMILY_FC, "fc" },
{ NVMF_ADDR_FAMILY_PCI, "pci" },
{ NVMF_ADDR_FAMILY_LOOP, "loop" },
};
static bool nvmet_is_port_enabled(struct nvmet_port *p, const char *caller)
{
if (p->enabled)
pr_err("Disable port '%u' before changing attribute in %s\n",
le16_to_cpu(p->disc_addr.portid), caller);
return p->enabled;
}
/*
* nvmet_port Generic ConfigFS definitions.
* Used in any place in the ConfigFS tree that refers to an address.
*/
static ssize_t nvmet_addr_adrfam_show(struct config_item *item, char *page)
{
u8 adrfam = to_nvmet_port(item)->disc_addr.adrfam;
int i;
for (i = 1; i < ARRAY_SIZE(nvmet_addr_family); i++) {
if (nvmet_addr_family[i].type == adrfam)
return snprintf(page, PAGE_SIZE, "%s\n",
nvmet_addr_family[i].name);
}
return snprintf(page, PAGE_SIZE, "\n");
}
static ssize_t nvmet_addr_adrfam_store(struct config_item *item,
const char *page, size_t count)
{
struct nvmet_port *port = to_nvmet_port(item);
int i;
if (nvmet_is_port_enabled(port, __func__))
return -EACCES;
for (i = 1; i < ARRAY_SIZE(nvmet_addr_family); i++) {
if (sysfs_streq(page, nvmet_addr_family[i].name))
goto found;
}
pr_err("Invalid value '%s' for adrfam\n", page);
return -EINVAL;
found:
port->disc_addr.adrfam = nvmet_addr_family[i].type;
return count;
}
CONFIGFS_ATTR(nvmet_, addr_adrfam);
static ssize_t nvmet_addr_portid_show(struct config_item *item,
char *page)
{
__le16 portid = to_nvmet_port(item)->disc_addr.portid;
return snprintf(page, PAGE_SIZE, "%d\n", le16_to_cpu(portid));
}
static ssize_t nvmet_addr_portid_store(struct config_item *item,
const char *page, size_t count)
{
struct nvmet_port *port = to_nvmet_port(item);
u16 portid = 0;
if (kstrtou16(page, 0, &portid)) {
pr_err("Invalid value '%s' for portid\n", page);
return -EINVAL;
Annotation
- Immediate include surface: `linux/hex.h`, `linux/kstrtox.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/stat.h`, `linux/ctype.h`, `linux/pci.h`.
- Detected declarations: `struct nvmet_type_name_map`, `function nvmet_is_port_enabled`, `function nvmet_addr_adrfam_show`, `function nvmet_addr_adrfam_store`, `function nvmet_addr_portid_show`, `function nvmet_addr_portid_store`, `function nvmet_addr_traddr_show`, `function nvmet_addr_traddr_store`, `function nvmet_port_disc_addr_treq_mask`, `function nvmet_addr_treq_show`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source 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.