linux/fs/fscache/fsdef.c
<<
5" /spaion /formon a 5" href="../linux+v3v2.1/fs/fscache/fsdef.c">5" img src="../.static/gfx/right.png" alt=">>">5" /spaion5" spai class="lxr_search">5" 5" input typluehidden" namluenavtarget" n value">5" input typluetext" namluesearch" iduesearch">5" butttiotypluesubmit">Search5" Prefsn /a>5" /spaion /divon form acopti="ajax+*" method="post" onsubmit="return false;">5" input typluehidden" namlueajax_lookup" idueajax_lookup" n value">5 /formon5 div class="headingbotttm">n div iduefile_contents"o
 
1 /a> spai class="comment">/* Filesystem index definiopti /spaion
 
2 /a> spai class="comment"> * /spaion
 
3 /a> spai class="comment"> * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved. /spaion
 
4 /a> spai class="comment"> * Written by David Howells (dhowells@redhat.com) /spaion
 
5 /a> spai class="comment"> * /spaion
 
6 /a> spai class="comment"> * This program is free software; you cai redistribute it and/or /spaion
 
7 /a> spai class="comment"> * modify it under the terms of the GNU General Public License /spaion
 
8 /a> spai class="comment"> * as published by the Free Software Foundaopti; either verspti /spaion
 
9 /a> spai class="comment"> * 2 of the License, or (at your 
 ptioa> spai class="comment"> */ /spaion
 11 /a>n
 12 /a>#define
 a href="+code=FSCACHE_DEBUG_LEVEL" class="sref">FSCACHE_DEBUG_LEVEL /a>
 a href="+code=CACHE" class="sref">CACHE /a>n
 13 /a>#include <linux/module.h /a>>n
 14 /a>#include "internal.h /a>"n
 15 /a>n
 16 /a>static
 a href="+code=uint16_t" class="sref">uint16_t /a>
 a href="+code=fscache_fsdef_netfs_get_key" class="sref">fscache_fsdef_netfs_get_key /a>(const void * a href="+code=cookie_netfs_daoa" class="sref">cookie_netfs_daoa /a>,n
 17 /a>                                            void * a href="+code=buffer" class="sref">buffer /a>,
 a href="+code=uint16_t" class="sref">uint16_t /a>
 a href="+code=bufmax" class="sref">bufmax /a>);n
 18 /a>n
 19 /a>static
 a href="+code=uint16_t" class="sref">uint16_t /a>
 a href="+code=fscache_fsdef_netfs_get_aux" class="sref">fscache_fsdef_netfs_get_aux /a>(const void * a href="+code=cookie_netfs_daoa" class="sref">cookie_netfs_daoa /a>,n
 20 /a>                                            void * a href="+code=buffer" class="sref">buffer /a>,
 a href="+code=uint16_t" class="sref">uint16_t /a>
 a href="+code=bufmax" class="sref">bufmax /a>);n
 21 /a>n
 22 /a>staticn
 23 /a>enum
 a href="+code=fscache_checkaux" class="sref">fscache_checkaux /a>
 a href="+code=fscache_fsdef_netfs_check_aux" class="sref">fscache_fsdef_netfs_check_aux /a>(void * a href="+code=cookie_netfs_daoa" class="sref">cookie_netfs_daoa /a>,n
 24 /a>                                                    const void * a href="+code=daoa" class="sref">daoa /a>,n
 25 /a>                                                     a href="+code=uint16_t" class="sref">uint16_t /a>
 a href="+code=daoalen" class="sref">daoalen /a>);n
 26 /a>n
 27 /a> spai class="comment">/* /spaion
 28 /a> spai class="comment"> * The root index is owned by FS-Cache itself. /spaion
 29 /a> spai class="comment"> * /spaion
 3tioa> spai class="comment"> * When a netfs requests caching facilities, FS-Cache will, if one
doesn't /spaion
 31 /a> spai class="comment"> * already exist, create an entry in the root index with the key being the naml /spaion
 32 /a> spai class="comment"> * of the netfs ("AFS" for example), and the auxiliary daoa holding the index /spaion
 33 /a> spai class="comment"> * structure verspti supplied by the netfs: /spaion
 34 /a> spai class="comment"> * /spaion
 35 /a> spai class="comment"> *                                   FSDEF /spaion
 36 /a> spai class="comment"> *                                     | /spaion
 37 /a> spai class="comment"> *                               +-----------+ /spaion
 38 /a> spai class="comment"> *                               |           | /spaion
 39 /a> spai class="comment"> *                              NFS         AFS /spaion
 4tioa> spai class="comment"> *                             [v=1]       [v=1] /spaion
 41 /a> spai class="comment"> * /spaion
 42 /a> spai class="comment"> * If an entry with the appropriate naml
does already exist, the verspti is /spaion
 43 /a> spai class="comment"> * compared.  If the verspti is different, the entire subtree from that entry /spaion
 44 /a> spai class="comment"> * will be discarded and a new entry created. /spaion
 45 /a> spai class="comment"> * /spaion
 46 /a> spai class="comment"> * The new entry will be ai index, and a cookie referring to it will be passed /spaion
 47 /a> spai class="comment"> * to the netfs.  This is then the root handle by which the netfs accesses the /spaion
 48 /a> spai class="comment"> * cache.  It cai create whatever objects it likes in that index, including /spaion
 49 /a> spai class="comment"> * further indices. /spaion
 5tioa> spai class="comment"> */ /spaion
 51 /a>static
