fs/fuse/dax.c
Source file repositories/reference/linux-study-clean/fs/fuse/dax.c
File Facts
- System
- Linux kernel
- Corpus path
fs/fuse/dax.c- Extension
.c- Size
- 36071 bytes
- Lines
- 1355
- 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
fuse_i.hlinux/delay.hlinux/dax.hlinux/uio.hlinux/pagemap.hlinux/iomap.hlinux/interval_tree.h
Detected Declarations
struct fuse_dax_mappingstruct fuse_inode_daxstruct fuse_conn_daxfunction node_to_dmapfunction __kick_dmap_free_workerfunction kick_dmap_free_workerfunction __dmap_remove_busy_listfunction dmap_remove_busy_listfunction __dmap_add_to_free_poolfunction dmap_add_to_free_poolfunction fuse_setup_one_mappingfunction fuse_send_removemappingfunction dmap_removemapping_listfunction dmap_reinit_add_to_free_poolfunction evict_inodefunction dmap_removemapping_onefunction evict_inodefunction fuse_fill_iomap_holefunction fuse_fill_iomapfunction fuse_setup_new_dax_mappingfunction dax_layout_busy_pagefunction fuse_upgrade_dax_mappingfunction fuse_iomap_beginfunction fuse_iomap_endfunction fuse_wait_dax_pagefunction fuse_dax_break_layoutsfunction fuse_dax_read_iterfunction file_extending_writefunction fuse_dax_direct_writefunction fuse_dax_write_iterfunction __fuse_dax_faultfunction fuse_dax_faultfunction fuse_dax_huge_faultfunction fuse_dax_page_mkwritefunction fuse_dax_pfn_mkwritefunction fuse_dax_mmapfunction dmap_writeback_invalidatefunction reclaim_one_dmap_lockedfunction inode_inline_reclaim_one_dmapfunction alloc_dax_mapping_reclaimfunction lookup_and_reclaim_dmap_lockedfunction lookup_and_reclaim_dmapfunction try_to_free_dmap_chunksfunction list_for_each_entry_safefunction fuse_dax_free_mem_workerfunction fuse_free_dax_mem_rangesfunction fuse_dax_conn_freefunction fuse_dax_mem_range_init
Annotated Snippet
struct fuse_dax_mapping {
/* Pointer to inode where this memory range is mapped */
struct inode *inode;
/* Will connect in fcd->free_ranges to keep track of free memory */
struct list_head list;
/* For interval tree in file/inode */
struct interval_tree_node itn;
/* Will connect in fc->busy_ranges to keep track busy memory */
struct list_head busy_list;
/** Position in DAX window */
u64 window_offset;
/** Length of mapping, in bytes */
loff_t length;
/* Is this mapping read-only or read-write */
bool writable;
/* reference count when the mapping is used by dax iomap. */
refcount_t refcnt;
};
/* Per-inode dax map */
struct fuse_inode_dax {
/* Semaphore to protect modifications to the dmap tree */
struct rw_semaphore sem;
/* Sorted rb tree of struct fuse_dax_mapping elements */
struct rb_root_cached tree;
unsigned long nr;
};
struct fuse_conn_dax {
/* DAX device */
struct dax_device *dev;
/* Lock protecting accessess to members of this structure */
spinlock_t lock;
/* List of memory ranges which are busy */
unsigned long nr_busy_ranges;
struct list_head busy_ranges;
/* Worker to free up memory ranges */
struct delayed_work free_work;
/* Wait queue for a dax range to become free */
wait_queue_head_t range_waitq;
/* DAX Window Free Ranges */
long nr_free_ranges;
struct list_head free_ranges;
unsigned long nr_ranges;
};
static inline struct fuse_dax_mapping *
node_to_dmap(struct interval_tree_node *node)
{
if (!node)
return NULL;
return container_of(node, struct fuse_dax_mapping, itn);
}
static struct fuse_dax_mapping *
alloc_dax_mapping_reclaim(struct fuse_conn_dax *fcd, struct inode *inode);
static void
__kick_dmap_free_worker(struct fuse_conn_dax *fcd, unsigned long delay_ms)
{
unsigned long free_threshold;
/* If number of free ranges are below threshold, start reclaim */
free_threshold = max_t(unsigned long, fcd->nr_ranges * FUSE_DAX_RECLAIM_THRESHOLD / 100,
1);
if (fcd->nr_free_ranges < free_threshold)
queue_delayed_work(system_dfl_long_wq, &fcd->free_work,
msecs_to_jiffies(delay_ms));
}
static void kick_dmap_free_worker(struct fuse_conn_dax *fcd,
unsigned long delay_ms)
{
spin_lock(&fcd->lock);
__kick_dmap_free_worker(fcd, delay_ms);
Annotation
- Immediate include surface: `fuse_i.h`, `linux/delay.h`, `linux/dax.h`, `linux/uio.h`, `linux/pagemap.h`, `linux/iomap.h`, `linux/interval_tree.h`.
- Detected declarations: `struct fuse_dax_mapping`, `struct fuse_inode_dax`, `struct fuse_conn_dax`, `function node_to_dmap`, `function __kick_dmap_free_worker`, `function kick_dmap_free_worker`, `function __dmap_remove_busy_list`, `function dmap_remove_busy_list`, `function __dmap_add_to_free_pool`, `function dmap_add_to_free_pool`.
- 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.