1 /* Copyright (c) 2010 The Regents of the University of California
2 * Barret Rhoden <brho@cs.berkeley.edu>
3 * See LICENSE for details.
5 * Page mapping: maps an object (inode or block dev) in page size chunks.
6 * Analagous to Linux's "struct address space". While this is closely coupled
7 * with the VFS, block devices also use it (hence the separate header and c
10 #ifndef ROS_KERN_PAGEMAP_H
11 #define ROS_KERN_PAGEMAP_H
17 /* Need to be careful, due to some ghetto circular references */
21 struct page_map_operations;
23 /* Every object that has pages, like an inode or the swap (or even direct block
24 * devices) has a page_map, tracking which of its pages are currently in memory.
25 * It is a map, per object, from index to physical page frame. */
28 struct inode *pm_host; /* inode of the owner, if any */
29 struct block_device *pm_bdev; /* bdev of the owner, if any */
31 struct radix_tree pm_tree; /* tracks present pages */
32 spinlock_t pm_tree_lock; /* spinlock => we can't block */
33 unsigned long pm_num_pages; /* how many pages are present */
34 struct page_map_operations *pm_op;
35 unsigned int pm_flags;
36 /*... and private lists, backing block dev info, other mappings, etc. */
38 struct vmr_tailq pm_vmrs;
41 /* Operations performed on a page_map. These are usually FS specific, which
42 * get assigned when the inode is created.
43 * Will fill these in as they are created/needed/used. */
44 struct page_map_operations {
45 int (*readpage) (struct page_map *, struct page *);
46 /* readpages: read a list of pages
47 writepage: write from a page to its backing store
48 writepages: write a list of pages
49 sync_page: start the IO of already scheduled ops
50 set_page_dirty: mark the given page dirty
51 prepare_write: prepare to write (disk backed pages)
52 commit_write: complete a write (disk backed pages)
53 bmap: get a logical block number from a file block index
54 invalidate page: invalidate, part of truncating
55 release page: prepare to release
56 direct_io: bypass the page cache */
59 /* Page cache functions */
60 void pm_init(struct page_map *pm, struct page_map_operations *op, void *host);
61 int pm_load_page(struct page_map *pm, unsigned long index, struct page **pp);
62 void pm_put_page(struct page *page);
63 void pm_add_vmr(struct page_map *pm, struct vm_region *vmr);
64 void pm_remove_vmr(struct page_map *pm, struct vm_region *vmr);
65 void print_page_map_info(struct page_map *pm);
67 #endif /* ROS_KERN_PAGEMAP_H */