block/blk-integrity.c
Source file repositories/reference/linux-study-clean/block/blk-integrity.c
File Facts
- System
- Linux kernel
- Corpus path
block/blk-integrity.c- Extension
.c- Size
- 8830 bytes
- Lines
- 343
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/blk-integrity.hlinux/backing-dev.hlinux/mempool.hlinux/bio.hlinux/scatterlist.hlinux/export.hlinux/slab.hlinux/t10-pi.hblk.h
Detected Declarations
function Copyrightfunction bio_for_each_integrity_vecfunction blk_get_meta_capfunction blk_rq_integrity_map_userfunction blk_integrity_merge_rqfunction blk_integrity_merge_biofunction flag_storefunction flag_showfunction format_showfunction tag_size_showfunction protection_interval_bytes_showfunction read_verify_storefunction read_verify_showfunction write_generate_storefunction write_generate_showfunction device_is_integrity_capable_showexport blk_rq_integrity_map_userexport blk_integrity_profile_name
Annotated Snippet
if (prev) {
if (!biovec_phys_mergeable(q, &ivprv, &iv))
goto new_segment;
if (seg_size + iv.bv_len > queue_max_segment_size(q))
goto new_segment;
seg_size += iv.bv_len;
} else {
new_segment:
segments++;
seg_size = iv.bv_len;
}
prev = 1;
ivprv = iv;
}
return segments;
}
int blk_get_meta_cap(struct block_device *bdev, unsigned int cmd,
struct logical_block_metadata_cap __user *argp)
{
struct blk_integrity *bi;
struct logical_block_metadata_cap meta_cap = {};
size_t usize = _IOC_SIZE(cmd);
if (!extensible_ioctl_valid(cmd, FS_IOC_GETLBMD_CAP, LBMD_SIZE_VER0))
return -ENOIOCTLCMD;
bi = blk_get_integrity(bdev->bd_disk);
if (!bi)
goto out;
if (bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE)
meta_cap.lbmd_flags |= LBMD_PI_CAP_INTEGRITY;
if (bi->flags & BLK_INTEGRITY_REF_TAG)
meta_cap.lbmd_flags |= LBMD_PI_CAP_REFTAG;
meta_cap.lbmd_interval = 1 << bi->interval_exp;
meta_cap.lbmd_size = bi->metadata_size;
meta_cap.lbmd_pi_size = bi->pi_tuple_size;
meta_cap.lbmd_pi_offset = bi->pi_offset;
meta_cap.lbmd_opaque_size = bi->metadata_size - bi->pi_tuple_size;
if (meta_cap.lbmd_opaque_size && !bi->pi_offset)
meta_cap.lbmd_opaque_offset = bi->pi_tuple_size;
switch (bi->csum_type) {
case BLK_INTEGRITY_CSUM_NONE:
meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_NONE;
break;
case BLK_INTEGRITY_CSUM_IP:
meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_IP;
break;
case BLK_INTEGRITY_CSUM_CRC:
meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC16_T10DIF;
break;
case BLK_INTEGRITY_CSUM_CRC64:
meta_cap.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC64_NVME;
break;
}
if (bi->csum_type != BLK_INTEGRITY_CSUM_NONE)
meta_cap.lbmd_app_tag_size = 2;
if (bi->flags & BLK_INTEGRITY_REF_TAG) {
switch (bi->csum_type) {
case BLK_INTEGRITY_CSUM_CRC64:
meta_cap.lbmd_ref_tag_size =
sizeof_field(struct crc64_pi_tuple, ref_tag);
break;
case BLK_INTEGRITY_CSUM_CRC:
case BLK_INTEGRITY_CSUM_IP:
meta_cap.lbmd_ref_tag_size =
sizeof_field(struct t10_pi_tuple, ref_tag);
break;
default:
break;
}
}
out:
return copy_struct_to_user(argp, usize, &meta_cap, sizeof(meta_cap),
NULL);
}
int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf,
ssize_t bytes)
{
int ret;
struct iov_iter iter;
Annotation
- Immediate include surface: `linux/blk-integrity.h`, `linux/backing-dev.h`, `linux/mempool.h`, `linux/bio.h`, `linux/scatterlist.h`, `linux/export.h`, `linux/slab.h`, `linux/t10-pi.h`.
- Detected declarations: `function Copyright`, `function bio_for_each_integrity_vec`, `function blk_get_meta_cap`, `function blk_rq_integrity_map_user`, `function blk_integrity_merge_rq`, `function blk_integrity_merge_bio`, `function flag_store`, `function flag_show`, `function format_show`, `function tag_size_show`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration implementation candidate.
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.