/drivers/net/hippi/

y>
aboutsummaryrefslogblamecommitdiffstats
path: root/mm/cleancache.c
blob: 8fc50811119b28b54f15ac875ddc956217acc570 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                                     
                          


                             
                                                                           

                                                        
                                                           
 
  
                                                                     






                                                                            
 










                                                                            

  
                                                            
   
                                                       
 
                                                
                              
 
          
















































                                                                               
           
                                                         
                 





                                                                
                                            
 



                                                             
         
                                        



                                                                          
                                                        
 
                                                   
 



                                                                                
         
                                        









                                                                       
                                                                      






                                                  
                                                                           
                                                                        













                                                                        



                                                                   






                                                           
                              



                                         
                                                

                                                               




                                                              
                                                                        













                                                                       



                                                                   





                                                           
                              



                                  
                                                
                                                               
                           
                                                                     
                                                                          





                                     
                                                                         
                                                                    



                                                                   
   

                                                                

                                                                            
                                                             

                                                           
                            

                       
                           
                                                        
                                                                   
                                                                
                                                          
                                                 


                 
                                            

  
                                                                         

                                                                    



                                                                   
   
                                                                 
 
                                                             

                                                           
                            

                       
                                                                         
                                                               
 
                                             


                                                                  

                                                                       
   
                                                       
 
                    
 




                                                       
 
                                          
 

                                       










                                                                              


                            
/*
 * Cleancache frontend
 *
 * This code provides the generic "frontend" layer to call a matching
 * "backend" driver implementation of cleancache.  See
 * Documentation/vm/cleancache.txt for more information.
 *
 * Copyright (C) 2009-2010 Oracle Corp. All rights reserved.
 * Author: Dan Magenheimer
 *
 * This work is licensed under the terms of the GNU GPL, version 2.
 */

#include <linux/module.h>
#include <linux/fs.h>
#include <linux/exportfs.h>
#include <linux/mm.h>
#include <linux/debugfs.h>
#include <linux/cleancache.h>

/*
 * cleancache_ops is set by cleancache_register_ops to contain the pointers
 * to the cleancache "backend" implementation functions.
 */
static struct cleancache_ops *cleancache_ops __read_mostly;

/*
 * Counters available via /sys/kernel/debug/cleancache (if debugfs is
 * properly configured.  These are for information only so are not protected
 * against increment races.
 */
static u64 cleancache_succ_gets;
static u64 cleancache_failed_gets;
static u64 cleancache_puts;
static u64 cleancache_invalidates;

static void cleancache_register_ops_sb(struct super_block *sb, void *unused)
{
	switch (sb->cleancache_poolid) {
	case CLEANCACHE_NO_BACKEND:
		__cleancache_init_fs(sb);
		break;
	case CLEANCACHE_NO_BACKEND_SHARED:
		__cleancache_init_shared_fs(sb);
		break;
	}
}

/*
 * Register operations for cleancache. Returns 0 on success.
 */
int cleancache_register_ops(struct cleancache_ops *ops)
{
	if (cmpxchg(&cleancache_ops, NULL, ops))
		return -EBUSY;

	/*
	 * A cleancache backend can be built as a module and hence loaded after
	 * a cleancache enabled filesystem has called cleancache_init_fs. To
	 * handle such a scenario, here we call ->init_fs or ->init_shared_fs
	 * for each active super block. To differentiate between local and
	 * shared filesystems, we temporarily initialize sb->cleancache_poolid
	 * to CLEANCACHE_NO_BACKEND or CLEANCACHE_NO_BACKEND_SHARED
	 * respectively in case there is no backend registered at the time
	 * cleancache_init_fs or cleancache_init_shared_fs is called.
	 *
	 * Since filesystems can be mounted concurrently with cleancache
	 * backend registration, we have to be careful to guarantee that all
	 * cleancache enabled filesystems that has been mounted by the time
	 * cleancache_register_ops is called has got and all mounted later will
	 * get cleancache_poolid. This is assured by the following statements
	 * tied together:
	 *
	 * a) iterate_supers skips only those super blocks that has started
	 *    ->kill_sb
	 *
	 * b) if iterate_supers encounters a super block that has not finished