fs/orangefs/orangefs-bufmap.c
Source file repositories/reference/linux-study-clean/fs/orangefs/orangefs-bufmap.c
File Facts
- System
- Linux kernel
- Corpus path
fs/orangefs/orangefs-bufmap.c- Extension
.c- Size
- 20022 bytes
- Lines
- 837
- 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.
- 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
protocol.horangefs-kernel.horangefs-bufmap.h
Detected Declarations
struct slot_mapstruct orangefs_bufmap_descfunction installfunction mark_killedfunction run_downfunction putfunction wait_for_freefunction getfunction orangefs_bufmap_unmapfunction orangefs_bufmap_freefunction orangefs_bufmap_size_queryfunction orangefs_bufmap_allocfunction orangefs_bufmap_group_foliosfunction orangefs_bufmap_mapfunction orangefs_bufmap_initializefunction orangefs_bufmap_finalizefunction orangefs_bufmap_run_downfunction orangefs_bufmap_getfunction orangefs_bufmap_putfunction orangefs_readdir_index_getfunction orangefs_readdir_index_putfunction orangefs_bufmap_copy_from_iovecfunction orangefs_bufmap_copy_to_iovec
Annotated Snippet
struct slot_map {
int c;
wait_queue_head_t q;
int count;
unsigned long *map;
};
static struct slot_map rw_map = {
.c = -1,
.q = __WAIT_QUEUE_HEAD_INITIALIZER(rw_map.q)
};
static struct slot_map readdir_map = {
.c = -1,
.q = __WAIT_QUEUE_HEAD_INITIALIZER(readdir_map.q)
};
static void install(struct slot_map *m, int count, unsigned long *map)
{
spin_lock(&m->q.lock);
m->c = m->count = count;
m->map = map;
wake_up_all_locked(&m->q);
spin_unlock(&m->q.lock);
}
static void mark_killed(struct slot_map *m)
{
spin_lock(&m->q.lock);
m->c -= m->count + 1;
spin_unlock(&m->q.lock);
}
static void run_down(struct slot_map *m)
{
DEFINE_WAIT(wait);
spin_lock(&m->q.lock);
if (m->c != -1) {
for (;;) {
if (likely(list_empty(&wait.entry)))
__add_wait_queue_entry_tail(&m->q, &wait);
set_current_state(TASK_UNINTERRUPTIBLE);
if (m->c == -1)
break;
spin_unlock(&m->q.lock);
schedule();
spin_lock(&m->q.lock);
}
__remove_wait_queue(&m->q, &wait);
__set_current_state(TASK_RUNNING);
}
m->map = NULL;
spin_unlock(&m->q.lock);
}
static void put(struct slot_map *m, int slot)
{
int v;
spin_lock(&m->q.lock);
__clear_bit(slot, m->map);
v = ++m->c;
if (v > 0)
wake_up_locked(&m->q);
if (unlikely(v == -1)) /* finished dying */
wake_up_all_locked(&m->q);
spin_unlock(&m->q.lock);
}
static int wait_for_free(struct slot_map *m)
{
long left = slot_timeout_secs * HZ;
DEFINE_WAIT(wait);
do {
long n = left, t;
if (likely(list_empty(&wait.entry)))
__add_wait_queue_entry_tail_exclusive(&m->q, &wait);
set_current_state(TASK_INTERRUPTIBLE);
if (m->c > 0)
break;
if (m->c < 0) {
/* we are waiting for map to be installed */
/* it would better be there soon, or we go away */
if (n > ORANGEFS_BUFMAP_WAIT_TIMEOUT_SECS * HZ)
n = ORANGEFS_BUFMAP_WAIT_TIMEOUT_SECS * HZ;
}
Annotation
- Immediate include surface: `protocol.h`, `orangefs-kernel.h`, `orangefs-bufmap.h`.
- Detected declarations: `struct slot_map`, `struct orangefs_bufmap_desc`, `function install`, `function mark_killed`, `function run_down`, `function put`, `function wait_for_free`, `function get`, `function orangefs_bufmap_unmap`, `function orangefs_bufmap_free`.
- 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.