drivers/nvme/target/admin-cmd.c
Source file repositories/reference/linux-study-clean/drivers/nvme/target/admin-cmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvme/target/admin-cmd.c- Extension
.c- Size
- 44436 bytes
- Lines
- 1690
- 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/module.hlinux/rculist.hlinux/part_stat.hgenerated/utsrelease.hlinux/unaligned.hnvmet.h
Detected Declarations
function Copyrightfunction nvmet_execute_create_sqfunction nvmet_execute_delete_cqfunction nvmet_execute_create_cqfunction nvmet_get_log_page_lenfunction nvmet_feat_data_lenfunction nvmet_get_log_page_offsetfunction nvmet_execute_get_log_page_noopfunction nvmet_execute_get_log_page_errorfunction nvmet_execute_get_supported_log_pagesfunction nvmet_get_smart_log_nsidfunction nvmet_get_smart_log_allfunction nvmet_execute_get_log_page_rmifunction nvmet_execute_get_log_page_smartfunction nvmet_get_cmd_effects_adminfunction nvmet_get_cmd_effects_nvmfunction nvmet_get_cmd_effects_znsfunction nvmet_execute_get_log_cmd_effects_nsfunction nvmet_execute_get_log_changed_nsfunction nvmet_format_ana_groupfunction nvmet_execute_get_log_page_endgrpfunction nvmet_execute_get_log_page_anafunction nvmet_execute_get_log_page_featuresfunction nvmet_execute_get_log_pagefunction nvmet_execute_identify_ctrlfunction nvmet_execute_identify_nsfunction nvmet_execute_identify_endgrp_listfunction nvmet_for_each_enabled_nsfunction nvmet_execute_identify_nslistfunction nvmet_for_each_enabled_nsfunction nvmet_copy_ns_identifierfunction nvmet_execute_identify_desclistfunction nvmet_execute_identify_ctrl_nvmfunction nvme_execute_identify_ns_nvmfunction nvmet_execute_id_cs_indepfunction nvmet_execute_identifyfunction nvmet_execute_abortfunction nvmet_write_protect_flush_syncfunction nvmet_set_feat_write_protectfunction nvmet_set_feat_katofunction nvmet_set_feat_async_eventfunction nvmet_set_feat_host_idfunction IDsfunction nvmet_set_feat_irq_coalescefunction nvmet_set_feat_irq_configfunction nvmet_set_feat_arbitrationfunction nvmet_execute_set_featuresfunction nvmet_get_feat_write_protect
Annotated Snippet
if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED)) {
status = NVME_SC_INVALID_IO_CMD_SET;
goto free;
}
nvmet_get_cmd_effects_admin(ctrl, log);
nvmet_get_cmd_effects_nvm(log);
nvmet_get_cmd_effects_zns(log);
break;
default:
status = NVME_SC_INVALID_LOG_PAGE;
goto free;
}
status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
free:
kfree(log);
out:
nvmet_req_complete(req, status);
}
static void nvmet_execute_get_log_changed_ns(struct nvmet_req *req)
{
struct nvmet_ctrl *ctrl = req->sq->ctrl;
u16 status = NVME_SC_INTERNAL;
size_t len;
if (req->transfer_len != NVME_MAX_CHANGED_NAMESPACES * sizeof(__le32))
goto out;
mutex_lock(&ctrl->lock);
if (ctrl->nr_changed_ns == U32_MAX)
len = sizeof(__le32);
else
len = ctrl->nr_changed_ns * sizeof(__le32);
status = nvmet_copy_to_sgl(req, 0, ctrl->changed_ns_list, len);
if (!status)
status = nvmet_zero_sgl(req, len, req->transfer_len - len);
ctrl->nr_changed_ns = 0;
nvmet_clear_aen_bit(req, NVME_AEN_BIT_NS_ATTR);
mutex_unlock(&ctrl->lock);
out:
nvmet_req_complete(req, status);
}
static u32 nvmet_format_ana_group(struct nvmet_req *req, u32 grpid,
struct nvme_ana_group_desc *desc)
{
struct nvmet_ctrl *ctrl = req->sq->ctrl;
struct nvmet_ns *ns;
unsigned long idx;
u32 count = 0;
if (!(req->cmd->get_log_page.lsp & NVME_ANA_LOG_RGO)) {
nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) {
if (ns->anagrpid == grpid)
desc->nsids[count++] = cpu_to_le32(ns->nsid);
}
}
desc->grpid = cpu_to_le32(grpid);
desc->nnsids = cpu_to_le32(count);
desc->chgcnt = cpu_to_le64(nvmet_ana_chgcnt);
desc->state = req->port->ana_state[grpid];
memset(desc->rsvd17, 0, sizeof(desc->rsvd17));
return struct_size(desc, nsids, count);
}
static void nvmet_execute_get_log_page_endgrp(struct nvmet_req *req)
{
u64 host_reads, host_writes, data_units_read, data_units_written;
struct nvme_endurance_group_log *log;
u16 status;
/*
* The target driver emulates each endurance group as its own
* namespace, reusing the nsid as the endurance group identifier.
*/
req->cmd->common.nsid = cpu_to_le32(le16_to_cpu(
req->cmd->get_log_page.lsi));
status = nvmet_req_find_ns(req);
if (status)
goto out;
log = kzalloc_obj(*log);
if (!log) {
status = NVME_SC_INTERNAL;
goto out;
}
if (!req->ns->bdev)
Annotation
- Immediate include surface: `linux/module.h`, `linux/rculist.h`, `linux/part_stat.h`, `generated/utsrelease.h`, `linux/unaligned.h`, `nvmet.h`.
- Detected declarations: `function Copyright`, `function nvmet_execute_create_sq`, `function nvmet_execute_delete_cq`, `function nvmet_execute_create_cq`, `function nvmet_get_log_page_len`, `function nvmet_feat_data_len`, `function nvmet_get_log_page_offset`, `function nvmet_execute_get_log_page_noop`, `function nvmet_execute_get_log_page_error`, `function nvmet_execute_get_supported_log_pages`.
- 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.