drivers/md/dm-pcache/segment.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-pcache/segment.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-pcache/segment.c- Extension
.c- Size
- 1673 bytes
- Lines
- 62
- Domain
- Driver Families
- Bucket
- drivers/md
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dax.hpcache_internal.hcache_dev.hsegment.h
Detected Declarations
function segment_copy_to_biofunction segment_copy_from_biofunction pcache_segment_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
#include <linux/dax.h>
#include "pcache_internal.h"
#include "cache_dev.h"
#include "segment.h"
int segment_copy_to_bio(struct pcache_segment *segment,
u32 data_off, u32 data_len, struct bio *bio, u32 bio_off)
{
struct iov_iter iter;
size_t copied;
void *src;
iov_iter_bvec(&iter, ITER_DEST, &bio->bi_io_vec[bio->bi_iter.bi_idx],
bio_segments(bio), bio->bi_iter.bi_size);
iter.iov_offset = bio->bi_iter.bi_bvec_done;
if (bio_off)
iov_iter_advance(&iter, bio_off);
src = segment->data + data_off;
copied = _copy_mc_to_iter(src, data_len, &iter);
if (copied != data_len)
return -EIO;
return 0;
}
int segment_copy_from_bio(struct pcache_segment *segment,
u32 data_off, u32 data_len, struct bio *bio, u32 bio_off)
{
struct iov_iter iter;
size_t copied;
void *dst;
iov_iter_bvec(&iter, ITER_SOURCE, &bio->bi_io_vec[bio->bi_iter.bi_idx],
bio_segments(bio), bio->bi_iter.bi_size);
iter.iov_offset = bio->bi_iter.bi_bvec_done;
if (bio_off)
iov_iter_advance(&iter, bio_off);
dst = segment->data + data_off;
copied = _copy_from_iter_flushcache(dst, data_len, &iter);
if (copied != data_len)
return -EIO;
pmem_wmb();
return 0;
}
void pcache_segment_init(struct pcache_cache_dev *cache_dev, struct pcache_segment *segment,
struct pcache_segment_init_options *options)
{
segment->seg_info = options->seg_info;
segment_info_set_type(segment->seg_info, options->type);
segment->cache_dev = cache_dev;
segment->seg_id = options->seg_id;
segment->data_size = PCACHE_SEG_SIZE - options->data_off;
segment->data = CACHE_DEV_SEGMENT(cache_dev, options->seg_id) + options->data_off;
}
Annotation
- Immediate include surface: `linux/dax.h`, `pcache_internal.h`, `cache_dev.h`, `segment.h`.
- Detected declarations: `function segment_copy_to_bio`, `function segment_copy_from_bio`, `function pcache_segment_init`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: source 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.