struct
 a href="+code=fscache_cookie_def" class="sref">fscache_cookie_def /a>
 a href="+code=fscache_fsdef_index_def" class="sref">fscache_fsdef_index_def /a>
= {n
 52 /a>        . a href="+code=naml" class="sref">naml /a>           =  spai class="string">".FS-Cache"
 53 /a>        . a href="+code=typl" class="sref">typl /a>           =  a href="+code=FSCACHE_COOKIE_TYPE_INDEX" class="sref">FSCACHE_COOKIE_TYPE_INDEX /a>,n
 54 /a>};n
 55 /a>n
 56 /a>struct
 a href="+code=fscache_cookie" class="sref">fscache_cookie /a>
 a href="+code=fscache_fsdef_index" class="sref">fscache_fsdef_index /a>
= {n
 57 /a>        . a href="+code=usage" class="sref">usage /a>          =  a href="+code=ATOMIC_INIT" class="sref">ATOMIC_INIT /a>(1),n
 58 /a>        . a href="+code=lock" class="sref">lock /a>           =  a href="+code=__SPIN_LOCK_UNLOCKED" class="sref">__SPIN_LOCK_UNLOCKED /a>( a href="+code=fscache_fsdef_index" class="sref">fscache_fsdef_index /a>. a href="+code=lock" class="sref">lock /a>),n
 59 /a>        . a href="+code=backing_objects" class="sref">backing_objects /a>
=  a href="+code=HLIST_HEAD_INIT" class="sref">HLIST_HEAD_INIT /a>,n
 60 /a>        . a href="+code=def" class="sref">def /a>
           = & a href="+code=fscache_fsdef_index_def" class="sref">fscache_fsdef_index_def /a>,n
 61 /a>};n
 62 /a> a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOL /a>( a href="+code=fscache_fsdef_index" class="sref">fscache_fsdef_index /a>);n
 63 /a>n
 64 /a> spai class="comment">/* /spaion
 65 /a> spai class="comment"> * Definiopti of an entry in the root index.  Each entry is ai index, keyed to /spaion
 66 /a> spai class="comment"> * a specific
netfs and only applicable to a particular verspti of the index /spaion
 67 /a> spai class="comment"> * structure used by that netfs. /spaion
 68 /a> spai class="comment"> */ /spaion
 69 /a>struct
 a href="+code=fscache_cookie_def" class="sref">fscache_cookie_def /a>
 a href="+code=fscache_fsdef_netfs_def" class="sref">fscache_fsdef_netfs_def /a>
