drivers/target/target_core_ua.c
Source file repositories/reference/linux-study-clean/drivers/target/target_core_ua.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/target/target_core_ua.c- Extension
.c- Size
- 8472 bytes
- Lines
- 324
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/spinlock.hscsi/scsi_proto.htarget/target_core_base.htarget/target_core_fabric.htarget_core_internal.htarget_core_alua.htarget_core_pr.htarget_core_ua.h
Detected Declarations
function target_scsi3_ua_checkfunction core_scsi3_ua_allocatefunction target_ua_allocate_lunfunction core_scsi3_ua_release_allfunction core_scsi3_ua_for_check_conditionfunction core_scsi3_ua_clear_for_request_sense
Annotated Snippet
if ((ua_p->ua_asc == asc) && (ua_p->ua_ascq == ascq)) {
spin_unlock(&deve->ua_lock);
kmem_cache_free(se_ua_cache, ua);
return 0;
}
/*
* Attach the highest priority Unit Attention to
* the head of the list following sam4r14,
* Section 5.14 Unit Attention Condition:
*
* POWER ON, RESET, OR BUS DEVICE RESET OCCURRED highest
* POWER ON OCCURRED or
* DEVICE INTERNAL RESET
* SCSI BUS RESET OCCURRED or
* MICROCODE HAS BEEN CHANGED or
* protocol specific
* BUS DEVICE RESET FUNCTION OCCURRED
* I_T NEXUS LOSS OCCURRED
* COMMANDS CLEARED BY POWER LOSS NOTIFICATION
* all others Lowest
*
* Each of the ASCQ codes listed above are defined in
* the 29h ASC family, see spc4r17 Table D.1
*/
if (ua_p->ua_asc == 0x29) {
if ((asc == 0x29) && (ascq > ua_p->ua_ascq))
list_add(&ua->ua_nacl_list,
&deve->ua_list);
else
list_add_tail(&ua->ua_nacl_list,
&deve->ua_list);
} else if (ua_p->ua_asc == 0x2a) {
/*
* Incoming Family 29h ASCQ codes will override
* Family 2AHh ASCQ codes for Unit Attention condition.
*/
if ((asc == 0x29) || (ascq > ua_p->ua_asc))
list_add(&ua->ua_nacl_list,
&deve->ua_list);
else
list_add_tail(&ua->ua_nacl_list,
&deve->ua_list);
} else
list_add_tail(&ua->ua_nacl_list,
&deve->ua_list);
spin_unlock(&deve->ua_lock);
return 0;
}
list_add_tail(&ua->ua_nacl_list, &deve->ua_list);
spin_unlock(&deve->ua_lock);
pr_debug("Allocated UNIT ATTENTION, mapped LUN: %llu, ASC:"
" 0x%02x, ASCQ: 0x%02x\n", deve->mapped_lun,
asc, ascq);
return 0;
}
void target_ua_allocate_lun(struct se_node_acl *nacl,
u32 unpacked_lun, u8 asc, u8 ascq)
{
struct se_dev_entry *deve;
if (!nacl)
return;
rcu_read_lock();
deve = target_nacl_find_deve(nacl, unpacked_lun);
if (!deve) {
rcu_read_unlock();
return;
}
core_scsi3_ua_allocate(deve, asc, ascq);
rcu_read_unlock();
}
void core_scsi3_ua_release_all(
struct se_dev_entry *deve)
{
struct se_ua *ua, *ua_p;
spin_lock(&deve->ua_lock);
list_for_each_entry_safe(ua, ua_p, &deve->ua_list, ua_nacl_list) {
list_del(&ua->ua_nacl_list);
kmem_cache_free(se_ua_cache, ua);
}
spin_unlock(&deve->ua_lock);
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/spinlock.h`, `scsi/scsi_proto.h`, `target/target_core_base.h`, `target/target_core_fabric.h`, `target_core_internal.h`, `target_core_alua.h`, `target_core_pr.h`.
- Detected declarations: `function target_scsi3_ua_check`, `function core_scsi3_ua_allocate`, `function target_ua_allocate_lun`, `function core_scsi3_ua_release_all`, `function core_scsi3_ua_for_check_condition`, `function core_scsi3_ua_clear_for_request_sense`.
- 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.