The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/vm/vnode_pager.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
    5  * 
    6  * This file contains Original Code and/or Modifications of Original Code
    7  * as defined in and that are subject to the Apple Public Source License
    8  * Version 2.0 (the 'License'). You may not use this file except in
    9  * compliance with the License. The rights granted to you under the License
   10  * may not be used to create, or enable the creation or redistribution of,
   11  * unlawful or unlicensed copies of an Apple operating system, or to
   12  * circumvent, violate, or enable the circumvention or violation of, any
   13  * terms of an Apple operating system software license agreement.
   14  * 
   15  * Please obtain a copy of the License at
   16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
   17  * 
   18  * The Original Code and all software distributed under the License are
   19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   23  * Please see the License for the specific language governing rights and
   24  * limitations under the License.
   25  * 
   26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
   27  */
   28 /* 
   29  * Mach Operating System
   30  * Copyright (c) 1987 Carnegie-Mellon University
   31  * All rights reserved.  The CMU software License Agreement specifies
   32  * the terms and conditions for use and redistribution.
   33  */
   34 
   35 #ifndef _VNODE_PAGER_
   36 #define _VNODE_PAGER_   1
   37 
   38 #include <mach/kern_return.h>
   39 #include <sys/types.h>
   40 #include <kern/queue.h>
   41 
   42 #ifdef  KERNEL
   43 #include <mach/boolean.h>
   44 #include <mach/memory_object_types.h>
   45 #include <mach/vm_types.h>
   46 #include <vm/vm_pager.h>
   47 
   48 vm_pager_t      vnode_pager_setup(struct vnode *, memory_object_t);
   49 
   50 /*
   51  *  Vstructs are the internal (to us) description of a unit of backing store.
   52  *  The are the link between memory objects and the backing store they represent.
   53  *  For the vnode pager, backing store comes in two flavors: normal files and
   54  *  swap files.
   55  *
   56  *  For objects that page to and from normal files (e.g. objects that represent
   57  *  program text segments), we maintain some simple parameters that allow us to
   58  *  access the file's contents directly through the vnode interface.
   59  *
   60  *  Data for objects without associated vnodes is maintained in the swap files.
   61  *  Each object that uses one of these as backing store has a vstruct indicating
   62  *  the swap file of preference (vs_pf) and a mapping between contiguous object
   63  *  offsets and swap file offsets (vs_pmap).  Each entry in this mapping specifies
   64  *  the pager file to use, and the offset of the page in that pager file.  These
   65  *  mapping entries are of type pfMapEntry.
   66  */
   67 
   68 /*
   69  * Pager file structure.  One per swap file.
   70  */
   71 typedef struct pager_file {
   72         queue_chain_t   pf_chain;       /* link to other paging files */
   73         struct  vnode   *pf_vp;         /* vnode of paging file */
   74         u_int           pf_count;       /* Number of vstruct using this file */
   75         u_char          *pf_bmap;       /* Map of used blocks */
   76         long            pf_npgs;        /* Size of file in pages */
   77         long            pf_pfree;       /* Number of unused pages */
   78         long            pf_lowat;       /* Low water page */
   79         long            pf_hipage;      /* Highest page allocated */
   80         long            pf_hint;        /* Lowest page unallocated */
   81         char            *pf_name;       /* Filename of this file */
   82         boolean_t       pf_prefer;
   83         int             pf_index;       /* index into the pager_file array */
   84         void *          pf_lock;        /* Lock for alloc and dealloc */
   85 } *pager_file_t;
   86 
   87 #define PAGER_FILE_NULL (pager_file_t) 0
   88 
   89 #define MAXPAGERFILES 16
   90 
   91 #define MAX_BACKING_STORE 100
   92 
   93 struct bs_map {
   94         struct vnode    *vp;   
   95         void            *bs;
   96 };
   97 extern struct bs_map  bs_port_table[];
   98 
   99 
  100 
  101 /*
  102  * Pager file data structures.
  103  */
  104 #define INDEX_NULL      0
  105 typedef struct {
  106         unsigned int index:8;   /* paging file this block is in */
  107         unsigned int offset:24; /* page number where block resides */
  108 } pf_entry;
  109 
  110 typedef enum {
  111                 IS_INODE,       /* Local disk */
  112                 IS_RNODE        /* NFS */
  113         } vpager_fstype;
  114 
  115 /*
  116  *  Basic vnode pager structure.  One per object, backing-store pair.
  117  */
  118 typedef struct vstruct {
  119         boolean_t       is_device;      /* Must be first - see vm_pager.h */
  120         pager_file_t    vs_pf;          /* Pager file this uses */
  121         pf_entry        **vs_pmap;      /* Map of pages into paging file */
  122         unsigned int
  123         /* boolean_t */ vs_swapfile:1;  /* vnode is a swapfile */
  124         short           vs_count;       /* use count */
  125         int             vs_size;        /* size of this chunk in pages*/
  126         struct vnode    *vs_vp;         /* vnode to page to */
  127 } *vnode_pager_t;
  128 
  129 #define VNODE_PAGER_NULL        ((vnode_pager_t) 0)
  130 
  131 
  132 pager_return_t  vnode_pagein(struct vnode *, upl_t,
  133                              upl_offset_t, vm_object_offset_t,
  134                              upl_size_t, int, int *);
  135 pager_return_t  vnode_pageout(struct vnode *, upl_t,
  136                               upl_offset_t, vm_object_offset_t,
  137                               upl_size_t, int, int *);
  138 
  139 extern vm_object_offset_t vnode_pager_get_filesize(
  140         struct vnode *vp);
  141 
  142 extern kern_return_t vnode_pager_get_pathname(
  143         struct vnode    *vp,
  144         char            *pathname,
  145         vm_size_t       *length_p);
  146 
  147 extern kern_return_t vnode_pager_get_filename(
  148         struct vnode    *vp,
  149         const char      **filename);
  150 
  151 extern kern_return_t vnode_pager_get_cs_blobs(
  152         struct vnode    *vp,
  153         void            **blobs);
  154 
  155 #endif  /* KERNEL */
  156 
  157 #endif  /* _VNODE_PAGER_ */

Cache object: b29f18ae0c5c7c89a675d588629b7de8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.