fs/fuse/notify.c
Source file repositories/reference/linux-study-clean/fs/fuse/notify.c
File Facts
- System
- Linux kernel
- Corpus path
fs/fuse/notify.c- Extension
.c- Size
- 9761 bytes
- Lines
- 445
- 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
dev.hfuse_i.hlinux/pagemap.h
Detected Declarations
struct fuse_retrieve_argsfunction fuse_notify_pollfunction fuse_notify_inval_inodefunction fuse_notify_inval_entryfunction fuse_notify_deletefunction fuse_notify_storefunction fuse_retrieve_endfunction fuse_retrievefunction fuse_notify_retrievefunction fuse_notify_resendfunction fuse_notify_inc_epochfunction fuse_notify_prunefunction scoped_guardfunction fuse_notify
Annotated Snippet
struct fuse_retrieve_args {
struct fuse_args_pages ap;
struct fuse_notify_retrieve_in inarg;
};
static void fuse_retrieve_end(struct fuse_args *args, int error)
{
struct fuse_retrieve_args *ra =
container_of(args, typeof(*ra), ap.args);
release_pages(ra->ap.folios, ra->ap.num_folios);
kfree(ra);
}
static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode,
struct fuse_notify_retrieve_out *outarg)
{
int err;
struct address_space *mapping = inode->i_mapping;
loff_t file_size;
unsigned int num;
unsigned int offset;
size_t total_len = 0;
unsigned int num_pages;
struct fuse_conn *fc = fm->fc;
struct fuse_retrieve_args *ra;
size_t args_size = sizeof(*ra);
struct fuse_args_pages *ap;
struct fuse_args *args;
loff_t pos = outarg->offset;
offset = offset_in_page(pos);
file_size = i_size_read(inode);
num = min(outarg->size, fc->max_write);
if (pos > file_size)
num = 0;
else if (num > file_size - pos)
num = file_size - pos;
num_pages = DIV_ROUND_UP(num + offset, PAGE_SIZE);
num_pages = min(num_pages, fc->max_pages);
num = min(num, num_pages << PAGE_SHIFT);
args_size += num_pages * (sizeof(ap->folios[0]) + sizeof(ap->descs[0]));
ra = kzalloc(args_size, GFP_KERNEL);
if (!ra)
return -ENOMEM;
ap = &ra->ap;
ap->folios = (void *) (ra + 1);
ap->descs = (void *) (ap->folios + num_pages);
args = &ap->args;
args->nodeid = outarg->nodeid;
args->opcode = FUSE_NOTIFY_REPLY;
args->in_numargs = 3;
args->in_pages = true;
args->end = fuse_retrieve_end;
while (num && ap->num_folios < num_pages) {
struct folio *folio;
unsigned int folio_offset;
unsigned int nr_bytes;
pgoff_t index = pos >> PAGE_SHIFT;
folio = filemap_get_folio(mapping, index);
if (IS_ERR(folio))
break;
if (!folio_test_uptodate(folio)) {
folio_put(folio);
break;
}
folio_offset = offset_in_folio(folio, pos);
nr_bytes = min(folio_size(folio) - folio_offset, num);
ap->folios[ap->num_folios] = folio;
ap->descs[ap->num_folios].offset = folio_offset;
ap->descs[ap->num_folios].length = nr_bytes;
ap->num_folios++;
pos += nr_bytes;
num -= nr_bytes;
total_len += nr_bytes;
}
ra->inarg.offset = outarg->offset;
ra->inarg.size = total_len;
fuse_set_zero_arg0(args);
Annotation
- Immediate include surface: `dev.h`, `fuse_i.h`, `linux/pagemap.h`.
- Detected declarations: `struct fuse_retrieve_args`, `function fuse_notify_poll`, `function fuse_notify_inval_inode`, `function fuse_notify_inval_entry`, `function fuse_notify_delete`, `function fuse_notify_store`, `function fuse_retrieve_end`, `function fuse_retrieve`, `function fuse_notify_retrieve`, `function fuse_notify_resend`.
- 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.