fs/btrfs/misc.h
Source file repositories/reference/linux-study-clean/fs/btrfs/misc.h
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/misc.h- Extension
.h- Size
- 5811 bytes
- Lines
- 228
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- 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.
- 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/types.hlinux/bitmap.hlinux/sched.hlinux/wait.hlinux/mm.hlinux/pagemap.hlinux/math64.hlinux/rbtree.hlinux/bio.h
Detected Declarations
struct rb_simple_nodefunction __freefunction bio_advance_iter_singlefunction init_bvec_iter_for_biofunction bio_advance_iter_singlefunction cond_wake_up_nombfunction mult_percfunction is_power_of_two_u64function has_single_bit_setfunction rb_simple_node_bytenr_cmpfunction bitmap_test_range_all_setfunction bitmap_test_range_all_zero
Annotated Snippet
struct rb_simple_node {
struct rb_node rb_node;
u64 bytenr;
};
static inline struct rb_node *rb_simple_search(const struct rb_root *root, u64 bytenr)
{
struct rb_node *node = root->rb_node;
struct rb_simple_node *entry;
while (node) {
entry = rb_entry(node, struct rb_simple_node, rb_node);
if (bytenr < entry->bytenr)
node = node->rb_left;
else if (bytenr > entry->bytenr)
node = node->rb_right;
else
return node;
}
return NULL;
}
/*
* Search @root from an entry that starts or comes after @bytenr.
*
* @root: the root to search.
* @bytenr: bytenr to search from.
*
* Return the rb_node that start at or after @bytenr. If there is no entry at
* or after @bytner return NULL.
*/
static inline struct rb_node *rb_simple_search_first(const struct rb_root *root,
u64 bytenr)
{
struct rb_node *node = root->rb_node, *ret = NULL;
struct rb_simple_node *entry, *ret_entry = NULL;
while (node) {
entry = rb_entry(node, struct rb_simple_node, rb_node);
if (bytenr < entry->bytenr) {
if (!ret || entry->bytenr < ret_entry->bytenr) {
ret = node;
ret_entry = entry;
}
node = node->rb_left;
} else if (bytenr > entry->bytenr) {
node = node->rb_right;
} else {
return node;
}
}
return ret;
}
static int rb_simple_node_bytenr_cmp(struct rb_node *new, const struct rb_node *existing)
{
struct rb_simple_node *new_entry = rb_entry(new, struct rb_simple_node, rb_node);
struct rb_simple_node *existing_entry = rb_entry(existing, struct rb_simple_node, rb_node);
if (new_entry->bytenr < existing_entry->bytenr)
return -1;
else if (new_entry->bytenr > existing_entry->bytenr)
return 1;
return 0;
}
static inline struct rb_node *rb_simple_insert(struct rb_root *root,
struct rb_simple_node *simple_node)
{
return rb_find_add(&simple_node->rb_node, root, rb_simple_node_bytenr_cmp);
}
static inline bool bitmap_test_range_all_set(const unsigned long *addr,
unsigned long start,
unsigned long nbits)
{
unsigned long found_zero;
found_zero = find_next_zero_bit(addr, start + nbits, start);
return (found_zero == start + nbits);
}
static inline bool bitmap_test_range_all_zero(const unsigned long *addr,
unsigned long start,
unsigned long nbits)
Annotation
- Immediate include surface: `linux/types.h`, `linux/bitmap.h`, `linux/sched.h`, `linux/wait.h`, `linux/mm.h`, `linux/pagemap.h`, `linux/math64.h`, `linux/rbtree.h`.
- Detected declarations: `struct rb_simple_node`, `function __free`, `function bio_advance_iter_single`, `function init_bvec_iter_for_bio`, `function bio_advance_iter_single`, `function cond_wake_up_nomb`, `function mult_perc`, `function is_power_of_two_u64`, `function has_single_bit_set`, `function rb_simple_node_bytenr_cmp`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.