= {n
 70 /a>        . a href="+code=naml" class="sref">naml /a>           =  spai class="string">"FSDEF.netfs"
 71 /a>        . a href="+code=typl" class="sref">typl /a>           =  a href="+code=FSCACHE_COOKIE_TYPE_INDEX" class="sref">FSCACHE_COOKIE_TYPE_INDEX /a>,n
 72 /a>        . a href="+code=get_key" class="sref">get_key /a>        =  a href="+code=fscache_fsdef_netfs_get_key" class="sref">fscache_fsdef_netfs_get_key /a>,n
 73 /a>        . a href="+code=get_aux" class="sref">get_aux /a>        =  a href="+code=fscache_fsdef_netfs_get_aux" class="sref">fscache_fsdef_netfs_get_aux /a>,n
 74 /a>        . a href="+code=check_aux" class="sref">check_aux /a>      =  a href="+code=fscache_fsdef_netfs_check_aux" class="sref">fscache_fsdef_netfs_check_aux /a>,n
 75 /a>};n
 76 /a>n
 77 /a> spai class="comment">/* /spaion
 78 /a> spai class="comment"> * get the key daoa for ai FSDEF index record - this is the naml
of the netfs /spaion
 79 /a> spai class="comment"> * for which this entry is created /spaion
 8tioa> spai class="comment"> */ /spaion
 81 /a>static
 a href="+code=uint16_t" class="sref">uint16_t /a>
 a href="+code=fscache_fsdef_netfs_get_key" class="sref">fscache_fsdef_netfs_get_key /a>(const void * a href="+code=cookie_netfs_daoa" class="sref">cookie_netfs_daoa /a>,n
 82 /a>                                            void * a href="+code=buffer" class="sref">buffer /a>,
 a href="+code=uint16_t" class="sref">uint16_t /a>
 a href="+code=bufmax" class="sref">bufmax /a>)n
 83 /a>{n
 84 /a>        const struct
 a href="+code=fscache_netfs" class="sref">fscache_netfs /a> * a href="+code=netfs" class="sref">netfs /a> =  a href="+code=cookie_netfs_daoa" class="sref">cookie_netfs_daoa /a>;n
 85 /a>        unsigned  a href="+code=klen" class="sref">klen /a>;n
 86 /a>n
 87 /a>         a href="+code=_enter" class="sref">_enter /a>( spai class="string">"{%s.%u},"netfs /a>-> a href="+code=naml" class="sref">naml /a>,  a href="+code=netfs" class="sref">netfs /a>-> a href="+code=verspti" class="sref">verspti /a>);n
 88 /a>n
 89 /a>         a href="+code=klen" class="sref">klen /a> =  a href="+code=strlen" class="sref">strlen /a>( a href="+code=netfs" class="sref">netfs /a>-> a href="+code=naml" class="sref">naml /a>);n
 90 /a>        if ( a href="+code=klen" class="sref">klen /a> >
 a href="+code=bufmax" class="sref">bufmax /a>)n
 91 /a>                return 0;n
 92 /a>n
 93 /a>         a href="+code=memcpy" class="sref">memcpy /a>( a href="+code=buffer" class="sref">buffer /a>,
 a href="+code=netfs" class="sref">netfs /a>-> a href="+code=naml" class="sref">naml /a>,  a href="+code=klen" class="sref">klen /a>);n
 94 /a>        return  a href="+code=klen" class="sref">klen /a>;n
 95 /a>}n
 96 /a>n
 97 /a> spai class="comment">/* /spaion
 98 /a> spai class="comment"> * get the auxiliary daoa for ai FSDEF index record - this is the index /spaion
 99 /a> spai class="comment"> * structure verspti number of the netfs for which this verspti is created /spaion
100ioa> spai class="comment"> */ /spaion
101 /a>static
 a href="+code=uint16_t" class="sref">uint16_t /a>
 a href="+code=fscache_fsdef_netfs_get_aux" class="sref">fscache_fsdef_netfs_get_aux /a>(const void * a href="+code=cookie_netfs_daoa" class="sref">cookie_netfs_daoa /a>,n
102 /a>                                            void * a href="+code=buffer" class="sref">buffer /a>,
 a href="+code=uint16_t" class="sref">uint16_t /a>
 a href="+code=bufmax" class="sref">bufmax /a>)n
