|
AquilaOS documentation
How it works, and its code
|
The page cache: a file's pages in memory, for mmap(). More...
Go to the source code of this file.
Functions | |
| static int | vm_page_eq (void *_a, void *_b) |
| Says whether a cached page is the one at the offset _b points to. | |
| struct vm_object * | vm_object_vnode (struct vnode *vnode) |
| Gets a vnode's vm object, making it the first time. | |
| struct vm_page * | vnode_page_in (struct vm_object *vm_object, size_t off) |
| Reads a page of a file into its vm object: the vnode pager's page in. | |
| void | vnode_pages_update (struct vnode *vnode, off_t start, off_t end) |
| Reads a file's cached pages again after a write or a truncation changed a range of it. | |
| void | vnode_pages_free (struct vnode *vnode) |
| Frees a vnode's vm object and its cached pages, when the vnode itself is freed. | |
Variables | |
| static struct vm_pager | vnode_pager |
The page cache: a file's pages in memory, for mmap().
A vnode that is mapped has a vm object, which keeps the file's pages by their offset; its pager reads a page in the first time a process touches it (see mm/fault.c), and every process that maps the file shares it.
Definition in file vm_object.c.
Gets a vnode's vm object, making it the first time.
| vnode | the vnode |
Definition at line 31 of file vm_object.c.
References kfree(), kmalloc(), M_ZERO, NULL, vm_object::p, vm_object::pager, vm_object::pages, vm_object::type, vnode::vm_object, vm_object_vnode(), vm_page_eq(), VMOBJ_FILE, and vnode_pager.
Referenced by binfmt_elf_load_segments(), sys_mmap(), and vm_object_vnode().
|
static |
Says whether a cached page is the one at the offset _b points to.
Definition at line 16 of file vm_object.c.
References vm_page::off, and vm_page_eq().
Reads a page of a file into its vm object: the vnode pager's page in.
Past the end of the file, the page reads as zeros.
| vm_object | the file's vm object |
| off | the page's offset in the file |
Definition at line 67 of file vm_object.c.
References hashmap_node::entry, hashmap_node::hash, kfree(), kmalloc(), M_ZERO, mm_page_alloc(), mm_page_dealloc(), NULL, vm_page::off, vm_object::p, vm_page::paddr, PAGE_ALIGN, PAGE_SIZE, vm_object::pages, pmap_page_write(), vm_page::ref, vfs_read(), vm_page::vm_object, vm_object_page_insert(), and vnode_page_in().
Referenced by vnode_page_in().
| void vnode_pages_free | ( | struct vnode * | vnode | ) |
Frees a vnode's vm object and its cached pages, when the vnode itself is freed.
Nothing maps them then, since a mapping holds the vnode (vm_object_incref()).
| vnode | the vnode |
Definition at line 172 of file vm_object.c.
References hashmap_node::entry, hashmap_for, kfree(), mm_page_dealloc(), NULL, vm_page::paddr, vm_object::pages, qnode::value, vnode::vm_object, and vnode_pages_free().
Referenced by ext2_close(), procfs_close(), pseudofs_close(), and vnode_pages_free().
Reads a file's cached pages again after a write or a truncation changed a range of it.
A page stays where it is, mapped by every process that maps the file, so its contents change but not the page; past the file's end it reads zeros. A private mapping's copies, made when it wrote to a page, are its own and don't change.
| vnode | the file |
| start | the start of the range that changed |
| end | its end (exclusive) |
Definition at line 128 of file vm_object.c.
References hashmap::count, hashmap_node::entry, hashmap_node::hash, kfree(), kmalloc(), memset(), NULL, vm_page::off, vm_page::paddr, PAGE_ALIGN, PAGE_SIZE, vm_object::pages, pmap_page_write(), printk(), vfs_read(), vnode::vm_object, and vnode_pages_update().
Referenced by vfs_trunc(), vfs_write_io(), and vnode_pages_update().
|
static |
Definition at line 13 of file vm_object.c.
Referenced by vm_object_vnode().