drivers/target/target_core_pr.c
Source file repositories/reference/linux-study-clean/drivers/target/target_core_pr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/target/target_core_pr.c- Extension
.c- Size
- 127616 bytes
- Lines
- 4197
- Domain
- Driver Families
- Bucket
- drivers/target
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/slab.hlinux/spinlock.hlinux/list.hlinux/vmalloc.hlinux/file.hlinux/fcntl.hlinux/fs.hscsi/scsi_proto.hlinux/unaligned.htarget/target_core_base.htarget/target_core_backend.htarget/target_core_fabric.htarget_core_internal.htarget_core_pr.htarget_core_ua.h
Detected Declarations
struct pr_transport_id_holderenum register_typeenum preempt_typefunction core_pr_dump_initiator_portfunction is_reservation_holderfunction target_scsi2_reservation_checkfunction target_check_scsi2_reservation_conflictfunction RELEASEfunction target_release_reservationfunction target_scsi2_reservation_releasefunction target_scsi2_reservation_reservefunction core_scsi3_pr_seq_non_holderfunction target_scsi3_pr_reservation_checkfunction core_scsi3_pr_generationfunction core_get_se_deve_from_rtpifunction list_for_each_entryfunction core_scsi3_alloc_aptpl_registrationfunction core_scsi3_aptpl_reservefunction __core_scsi3_check_aptpl_registrationfunction core_scsi3_check_aptpl_registrationfunction __core_scsi3_dump_registrationfunction __core_scsi3_add_registrationfunction __core_scsi3_alloc_registrationfunction core_scsi3_alloc_registrationfunction core_scsi3_put_pr_regfunction core_scsi3_check_implicit_releasefunction core_scsi3_pr_seq_non_holderfunction __core_scsi3_free_registrationfunction core_scsi3_put_pr_regfunction core_scsi3_free_pr_reg_from_naclfunction list_for_each_entry_safefunction core_scsi3_free_all_registrationsfunction core_scsi3_tpg_depend_itemfunction core_scsi3_tpg_undepend_itemfunction core_scsi3_nodeacl_depend_itemfunction core_scsi3_nodeacl_undepend_itemfunction core_scsi3_lunacl_depend_itemfunction core_scsi3_lunacl_undepend_itemfunction core_scsi3_decode_spec_i_portfunction list_for_each_entryfunction modulesfunction list_for_each_entry_safefunction core_scsi3_update_aptpl_buffunction __core_scsi3_write_aptpl_to_filefunction core_scsi3_update_and_write_aptplfunction core_scsi3_emulate_pro_registerfunction core_scsi3_pro_reservefunction holder
Annotated Snippet
struct pr_transport_id_holder {
struct t10_pr_registration *dest_pr_reg;
struct se_portal_group *dest_tpg;
struct se_node_acl *dest_node_acl;
struct se_dev_entry *dest_se_deve;
struct list_head dest_list;
};
void core_pr_dump_initiator_port(
struct t10_pr_registration *pr_reg,
char *buf,
u32 size)
{
if (!pr_reg->isid_present_at_reg) {
buf[0] = '\0';
return;
}
snprintf(buf, size, ",i,0x%s", pr_reg->pr_reg_isid);
}
enum register_type {
REGISTER,
REGISTER_AND_IGNORE_EXISTING_KEY,
REGISTER_AND_MOVE,
};
enum preempt_type {
PREEMPT,
PREEMPT_AND_ABORT,
};
static void __core_scsi3_complete_pro_release(struct se_device *, struct se_node_acl *,
struct t10_pr_registration *, int, int);
static int is_reservation_holder(
struct t10_pr_registration *pr_res_holder,
struct t10_pr_registration *pr_reg)
{
int pr_res_type;
if (pr_res_holder) {
pr_res_type = pr_res_holder->pr_res_type;
return pr_res_holder == pr_reg ||
pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_ALLREG ||
pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_ALLREG;
}
return 0;
}
static sense_reason_t
target_scsi2_reservation_check(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_dev;
struct se_session *sess = cmd->se_sess;
switch (cmd->t_task_cdb[0]) {
case INQUIRY:
case RELEASE_6:
case RELEASE_10:
return 0;
default:
break;
}
if (!dev->reservation_holder || !sess)
return 0;
if (dev->reservation_holder->se_node_acl != sess->se_node_acl)
return TCM_RESERVATION_CONFLICT;
if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS_WITH_ISID) {
if (dev->dev_res_bin_isid != sess->sess_bin_isid)
return TCM_RESERVATION_CONFLICT;
}
return 0;
}
static struct t10_pr_registration *core_scsi3_locate_pr_reg(struct se_device *,
struct se_node_acl *, struct se_session *);
static void core_scsi3_put_pr_reg(struct t10_pr_registration *);
static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd)
{
struct se_session *se_sess = cmd->se_sess;
struct se_device *dev = cmd->se_dev;
struct t10_pr_registration *pr_reg;
struct t10_reservation *pr_tmpl = &dev->t10_pr;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/spinlock.h`, `linux/list.h`, `linux/vmalloc.h`, `linux/file.h`, `linux/fcntl.h`, `linux/fs.h`, `scsi/scsi_proto.h`.
- Detected declarations: `struct pr_transport_id_holder`, `enum register_type`, `enum preempt_type`, `function core_pr_dump_initiator_port`, `function is_reservation_holder`, `function target_scsi2_reservation_check`, `function target_check_scsi2_reservation_conflict`, `function RELEASE`, `function target_release_reservation`, `function target_scsi2_reservation_release`.
- Atlas domain: Driver Families / drivers/target.
- 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.