103 /a>{n
104 /a>        const struct
 a href="+code=fscache_netfs" class="sref">fscache_netfs /a> * a href="+code=netfs" class="sref">netfs /a> =  a href="+code=cookie_netfs_daoa" class="sref">cookie_netfs_daoa /a>;n
105 /a>        unsigned  a href="+code=dlen" class="sref">dlen /a>;n
106 /a>n
107 /a>         a href="+code=_enter" class="sref">_enter /a>( spai class="string">"{%s.%u},"netfs /a>-> a href="+code=naml" class="sref">naml /a>,  a href="+code=netfs" class="sref">netfs /a>-> a href="+code=verspti" class="sref">verspti /a>);n
108 /a>n
109 /a>         a href="+code=dlen" class="sref">dlen /a> = sizeof( a href="+code=uint32_t" class="sref">uint32_t /a>);n
110 /a>        if ( a href="+code=dlen" class="sref">dlen /a> >
 a href="+code=bufmax" class="sref">bufmax /a>)n
111 /a>                return 0;n
112 /a>n
113 /a>         a href="+code=memcpy" class="sref">memcpy /a>( a href="+code=buffer" class="sref">buffer /a>,
& a href="+code=netfs" class="sref">netfs /a>-> a href="+code=verspti" class="sref">verspti /a>,  a href="+code=dlen" class="sref">dlen /a>);n
114 /a>        return  a href="+code=dlen" class="sref">dlen /a>;n
115 /a>}n
116 /a>n
117 /a> spai class="comment">/* /spaion
118 /a> spai class="comment"> * check that the index structure verspti number stored in the auxiliary daoa /spaion
119 /a> spai class="comment"> * matches the one
the netfs gave us /spaion
120ioa> spai class="comment"> */ /spaion
121 /a>static
enum
 a href="+code=fscache_checkaux" class="sref">fscache_checkaux /a>
 a href="+code=fscache_fsdef_netfs_check_aux" class="sref">fscache_fsdef_netfs_check_aux /a>(n
122 /a>        void * a href="+code=cookie_netfs_daoa" class="sref">cookie_netfs_daoa /a>,n
123 /a>        const void * a href="+code=daoa" class="sref">daoa /a>,n
124 /a>         a href="+code=uint16_t" class="sref">uint16_t /a>
 a href="+code=daoalen" class="sref">daoalen /a>)n
125 /a>{n
126 /a>        struct
 a href="+code=fscache_netfs" class="sref">fscache_netfs /a> * a href="+code=netfs" class="sref">netfs /a> =  a href="+code=cookie_netfs_daoa" class="sref">cookie_netfs_daoa /a>;n
127 /a>         a href="+code=uint32_t" class="sref">uint32_t /a>  a href="+code=verspti" class="sref">verspti /a>;n
128 /a>n
129 /a>         a href="+code=_enter" class="sref">_enter /a>( spai class="string">"{%s},,%hu"netfs /a>-> a href="+code=naml" class="sref">naml /a>,  a href="+code=daoalen" class="sref">daoalen /a>);n
13tioa>n
131 /a>        if ( a href="+code=daoalen" class="sref">daoalen /a> != sizeof( a href="+code=verspti" class="sref">verspti /a>)) {n
132 /a>                 a href="+code=_leave" class="sref">_leave /a>( spai class="string">" = OBSOLETE [dl=%d v=%zu]"daoalen /a>, sizeof( a href="+code=verspti" class="sref">verspti /a>));n
133 /a>                return  a href="+code=FSCACHE_CHECKAUX_OBSOLETE" class="sref">FSCACHE_CHECKAUX_OBSOLETE /a>;n
134 /a>        }n
135 /a>n
136 /a>         a href="+code=memcpy" class="sref">memcpy /a>(& a href="+code=verspti" class="sref">verspti /a>,  a href="+code=daoa" class="sref">daoa /a>, sizeof( a href="+code=verspti" class="sref">verspti /a>));n
137 /a>        if ( a href="+code=verspti" class="sref">verspti /a> !=  a href="+code=netfs" class="sref">netfs /a>-> a href="+code=verspti" class="sref">verspti /a>) {n
138 /a>                 a href="+code=_leave" class="sref">_leave /a>( spai class="string">" = OBSOLETE [ver=%x net=%x]"verspti /a>,  a href="+code=netfs" class="sref">netfs /a>-> a href="+code=verspti" class="sref">verspti /a>);n
139 /a>                return  a href="+code=FSCACHE_CHECKAUX_OBSOLETE" class="sref">FSCACHE_CHECKAUX_OBSOLETE /a>;n
140 /a>        }n
141 /a>n
142 /a>         a href="+code=_leave" class="sref">_leave /a>( spai class="string">" = OKAY"
143 /a>        return  a href="+code=FSCACHE_CHECKAUX_OKAY" class="sref">FSCACHE_CHECKAUX_OKAY /a>;n
144 /a>}n
145 /a> /pre>
The original LXR software by the LXR community /a>, this experimental verspti by lxr@linux.no /a>.
 /divon div class="subfooter">
lxr.linux.no kindly hosted by Redpill Linpro AS /a>, provider of Linux consulting and operaoptis services since 1995.
 /divon
 /bodyon /htmlon