sched: Slightly fix up tests/prov
[akaros.git] / kern / include / pagemap.h
index 56dd9c2..4aac3ab 100644 (file)
@@ -7,16 +7,17 @@
  * with the VFS, block devices also use it (hence the separate header and c
  * file). */
 
-#ifndef ROS_KERN_PAGEMAP_H
-#define ROS_KERN_PAGEMAP_H
+#pragma once
 
 #include <radix.h>
 #include <atomic.h>
+#include <mm.h>
 
 /* Need to be careful, due to some ghetto circular references */
 struct page;
 struct inode;
 struct block_device;
+struct chan;
 struct page_map_operations;
 
 /* Every object that has pages, like an inode or the swap (or even direct block
@@ -26,13 +27,14 @@ struct page_map {
        union {
                struct inode                            *pm_host;       /* inode of the owner, if any */
                struct block_device                     *pm_bdev;       /* bdev of the owner, if any */
+               struct chan                                     *pm_chan;
        };
        struct radix_tree                       pm_tree;                /* tracks present pages */
-       spinlock_t                                      pm_tree_lock;   /* spinlock => we can't block */
        unsigned long                           pm_num_pages;   /* how many pages are present */
        struct page_map_operations      *pm_op;
-       unsigned int                            pm_flags;
-       /*... and private lists, backing block dev info, other mappings, etc. */
+       spinlock_t                                      pm_lock;
+       struct vmr_tailq                        pm_vmrs;
+       atomic_t                                        pm_removal;
 };
 
 /* Operations performed on a page_map.  These are usually FS specific, which
@@ -40,6 +42,7 @@ struct page_map {
  * Will fill these in as they are created/needed/used. */
 struct page_map_operations {
        int (*readpage) (struct page_map *, struct page *);
+       int (*writepage) (struct page_map *, struct page *);
 /*     readpages: read a list of pages
        writepage: write from a page to its backing store
        writepages: write a list of pages
@@ -49,14 +52,19 @@ struct page_map_operations {
        commit_write: complete a write (disk backed pages)
        bmap: get a logical block number from a file block index
        invalidate page: invalidate, part of truncating
-       release page: prepare to release 
+       release page: prepare to release
        direct_io: bypass the page cache */
 };
 
 /* Page cache functions */
 void pm_init(struct page_map *pm, struct page_map_operations *op, void *host);
-struct page *pm_find_page(struct page_map *pm, unsigned long index);
-int pm_insert_page(struct page_map *pm, unsigned long index, struct page *page);
-int pm_remove_page(struct page_map *pm, struct page *page);
-
-#endif /* ROS_KERN_PAGEMAP_H */
+int pm_load_page(struct page_map *pm, unsigned long index, struct page **pp);
+int pm_load_page_nowait(struct page_map *pm, unsigned long index,
+                        struct page **pp);
+void pm_put_page(struct page *page);
+void pm_add_vmr(struct page_map *pm, struct vm_region *vmr);
+void pm_remove_vmr(struct page_map *pm, struct vm_region *vmr);
+int pm_remove_contig(struct page_map *pm, unsigned long index,
+                     unsigned long nr_pgs);
+void pm_page_asserter(struct page *page, char *str);
+void print_page_map_info(struct page_map *pm);