fs/dax.c
Source file repositories/reference/linux-study-clean/fs/dax.c
File Facts
- System
- Linux kernel
- Corpus path
fs/dax.c- Extension
.c- Size
- 62161 bytes
- Lines
- 2279
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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
linux/atomic.hlinux/blkdev.hlinux/buffer_head.hlinux/dax.hlinux/fs.hlinux/highmem.hlinux/memcontrol.hlinux/mm.hlinux/mutex.hlinux/sched.hlinux/sched/signal.hlinux/uio.hlinux/vmstat.hlinux/sizes.hlinux/mmu_notifier.hlinux/iomap.hlinux/rmap.hlinux/pgalloc.htrace/events/fs_dax.h
Detected Declarations
struct exceptional_entry_keystruct wait_exceptional_entry_queueenum dax_wake_modefunction init_dax_wait_tablefunction dax_to_pfnfunction dax_is_lockedfunction dax_entry_orderfunction dax_is_pmd_entryfunction dax_is_pte_entryfunction dax_is_zero_entryfunction dax_is_empty_entryfunction dax_is_conflictfunction wake_exceptional_entry_funcfunction dax_wake_entryfunction put_unlocked_entryfunction put_unlocked_entryfunction xas_unlock_irqfunction put_unlocked_entryfunction dax_unlock_entryfunction dax_entry_sizefunction dax_folio_is_sharedfunction dax_insert_entryfunction dax_folio_reset_orderfunction dax_folio_putfunction dax_folio_initfunction dax_associate_entryfunction dax_disassociate_entryfunction dax_lock_foliofunction dax_unlock_foliofunction dax_lock_mapping_entryfunction dax_unlock_mapping_entryfunction get_user_pagesfunction __dax_invalidate_entryfunction __dax_clear_dirty_rangefunction dax_delete_mapping_entryfunction dax_delete_mapping_rangefunction wait_page_idlefunction wait_page_idle_uninterruptiblefunction dax_break_layoutfunction dax_break_layout_finalfunction dax_invalidate_mapping_entry_syncfunction dax_iomap_pgofffunction copy_cow_page_daxfunction dax_fault_is_synchronousfunction grab_mapping_entryfunction dax_writeback_onefunction dax_writeback_mapping_rangefunction dax_iomap_direct_access
Annotated Snippet
struct exceptional_entry_key {
struct xarray *xa;
pgoff_t entry_start;
};
struct wait_exceptional_entry_queue {
wait_queue_entry_t wait;
struct exceptional_entry_key key;
};
/**
* enum dax_wake_mode: waitqueue wakeup behaviour
* @WAKE_ALL: wake all waiters in the waitqueue
* @WAKE_NEXT: wake only the first waiter in the waitqueue
*/
enum dax_wake_mode {
WAKE_ALL,
WAKE_NEXT,
};
static wait_queue_head_t *dax_entry_waitqueue(struct xa_state *xas,
void *entry, struct exceptional_entry_key *key)
{
unsigned long hash;
unsigned long index = xas->xa_index;
/*
* If 'entry' is a PMD, align the 'index' that we use for the wait
* queue to the start of that PMD. This ensures that all offsets in
* the range covered by the PMD map to the same bit lock.
*/
if (dax_is_pmd_entry(entry))
index &= ~PG_PMD_COLOUR;
key->xa = xas->xa;
key->entry_start = index;
hash = hash_long((unsigned long)xas->xa ^ index, DAX_WAIT_TABLE_BITS);
return wait_table + hash;
}
static int wake_exceptional_entry_func(wait_queue_entry_t *wait,
unsigned int mode, int sync, void *keyp)
{
struct exceptional_entry_key *key = keyp;
struct wait_exceptional_entry_queue *ewait =
container_of(wait, struct wait_exceptional_entry_queue, wait);
if (key->xa != ewait->key.xa ||
key->entry_start != ewait->key.entry_start)
return 0;
return autoremove_wake_function(wait, mode, sync, NULL);
}
/*
* @entry may no longer be the entry at the index in the mapping.
* The important information it's conveying is whether the entry at
* this index used to be a PMD entry.
*/
static void dax_wake_entry(struct xa_state *xas, void *entry,
enum dax_wake_mode mode)
{
struct exceptional_entry_key key;
wait_queue_head_t *wq;
wq = dax_entry_waitqueue(xas, entry, &key);
/*
* Checking for locked entry and prepare_to_wait_exclusive() happens
* under the i_pages lock, ditto for entry handling in our callers.
* So at this point all tasks that could have seen our entry locked
* must be in the waitqueue and the following check will see them.
*/
if (waitqueue_active(wq))
__wake_up(wq, TASK_NORMAL, mode == WAKE_ALL ? 0 : 1, &key);
}
/*
* Look up entry in page cache, wait for it to become unlocked if it
* is a DAX entry and return it. The caller must subsequently call
* put_unlocked_entry() if it did not lock the entry or dax_unlock_entry()
* if it did. The entry returned may have a larger order than @order.
* If @order is larger than the order of the entry found in i_pages, this
* function returns a dax_is_conflict entry.
*
* Must be called with the i_pages lock held.
*/
static void *get_next_unlocked_entry(struct xa_state *xas, unsigned int order)
{
void *entry;
struct wait_exceptional_entry_queue ewait;
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/blkdev.h`, `linux/buffer_head.h`, `linux/dax.h`, `linux/fs.h`, `linux/highmem.h`, `linux/memcontrol.h`, `linux/mm.h`.
- Detected declarations: `struct exceptional_entry_key`, `struct wait_exceptional_entry_queue`, `enum dax_wake_mode`, `function init_dax_wait_table`, `function dax_to_pfn`, `function dax_is_locked`, `function dax_entry_order`, `function dax_is_pmd_entry`, `function dax_is_pte_entry`, `function dax_is_zero_entry`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.