include/linux/bvec.h
Source file repositories/reference/linux-study-clean/include/linux/bvec.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/bvec.h- Extension
.h- Size
- 9156 bytes
- Lines
- 347
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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/highmem.hlinux/bug.hlinux/errno.hlinux/limits.hlinux/minmax.hlinux/types.h
Detected Declarations
struct pagestruct bio_vecstruct bvec_iterstruct bvec_iter_allfunction bvec_set_pagefunction bvec_set_foliofunction bvec_set_virtfunction bio_for_each_folio_allfunction __bvec_iter_bvecfunction mp_bvec_iter_pagefunction mp_bvec_iter_lenfunction mp_bvec_iter_offsetfunction mp_bvec_iter_page_idxfunction mp_bvec_iter_bvecfunction bvec_iter_offsetfunction bvec_iter_lenfunction bvec_iter_pagefunction bvec_iter_bvecfunction bvec_iter_advancefunction bvec_iter_advancefunction bvec_iter_advance_singlefunction bvec_advancefunction memcpy_from_bvecfunction memcpy_to_bvecfunction memzero_bvecfunction bvec_phys
Annotated Snippet
struct bio_vec {
struct page *bv_page;
unsigned int bv_len;
unsigned int bv_offset;
};
/**
* bvec_set_page - initialize a bvec based off a struct page
* @bv: bvec to initialize
* @page: page the bvec should point to
* @len: length of the bvec
* @offset: offset into the page
*/
static inline void bvec_set_page(struct bio_vec *bv, struct page *page,
unsigned int len, unsigned int offset)
{
bv->bv_page = page;
bv->bv_len = len;
bv->bv_offset = offset;
}
/**
* bvec_set_folio - initialize a bvec based off a struct folio
* @bv: bvec to initialize
* @folio: folio the bvec should point to
* @len: length of the bvec
* @offset: offset into the folio
*/
static inline void bvec_set_folio(struct bio_vec *bv, struct folio *folio,
size_t len, size_t offset)
{
unsigned long nr = offset / PAGE_SIZE;
WARN_ON_ONCE(len > UINT_MAX);
bvec_set_page(bv, folio_page(folio, nr), len, offset % PAGE_SIZE);
}
/**
* bvec_set_virt - initialize a bvec based on a virtual address
* @bv: bvec to initialize
* @vaddr: virtual address to set the bvec to
* @len: length of the bvec
*/
static inline void bvec_set_virt(struct bio_vec *bv, void *vaddr,
unsigned int len)
{
bvec_set_page(bv, virt_to_page(vaddr), len, offset_in_page(vaddr));
}
/**
* bvec_folio - Return the first folio referenced by this bvec
* @bv: bvec to access
*
* A bvec can contain non-folio memory, so this should only be called by
* the creator of the bvec; drivers have no business looking at the owner
* of the memory. It may not even be the right interface for the caller
* to use as a bvec can span multiple folios. You may be better off using
* something like bio_for_each_folio_all() which iterates over all folios.
*/
static inline struct folio *bvec_folio(const struct bio_vec *bv)
{
return page_folio(bv->bv_page);
}
struct bvec_iter {
/*
* Current device address in 512 byte sectors. Only updated by the bio
* iter wrappers and not the bvec iterator helpers themselves.
*/
sector_t bi_sector;
/*
* Remaining size in bytes.
*/
unsigned int bi_size;
/*
* Current index into the bvec array. This indexes into `bi_io_vec` when
* iterating a bvec array that is part of a `bio`.
*/
unsigned int bi_idx;
/*
* Current offset in the bvec entry pointed to by `bi_idx`.
*/
unsigned int bi_bvec_done;
} __packed __aligned(4);
struct bvec_iter_all {
struct bio_vec bv;
Annotation
- Immediate include surface: `linux/highmem.h`, `linux/bug.h`, `linux/errno.h`, `linux/limits.h`, `linux/minmax.h`, `linux/types.h`.
- Detected declarations: `struct page`, `struct bio_vec`, `struct bvec_iter`, `struct bvec_iter_all`, `function bvec_set_page`, `function bvec_set_folio`, `function bvec_set_virt`, `function bio_for_each_folio_all`, `function __bvec_iter_bvec`, `function mp_bvec_iter_page`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.