linux-bk/include/linux/pagemap.h
<<
>>
Prefs
   1#ifndef _LINUX_PAGEMAP_H
   2#define _LINUX_PAGEMAP_H
   3
   4/*
   5 * Copyright 1995 Linus Torvalds
   6 */
   7#include <linux/mm.h>
   8#include <linux/fs.h>
   9#include <linux/list.h>
  10#include <linux/highmem.h>
  11
  12/*
  13 * The page cache can done in larger chunks than
  14 * one page, because it allows for more efficient
  15 * throughput (it can then be mapped into user
  16 * space in smaller chunks for same flexibility).
  17 *
  18 * Or rather, it _will_ be done in larger chunks.
  19 */
  20#define PAGE_CACHE_SHIFT        PAGE_SHIFT
  21#define PAGE_CACHE_SIZE         PAGE_SIZE
  22#define PAGE_CACHE_MASK         PAGE_MASK
  23#define PAGE_CACHE_ALIGN(addr)  (((addr)+PAGE_CACHE_SIZE-1)&PAGE_CACHE_MASK)
  24
  25#define page_cache_get(x)       get_page(x)
  26extern void FASTCALL(page_cache_release(struct page *));
  27
  28static inline struct page *page_cache_alloc(struct address_space *x)
  29{
  30        return alloc_pages(x->gfp_mask, 0);
  31}
  32
  33
  34typedef int filler_t(void *, struct page *);
  35
  36extern struct page * find_get_page(struct address_space *mapping,
  37                                unsigned long index);
  38extern struct page * find_lock_page(struct address_space *mapping,
  39                                unsigned long index);
  40extern struct page * find_trylock_page(struct address_space *mapping,
  41                                unsigned long index);
  42extern struct page * find_or_create_page(struct address_space *mapping,
  43                                unsigned long index, unsigned int gfp_mask);
  44
  45extern struct page * grab_cache_page(struct address_space *mapping,
  46                                unsigned long index);
  47extern struct page * grab_cache_page_nowait(struct address_space *mapping,
  48                                unsigned long index);
  49extern struct page * read_cache_page(struct address_space *mapping,
  50                                unsigned long index, filler_t *filler,
  51                                void *data);
  52
  53extern int add_to_page_cache(struct page *page,
  54                struct address_space *mapping, unsigned long index);
  55
  56static inline void ___add_to_page_cache(struct page *page,
  57                struct address_space *mapping, unsigned long index)
  58{
  59        list_add(&page->list, &mapping->clean_pages);
  60        page->mapping = mapping;
  61        page->index = index;
  62
  63        mapping->nrpages++;
  64        inc_page_state(nr_pagecache);
  65}
  66
  67extern void FASTCALL(lock_page(struct page *page));
  68extern void FASTCALL(unlock_page(struct page *page));
  69
  70/*
  71 * This is exported only for wait_on_page_locked/wait_on_page_writeback.
  72 * Never use this directly!
  73 */
  74extern void FASTCALL(wait_on_page_bit(struct page *page, int bit_nr));
  75
  76/* 
  77 * Wait for a page to be unlocked.
  78 *
  79 * This must be called with the caller "holding" the page,
  80 * ie with increased "page->count" so that the page won't
  81 * go away during the wait..
  82 */
  83static inline void wait_on_page_locked(struct page *page)
  84{
  85        if (PageLocked(page))
  86                wait_on_page_bit(page, PG_locked);
  87}
  88
  89/* 
  90 * Wait for a page to complete writeback
  91 */
  92static inline void wait_on_page_writeback(struct page *page)
  93{
  94        if (PageWriteback(page))
  95                wait_on_page_bit(page, PG_writeback);
  96}
  97
  98extern void end_page_writeback(struct page *page);
  99#endif /* _LINUX_PAGEMAP_H */
 100
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.