linux-old/include/linux/pagemap.h
<<
>>
Prefs
   1#ifndef _LINUX_PAGEMAP_H
   2#define _LINUX_PAGEMAP_H
   3
   4/*
   5 * Page-mapping primitive inline functions
   6 *
   7 * Copyright 1995 Linus Torvalds
   8 */
   9
  10#include <linux/mm.h>
  11#include <linux/fs.h>
  12#include <linux/list.h>
  13
  14#include <asm/system.h>
  15#include <asm/pgtable.h>
  16#include <linux/highmem.h>
  17
  18/*
  19 * The page cache can done in larger chunks than
  20 * one page, because it allows for more efficient
  21 * throughput (it can then be mapped into user
  22 * space in smaller chunks for same flexibility).
  23 *
  24 * Or rather, it _will_ be done in larger chunks.
  25 */
  26#define PAGE_CACHE_SHIFT        PAGE_SHIFT
  27#define PAGE_CACHE_SIZE         PAGE_SIZE
  28#define PAGE_CACHE_MASK         PAGE_MASK
  29#define PAGE_CACHE_ALIGN(addr)  (((addr)+PAGE_CACHE_SIZE-1)&PAGE_CACHE_MASK)
  30
  31#define page_cache_get(x)       get_page(x)
  32#define page_cache_alloc()      alloc_pages(GFP_HIGHUSER, 0)
  33#define page_cache_free(x)      __free_page(x)
  34#define page_cache_release(x)   __free_page(x)
  35
  36/*
  37 * From a kernel address, get the "struct page *"
  38 */
  39#define page_cache_entry(x)     virt_to_page(x)
  40
  41extern unsigned int page_hash_bits;
  42#define PAGE_HASH_BITS (page_hash_bits)
  43#define PAGE_HASH_SIZE (1 << PAGE_HASH_BITS)
  44
  45extern atomic_t page_cache_size; /* # of pages currently in the hash table */
  46extern struct page **page_hash_table;
  47
  48extern void page_cache_init(unsigned long);
  49
  50/*
  51 * We use a power-of-two hash table to avoid a modulus,
  52 * and get a reasonable hash by knowing roughly how the
  53 * inode pointer and indexes are distributed (ie, we
  54 * roughly know which bits are "significant")
  55 *
  56 * For the time being it will work for struct address_space too (most of
  57 * them sitting inside the inodes). We might want to change it later.
  58 */
  59extern inline unsigned long _page_hashfn(struct address_space * mapping, unsigned long index)
  60{
  61#define i (((unsigned long) mapping)/(sizeof(struct inode) & ~ (sizeof(struct inode) - 1)))
  62#define s(x) ((x)+((x)>>PAGE_HASH_BITS))
  63        return s(i+index) & (PAGE_HASH_SIZE-1);
  64#undef i
  65#undef s
  66}
  67
  68#define page_hash(mapping,index) (page_hash_table+_page_hashfn(mapping,index))
  69
  70extern struct page * __find_get_page(struct address_space *mapping,
  71                                     unsigned long offset, struct page **hash);
  72extern struct page * __find_lock_page (struct address_space * mapping,
  73                                unsigned long index, struct page **hash);
  74extern void lock_page(struct page *page);
  75#define find_lock_page(mapping, index) \
  76                __find_lock_page(mapping, index, page_hash(mapping, index))
  77
  78extern void __add_page_to_hash_queue(struct page * page, struct page **p);
  79
  80extern void add_to_page_cache(struct page * page, struct address_space *mapping, unsigned long index);
  81extern void add_to_page_cache_locked(struct page * page, struct address_space *mapping, unsigned long index);
  82
  83extern void ___wait_on_page(struct page *);
  84
  85extern inline void wait_on_page(struct page * page)
  86{
  87        if (PageLocked(page))
  88                ___wait_on_page(page);
  89}
  90
  91extern struct page * grab_cache_page (struct address_space *, unsigned long);
  92
  93typedef int filler_t(void *, struct page*);
  94
  95extern struct page *read_cache_page(struct address_space *, unsigned long,
  96                                filler_t *, void *);
  97#endif
  98
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.