]> mj.ucw.cz Git - libucw.git/blob - lib/pagecache.h
Allow locked dirty pages. Better debugging. Simplified and cleaned up
[libucw.git] / lib / pagecache.h
1 /*
2  *      Sherlock Library -- File Page Cache
3  *
4  *      (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
5  */
6
7 #ifndef _SHERLOCK_PAGECACHE_H
8 #define _SHERLOCK_PAGECACHE_H
9
10 #include "lib/lists.h"
11
12 struct page_cache;
13
14 struct page {
15   node n;                               /* Node in page list */
16   node hn;                              /* Node in hash table */
17   sh_off_t key;                         /* Lower bits contain file handle */
18   uns flags;
19   uns lock_count;
20   byte data[0];
21 };
22
23 #define PG_FLAG_DIRTY           1
24 #define PG_FLAG_VALID           2
25
26 struct page_cache *pgc_open(uns page_size, uns max_pages);
27 void pgc_close(struct page_cache *);
28 void pgc_debug(struct page_cache *, int mode);
29 void pgc_flush(struct page_cache *);                            /* Write all unwritten pages */
30 void pgc_cleanup(struct page_cache *);                          /* Deallocate all unused buffers */
31 struct page *pgc_read(struct page_cache *, int fd, sh_off_t);   /* Read page and lock it */
32 struct page *pgc_get(struct page_cache *, int fd, sh_off_t);    /* Get page for writing */
33 void pgc_put(struct page_cache *, struct page *);               /* Release page */
34 void pgc_mark_dirty(struct page_cache *, struct page *);        /* Mark locked page as dirty */
35 byte *pgc_read_data(struct page_cache *, int fd, sh_off_t, uns *);      /* Partial reading */
36
37 #endif