drivers/nvme/target/pr.c
Source file repositories/reference/linux-study-clean/drivers/nvme/target/pr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvme/target/pr.c- Extension
.c- Size
- 29720 bytes
- Lines
- 1156
- 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/unaligned.hnvmet.h
Detected Declarations
function Copyrightfunction nvmet_pr_find_registrantfunction list_for_each_entry_rcufunction nvmet_set_feat_resv_notif_maskfunction nvmet_for_each_enabled_nsfunction nvmet_get_feat_resv_notif_maskfunction nvmet_execute_get_log_page_resvfunction nvmet_pr_add_resv_logfunction nvmet_pr_resv_releasedfunction nvmet_pr_send_event_to_hostfunction nvmet_pr_resv_preemptedfunction nvmet_pr_registration_preemptedfunction nvmet_pr_set_new_holderfunction nvmet_pr_registerfunction nvmet_pr_unregister_onefunction nvmet_pr_unregisterfunction nvmet_pr_update_reg_rkeyfunction nvmet_pr_update_reg_attrfunction nvmet_pr_replacefunction nvmet_execute_pr_registerfunction nvmet_pr_acquirefunction nvmet_pr_confirm_ns_pc_reffunction nvmet_pr_set_ctrl_to_abortfunction xa_for_eachfunction nvmet_pr_unreg_all_host_by_prkeyfunction list_for_each_entry_safefunction nvmet_pr_unreg_all_others_by_prkeyfunction list_for_each_entry_safefunction nvmet_pr_unreg_all_othersfunction list_for_each_entry_safefunction nvmet_pr_update_holder_rtypefunction nvmet_pr_preemptfunction nvmet_pr_do_abortfunction __nvmet_execute_pr_acquirefunction nvmet_execute_pr_acquirefunction nvmet_pr_releasefunction nvmet_pr_clearfunction list_for_each_entry_safefunction __nvmet_execute_pr_releasefunction nvmet_execute_pr_releasefunction nvmet_execute_pr_reportfunction list_for_each_entry_rcufunction nvmet_parse_pr_cmdfunction nvmet_is_req_write_cmd_groupfunction nvmet_is_req_read_cmd_groupfunction nvmet_pr_check_cmd_accessfunction nvmet_pr_get_ns_pc_reffunction nvmet_pr_ctrl_ns_all_cmds_done
Annotated Snippet
nvmet_pr_find_registrant(pr, &ctrl->hostid)) {
nvmet_pr_add_resv_log(ctrl,
NVME_PR_LOG_RESERVATION_RELEASED, ns->nsid);
nvmet_add_async_event(ctrl, NVME_AER_CSS,
NVME_AEN_RESV_LOG_PAGE_AVALIABLE,
NVME_LOG_RESERVATION);
}
}
mutex_unlock(&subsys->lock);
}
static void nvmet_pr_send_event_to_host(struct nvmet_pr *pr, uuid_t *hostid,
u8 log_type)
{
struct nvmet_ns *ns = nvmet_pr_to_ns(pr);
struct nvmet_subsys *subsys = ns->subsys;
struct nvmet_ctrl *ctrl;
mutex_lock(&subsys->lock);
list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) {
if (uuid_equal(hostid, &ctrl->hostid)) {
nvmet_pr_add_resv_log(ctrl, log_type, ns->nsid);
nvmet_add_async_event(ctrl, NVME_AER_CSS,
NVME_AEN_RESV_LOG_PAGE_AVALIABLE,
NVME_LOG_RESERVATION);
}
}
mutex_unlock(&subsys->lock);
}
static void nvmet_pr_resv_preempted(struct nvmet_pr *pr, uuid_t *hostid)
{
if (test_bit(NVME_PR_NOTIFY_BIT_RESV_PREEMPTED, &pr->notify_mask))
return;
nvmet_pr_send_event_to_host(pr, hostid,
NVME_PR_LOG_RESERVATOIN_PREEMPTED);
}
static void nvmet_pr_registration_preempted(struct nvmet_pr *pr,
uuid_t *hostid)
{
if (test_bit(NVME_PR_NOTIFY_BIT_REG_PREEMPTED, &pr->notify_mask))
return;
nvmet_pr_send_event_to_host(pr, hostid,
NVME_PR_LOG_REGISTRATION_PREEMPTED);
}
static inline void nvmet_pr_set_new_holder(struct nvmet_pr *pr, u8 new_rtype,
struct nvmet_pr_registrant *reg)
{
reg->rtype = new_rtype;
rcu_assign_pointer(pr->holder, reg);
}
static u16 nvmet_pr_register(struct nvmet_req *req,
struct nvmet_pr_register_data *d)
{
struct nvmet_ctrl *ctrl = req->sq->ctrl;
struct nvmet_pr_registrant *new, *reg;
struct nvmet_pr *pr = &req->ns->pr;
u16 status = NVME_SC_SUCCESS;
u64 nrkey = le64_to_cpu(d->nrkey);
new = kmalloc_obj(*new);
if (!new)
return NVME_SC_INTERNAL;
down(&pr->pr_sem);
reg = nvmet_pr_find_registrant(pr, &ctrl->hostid);
if (reg) {
if (reg->rkey != nrkey)
status = NVME_SC_RESERVATION_CONFLICT | NVME_STATUS_DNR;
kfree(new);
goto out;
}
memset(new, 0, sizeof(*new));
INIT_LIST_HEAD(&new->entry);
new->rkey = nrkey;
uuid_copy(&new->hostid, &ctrl->hostid);
list_add_tail_rcu(&new->entry, &pr->registrant_list);
out:
up(&pr->pr_sem);
return status;
}
static void nvmet_pr_unregister_one(struct nvmet_pr *pr,
Annotation
- Immediate include surface: `linux/unaligned.h`, `nvmet.h`.
- Detected declarations: `function Copyright`, `function nvmet_pr_find_registrant`, `function list_for_each_entry_rcu`, `function nvmet_set_feat_resv_notif_mask`, `function nvmet_for_each_enabled_ns`, `function nvmet_get_feat_resv_notif_mask`, `function nvmet_execute_get_log_page_resv`, `function nvmet_pr_add_resv_log`, `function nvmet_pr_resv_released`, `function nvmet_pr_send_event_to_host`.
- 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.