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
16 /* 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 */
32 struct radix_tree pm_tree; /* tracks present pages */
33 unsigned long pm_num_pages; /* how many pages are present */
34 struct page_map_operations *pm_op;
36 struct vmr_tailq pm_vmrs;
40 /* Operations performed on a page_map. These are usually FS specific, which
41 * get assigned when the inode is created.
42 * Will fill these in as they are created/needed/used. */
43 struct page_map_operations {
44 int (*readpage) (struct page_map *, struct page *);
45 int (*writepage) (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 int pm_load_page_nowait(struct page_map *pm, unsigned long index,
64 void pm_put_page(struct page *page);
65 void pm_add_vmr(struct page_map *pm, struct vm_region *vmr);
66 void pm_remove_vmr(struct page_map *pm, struct vm_region *vmr);
67 int pm_remove_contig(struct page_map *pm, unsigned long index,
68 unsigned long nr_pgs);
69 void print_page_map_info(struct page_map *pm);