drivers/target/target_core_xcopy.c
Source file repositories/reference/linux-study-clean/drivers/target/target_core_xcopy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/target/target_core_xcopy.c- Extension
.c- Size
- 29011 bytes
- Lines
- 1042
- 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/rculist.hlinux/configfs.hlinux/ratelimit.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.htarget_core_xcopy.h
Detected Declarations
struct xcopy_pt_cmdfunction target_xcopy_locate_se_dev_e4_iterfunction target_xcopy_locate_se_dev_e4function target_xcopy_parse_tiddesc_e4function destinationfunction target_xcopy_parse_target_descriptorsfunction target_xcopy_parse_segdesc_02function target_xcopy_parse_segment_descriptorsfunction xcopy_pt_get_cmd_statefunction xcopy_pt_undepend_remotedevfunction xcopy_pt_release_cmdfunction xcopy_pt_check_stop_freefunction xcopy_pt_write_pendingfunction xcopy_pt_queue_data_infunction xcopy_pt_queue_statusfunction target_xcopy_setup_ptfunction target_xcopy_release_ptfunction commandfunction target_xcopy_issue_pt_cmdfunction target_xcopy_read_sourcefunction target_xcopy_write_destinationfunction target_xcopy_do_workfunction target_parse_xcopy_cmdfunction target_do_xcopyfunction target_rcr_operating_parametersfunction target_do_receive_copy_results
Annotated Snippet
struct xcopy_pt_cmd {
struct se_cmd se_cmd;
struct completion xpt_passthrough_sem;
unsigned char sense_buffer[TRANSPORT_SENSE_BUFFER];
};
struct se_portal_group xcopy_pt_tpg;
static struct se_session xcopy_pt_sess;
static struct se_node_acl xcopy_pt_nacl;
static int xcopy_pt_get_cmd_state(struct se_cmd *se_cmd)
{
return 0;
}
static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop)
{
if (xop->op_origin == XCOL_SOURCE_RECV_OP)
pr_debug("putting dst lun_ref for %p\n", xop->dst_dev);
else
pr_debug("putting src lun_ref for %p\n", xop->src_dev);
percpu_ref_put(xop->remote_lun_ref);
}
static void xcopy_pt_release_cmd(struct se_cmd *se_cmd)
{
struct xcopy_pt_cmd *xpt_cmd = container_of(se_cmd,
struct xcopy_pt_cmd, se_cmd);
/* xpt_cmd is on the stack, nothing to free here */
pr_debug("xpt_cmd done: %p\n", xpt_cmd);
}
static int xcopy_pt_check_stop_free(struct se_cmd *se_cmd)
{
struct xcopy_pt_cmd *xpt_cmd = container_of(se_cmd,
struct xcopy_pt_cmd, se_cmd);
complete(&xpt_cmd->xpt_passthrough_sem);
return 0;
}
static int xcopy_pt_write_pending(struct se_cmd *se_cmd)
{
return 0;
}
static int xcopy_pt_queue_data_in(struct se_cmd *se_cmd)
{
return 0;
}
static int xcopy_pt_queue_status(struct se_cmd *se_cmd)
{
return 0;
}
static const struct target_core_fabric_ops xcopy_pt_tfo = {
.fabric_name = "xcopy-pt",
.get_cmd_state = xcopy_pt_get_cmd_state,
.release_cmd = xcopy_pt_release_cmd,
.check_stop_free = xcopy_pt_check_stop_free,
.write_pending = xcopy_pt_write_pending,
.queue_data_in = xcopy_pt_queue_data_in,
.queue_status = xcopy_pt_queue_status,
};
/*
* End xcopy_pt_ops
*/
int target_xcopy_setup_pt(void)
{
xcopy_wq = alloc_workqueue("xcopy_wq", WQ_MEM_RECLAIM | WQ_PERCPU, 0);
if (!xcopy_wq) {
pr_err("Unable to allocate xcopy_wq\n");
return -ENOMEM;
}
memset(&xcopy_pt_tpg, 0, sizeof(struct se_portal_group));
INIT_LIST_HEAD(&xcopy_pt_tpg.acl_node_list);
INIT_LIST_HEAD(&xcopy_pt_tpg.tpg_sess_list);
xcopy_pt_tpg.se_tpg_tfo = &xcopy_pt_tfo;
memset(&xcopy_pt_nacl, 0, sizeof(struct se_node_acl));
INIT_LIST_HEAD(&xcopy_pt_nacl.acl_list);
INIT_LIST_HEAD(&xcopy_pt_nacl.acl_sess_list);
memset(&xcopy_pt_sess, 0, sizeof(struct se_session));
Annotation
- Immediate include surface: `linux/slab.h`, `linux/spinlock.h`, `linux/list.h`, `linux/rculist.h`, `linux/configfs.h`, `linux/ratelimit.h`, `scsi/scsi_proto.h`, `linux/unaligned.h`.
- Detected declarations: `struct xcopy_pt_cmd`, `function target_xcopy_locate_se_dev_e4_iter`, `function target_xcopy_locate_se_dev_e4`, `function target_xcopy_parse_tiddesc_e4`, `function destination`, `function target_xcopy_parse_target_descriptors`, `function target_xcopy_parse_segdesc_02`, `function target_xcopy_parse_segment_descriptors`, `function xcopy_pt_get_cmd_state`, `function xcopy_pt_undepend_remotedev`.
- 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.