root/fs/nfs/cache.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. nfs_bl_cache_invalidate
  2. nfs_bl_cache_revalidate
  3. nfs_cache_find

   1 
   2 void nfs_bl_cache_invalidate(nfs_cache *nh)
     /* [previous][next][first][last][top][bottom][index][help] */
   3 {
   4         unsigned long flags;
   5         save_flags(flags);
   6         cli();
   7         if(nh->inuse)
   8                 nh->dead=1;
   9         else
  10         {
  11                 kfree_s(nh->data);
  12                 nh->data=NULL;
  13                 nh->free=1;
  14         }
  15 }
  16 
  17 void nfs_bl_cache_revalidate(nfs_cache *nh, struct fattr fa)
     /* [previous][next][first][last][top][bottom][index][help] */
  18 {
  19         nh->fattr=fattr;
  20         nh->time=jiffies;
  21 }
  22 
  23 /*
  24  *      Find a block in the cache. We know the cache is block sized in block
  25  *      aligned space.
  26  */
  27  
  28 nfs_cache *nfs_cache_find(struct inode *inode, off_t pos)
     /* [previous][next][first][last][top][bottom][index][help] */
  29 {
  30         nfs_cache *nh=&nfs_cache_slot[0];
  31         nfs_cache *ffree=NULL;
  32         struct nfs_fattr fattr;
  33         int ct=0;
  34         while(ct<NH_CACHE_SIZE)
  35         {
  36                 if(nh->inode_num==inode->i_no && !nh->dead&&!nh->free&&nh->file_pos==pos)
  37                 {
  38                         if(abs(jiffies-nh->time)<EXPIRE_CACHE)
  39                                 return nh;
  40                         /*
  41                          *      Revalidate
  42                          */
  43                         
  44                         if(nfs_proc_getattr(NFS_SERVER(inode), NFS_FH(inode), &fattr))
  45                         {
  46                                 nfs_bl_cache_invalidate(nh);
  47                                 continue;       /* get attr failed */
  48                         }
  49                         if(nh->fattr.modified!=fattr.modified)
  50                         {
  51                                 nfs_bl_cache_invalidate(nh);
  52                                 continue;       /* cache is out of date */
  53                         }
  54                         nfs_refresh_inode(inode, fattr);
  55                         nh->fattr=fattr;
  56                         nfs_bl_cache_revalidate(nh);
  57                         return nh;
  58                 }
  59                 if(nh->free)
  60                         ffree=nh;
  61         }
  62         return ffree;
  63 }       

/* [previous][next][first][last][top][bottom][index][help] */