fs/ocfs2/reservations.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/reservations.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/reservations.c- Extension
.c- Size
- 20304 bytes
- Lines
- 825
- 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/fs.hlinux/types.hlinux/highmem.hlinux/bitops.hlinux/list.hcluster/masklog.hocfs2.hocfs2_trace.h
Detected Declarations
function ocfs2_dir_resv_allowedfunction ocfs2_resv_window_bitsfunction ocfs2_resv_endfunction ocfs2_resv_emptyfunction ocfs2_resmap_disabledfunction ocfs2_dump_resvfunction ocfs2_validate_resmap_bitsfunction ocfs2_check_resmapfunction ocfs2_check_resmapfunction ocfs2_resv_set_typefunction ocfs2_resmap_initfunction ocfs2_resv_mark_lrufunction __ocfs2_resv_truncfunction ocfs2_resv_removefunction __ocfs2_resv_discardfunction ocfs2_resv_discardfunction ocfs2_resmap_clear_all_resvfunction ocfs2_resmap_restartfunction ocfs2_resmap_uninitfunction ocfs2_find_resv_lhsfunction treefunction __ocfs2_resv_find_windowfunction ocfs2_cannibalize_resvfunction Cannibalizefunction ocfs2_resv_find_windowfunction ocfs2_resmap_resv_bitsfunction ocfs2_adjust_resv_from_allocfunction ocfs2_resmap_claimed_bits
Annotated Snippet
if (ocfs2_test_bit(start, disk_bitmap)) {
mlog(ML_ERROR,
"reservation %d covers an allocated area "
"starting at bit %u!\n", i, start);
return 1;
}
start++;
}
return 0;
}
static void ocfs2_check_resmap(struct ocfs2_reservation_map *resmap)
{
unsigned int off = 0;
int i = 0;
struct rb_node *node;
struct ocfs2_alloc_reservation *resv;
node = rb_first(&resmap->m_reservations);
while (node) {
resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node);
if (i > 0 && resv->r_start <= off) {
mlog(ML_ERROR, "reservation %d has bad start off!\n",
i);
goto bad;
}
if (resv->r_len == 0) {
mlog(ML_ERROR, "reservation %d has no length!\n",
i);
goto bad;
}
if (resv->r_start > ocfs2_resv_end(resv)) {
mlog(ML_ERROR, "reservation %d has invalid range!\n",
i);
goto bad;
}
if (ocfs2_resv_end(resv) >= resmap->m_bitmap_len) {
mlog(ML_ERROR, "reservation %d extends past bitmap!\n",
i);
goto bad;
}
if (ocfs2_validate_resmap_bits(resmap, i, resv))
goto bad;
off = ocfs2_resv_end(resv);
node = rb_next(node);
i++;
}
return;
bad:
ocfs2_dump_resv(resmap);
BUG();
}
#else
static inline void ocfs2_check_resmap(struct ocfs2_reservation_map *resmap)
{
}
#endif
void ocfs2_resv_init_once(struct ocfs2_alloc_reservation *resv)
{
memset(resv, 0, sizeof(*resv));
INIT_LIST_HEAD(&resv->r_lru);
}
void ocfs2_resv_set_type(struct ocfs2_alloc_reservation *resv,
unsigned int flags)
{
BUG_ON(flags & ~OCFS2_RESV_TYPES);
resv->r_flags |= flags;
}
void ocfs2_resmap_init(struct ocfs2_super *osb,
struct ocfs2_reservation_map *resmap)
{
memset(resmap, 0, sizeof(*resmap));
resmap->m_osb = osb;
resmap->m_reservations = RB_ROOT;
/* m_bitmap_len is initialized to zero by the above memset. */
Annotation
- Immediate include surface: `linux/fs.h`, `linux/types.h`, `linux/highmem.h`, `linux/bitops.h`, `linux/list.h`, `cluster/masklog.h`, `ocfs2.h`, `ocfs2_trace.h`.
- Detected declarations: `function ocfs2_dir_resv_allowed`, `function ocfs2_resv_window_bits`, `function ocfs2_resv_end`, `function ocfs2_resv_empty`, `function ocfs2_resmap_disabled`, `function ocfs2_dump_resv`, `function ocfs2_validate_resmap_bits`, `function ocfs2_check_resmap`, `function ocfs2_check_resmap`, `function ocfs2_resv_set_type`.
- 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.