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

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