From 5167464446e527b5a3b5618ba0baff93048bcbbe Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 30 Apr 2008 00:55:17 -0700 Subject: revert "memory hotplug: allocate usemap on the section with pgdat" This: commit 86f6dae1377523689bd8468fed2f2dd180fc0560 Author: Yasunori Goto Date: Mon Apr 28 02:13:33 2008 -0700 memory hotplug: allocate usemap on the section with pgdat Usemaps are allocated on the section which has pgdat by this. Because usemap size is very small, many other sections usemaps are allocated on only one page. If a section has usemap, it can't be removed until removing other sections. This dependency is not desirable for memory removing. Pgdat has similar feature. When a section has pgdat area, it must be the last section for removing on the node. So, if section A has pgdat and section B has usemap for section A, Both sections can't be removed due to dependency each other. To solve this issue, this patch collects usemap on same section with pgdat. If other sections doesn't have any dependency, this section will be able to be removed finally. Signed-off-by: Yasunori Goto Cc: Badari Pulavarty Cc: Yinghai Lu Cc: Yasunori Goto Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds broke davem's sparc64 bootup. Revert it while we work out what went wrong. Cc: Yasunori Goto Cc: Badari Pulavarty Cc: Yinghai Lu Cc: "David S. Miller" Cc: Heiko Carstens Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/sparse.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'mm/sparse.c') diff --git a/mm/sparse.c b/mm/sparse.c index d9409ba7a1a1..36511c7b5e2c 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -250,22 +250,11 @@ static unsigned long *__kmalloc_section_usemap(void) static unsigned long *__init sparse_early_usemap_alloc(unsigned long pnum) { - unsigned long *usemap, section_nr; + unsigned long *usemap; struct mem_section *ms = __nr_to_section(pnum); int nid = sparse_early_nid(ms); - struct pglist_data *pgdat = NODE_DATA(nid); - /* - * Usemap's page can't be freed until freeing other sections - * which use it. And, Pgdat has same feature. - * If section A has pgdat and section B has usemap for other - * sections (includes section A), both sections can't be removed, - * because there is the dependency each other. - * To solve above issue, this collects all usemap on the same section - * which has pgdat. - */ - section_nr = pfn_to_section_nr(__pa(pgdat) >> PAGE_SHIFT); - usemap = alloc_bootmem_section(usemap_size(), section_nr); + usemap = alloc_bootmem_node(NODE_DATA(nid), usemap_size()); if (usemap) return usemap; -- cgit v1.2.3-55-g7522 04f'>fs/splice.c
blob: 0a0b79b01d059a1c71b632de1807100578be8269 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                                          

                                                                       
  
                                                       

                                                             




                          
                         
                            
                       

                              
                         
                           
                      
                           
 





                                                                          
                                                                  


                                                             
                                      
 

                        


                                             
 








                                                                              
 
                                      
                                                              
 







                                                                        
         
 





                                                                    

 
                                                                     


                                                                
                                         

 



                                                                       

                                                                    

                                      
                

                                  



                                                                        
                                                     




                                       
 
                  
                                               






                                          
                                                    
                   
                                  

         
                 

                          
                   

 
                                                                   
                       

                                        
                                               
                                               
                                           
                                    

  


                                                                 


                                               
                                        
                                                 

 
                                                                  
                       

                                        
                                            

                                               
                                    

  





                                                
                                                                    


                                                                      
   

                                                    
 
                                               
                                    


                      
                    
 

                                                  
 
                  
                                     





                                                      

                                                                                        
                                                                      
 


                                                                   
                                                                     
                                            


                                                                 
                                       


                                        

                                              
 
                                             
                                      
                                                        




                                         
                                                     




                                              






                                                   
                                 


                                                                           


                                      


                                        

         
                          
                                                    
 





                                                                           

         
                                   
                                                 



                   




                                                                          
          


                                                                    

                                                      
                                               
                                         
                                                  
                          

                                 
                           




                                                
                                                
          
 
                                          
                                        

                                                                           

          


                                                                              
                              
 

                                                                          
                                                             
           
                                    

                                                                 
 
                  
                                         
                  

                                                                         
                   

                                                     
                          
                                                           





                                                                           
                                                          

                                                         

                                                     

                                      




                                                                          

                 






















                                                                             
                                        
                                                                          
                                                                          
 



                                                                            



                                                                         




                                                            







                                                                           








                                                                           
 



                                                                   
                                              





                                                                            
                                                                

                                                  

                                      















                                                                     

                          
                                                      
                           

                                                                    
                                      

                          
                                                            
                           

                                                              
                 
 

                                                
                                
                         

                               

         
          
                                                                               



                                                               
                                                              
 
                         
                                                  
 
                     

 


                                                             
                               



                                         




                                                                            
   


                                                                          


                        








                                                 


                    
                                 
                                                                             
 
                            
                              







                                                        
 
                             









                               

                                        
  
                                                                       
                                                     
   
                                                         

                                                                            
                                       
                             
                      
 
                                           

                                                                              
 


                                                                        
 
                   














                                                                         





                                                                        
   
                                                                              

                                               
                                       
                                                        
                                      
                          
                     
                

          
                                                        
           
                                           

                           
 

                                            



                                                    



                                                                          
 
                                


                                                  
                                                        
                                                        
 
                                                                  
                                        
                                             
                                                
         

                                                                             
    


                   











                                                                      
   

                                                                                
 
                                



                      
                  

                                                                            
                                                                         
 


                                                        
 
                                                   
                                       





                                                            



                                           



                                             
                                         
 

                                                
                                                        



                                                                                       

                         
                                           


                                      
                                 
                                 
                                   
                              
                                             



                                      
                                                    




                                              






                                                   
                                 


                                                                            


                                      
                                

         
                        
                         


                                                                    

         
                   
 
                                  
 













                                                                              





                                                                        



                                 
                              
          







                                                                    
                                                   








                                                                               
                                


                                         



                                                                        







                                                                                



                                 
                              
          


                    
                                              


                           
                                                          
                      

                                       
                             
                                                                           











                                                                             
                                                                      






                                                

                                                                
                         
                                
                                


                                         


                                                                        

   

                                                                         
                                                                       
 
                                                       
                                            
                               
                    
                    
 


                                                                    
                                            



                                                                          



                                              
 
                                                                          
                      

                                       
                             
                                                                           





                                                                            



                                                                             
 


                                          
                                                                      


                   

 

                                         

                                                                
                                   
                                  
                                


                                         


                                                                             

   
                                                                               
                                                                             
 
                                                                               

 
                                       
 


                                                  
                                                                          
                                                                        
 

                
                                                             

                               
                                                   

                              
                                                    


                              
                                                                    

 


                                                      


                                                                  
 

                
                                                          

                               
                                                 

                              
                                                  


                              
                                                                 

 








                                                                         
                                                                      

                   


                                                                       



                                     

                     





                                                                         
                                                    







                                                                             
                              





                                                                              
                                                                           







                                              
                         


                  






                                                                   

                     
                                
                                     
 
                                                               
                                       


                                         
                                         





                                                                        
                                      
                                       



                                         
                              
 

                                         


                                        























                                                                   






                                                            
                                       



                                                                              














                                                                              







                                                                      
                                      
          
                 

                                                                   


                             
                   

 
  












                                                                        

                                     


                                                               
 
                                     
                            
                 
 
                                                     


                                       


                                                           
                                                                             
                                               


                                          
 





                                                                          
         
 
                                                      


                                       


                                                          
                                                                            
                                               


                                         
 





                                                                        
         



                       
  


























                                                                               







                                                                          
                                                                          


                                   



                                          
                                   



                                  

                                                                        

                              


                                      


                                                            
                          










                                                                     








                                                                          














                                                                          
                                                                             




































                                                                             





                                                                              
                                           


























                                                                               
                                        


                                     















































































                                                                               



                                                                          
   

                                                                               
 
                                     






                                                  
                                                

          
                                                       
                  
                              
 

                                                                         


                                    
                                          

 















                                                                             






                                                                       




                                           



                                               


                                                                            






                                       


                                                              








                              
                                         

                                              
                                                            

                                                              


                                                                       








                                                          

  














































































                                                                            






                                                    
                                 





                                                                             
                                                      
 
            





                                                      
 





                                                                        
 

                                                                                

                  

                                                       
                   




                                            
                  

                                                          
                   
                                                   
 

                                        
 




                                 
 
                                                        
 



                                                                           

















                                                                       

                                                                               
                          

          

                                                                    
           














                                                                            
 
                   



























                                                                            
/*
 * "splice": joining two ropes together by interweaving their strands.
 *
 * This is the "extended pipe" functionality, where a pipe is used as
 * an arbitrary in-memory buffer. Think of a pipe as a small kernel
 * buffer that you can use to transfer data from one end to the other.
 *
 * The traditional unix read/write is extended with a "splice()" operation
 * that transfers data buffers to or from a pipe buffer.
 *
 * Named by Larry McVoy, original implementation from Linus, extended by
 * Jens to support splicing to files, network, direct splicing, etc and
 * fixing lots of bugs.
 *
 * Copyright (C) 2005-2006 Jens Axboe <axboe@kernel.dk>
 * Copyright (C) 2005-2006 Linus Torvalds <torvalds@osdl.org>
 * Copyright (C) 2006 Ingo Molnar <mingo@elte.hu>
 *
 */
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/pagemap.h>
#include <linux/splice.h>
#include <linux/mm_inline.h>
#include <linux/swap.h>
#include <linux/writeback.h>
#include <linux/buffer_head.h>
#include <linux/module.h>
#include <linux/syscalls.h>
#include <linux/uio.h>
#include <linux/security.h>

/*
 * Attempt to steal a page from a pipe buffer. This should perhaps go into
 * a vm helper function, it's already simplified quite a bit by the
 * addition of remove_mapping(). If success is returned, the caller may
 * attempt to reuse this page for another destination.
 */
static int page_cache_pipe_buf_steal(struct pipe_inode_info *pipe,
				     struct pipe_buffer *buf)
{
	struct page *page = buf->page;
	struct address_space *mapping;

	lock_page(page);

	mapping = page_mapping(page);
	if (mapping) {
		WARN_ON(!PageUptodate(page));

		/*
		 * At least for ext2 with nobh option, we need to wait on
		 * writeback completing on this page, since we'll remove it
		 * from the pagecache.  Otherwise truncate wont wait on the
		 * page, allowing the disk blocks to be reused by someone else
		 * before we actually wrote our data to them. fs corruption
		 * ensues.
		 */
		wait_on_page_writeback(page);

		if (PagePrivate(page))
			try_to_release_page(page, GFP_KERNEL);

		/*
		 * If we succeeded in removing the mapping, set LRU flag
		 * and return good.
		 */
		if (remove_mapping(mapping, page)) {
			buf->flags |= PIPE_BUF_FLAG_LRU;
			return 0;
		}
	}

	/*
	 * Raced with truncate or failed to remove page from current
	 * address space, unlock and return failure.
	 */
	unlock_page(page);
	return 1;
}

static void page_cache_pipe_buf_release(struct pipe_inode_info *pipe,
					struct pipe_buffer *buf)
{
	page_cache_release(buf->page);
	buf->flags &= ~PIPE_BUF_FLAG_LRU;
}

/*
 * Check whether the contents of buf is OK to access. Since the content
 * is a page cache page, IO may be in flight.
 */
static int page_cache_pipe_buf_confirm(struct pipe_inode_info *pipe,
				       struct pipe_buffer *buf)
{
	struct page *page = buf->page;
	int err;

	if (!PageUptodate(page)) {
		lock_page(page);

		/*
		 * Page got truncated/unhashed. This will cause a 0-byte
		 * splice, if this is the first page.
		 */
		if (!page->mapping) {
			err = -ENODATA;
			goto error;
		}

		/*
		 * Uh oh, read-error from disk.
		 */
		if (!PageUptodate(page)) {
			err = -EIO;
			goto error;
		}

		/*
		 * Page is ok afterall, we are done.
		 */
		unlock_page(page);
	}

	return 0;
error:
	unlock_page(page);
	return err;
}

static const struct pipe_buf_operations page_cache_pipe_buf_ops = {
	.can_merge = 0,
	.map = generic_pipe_buf_map,
	.unmap = generic_pipe_buf_unmap,
	.confirm = page_cache_pipe_buf_confirm,
	.release = page_cache_pipe_buf_release,
	.steal = page_cache_pipe_buf_steal,
	.get = generic_pipe_buf_get,
};

static int user_page_pipe_buf_steal(struct pipe_inode_info *pipe,
				    struct pipe_buffer *buf)
{
	if (!(buf->flags & PIPE_BUF_FLAG_GIFT))
		return 1;

	buf->flags |= PIPE_BUF_FLAG_LRU;
	return generic_pipe_buf_steal(pipe, buf);
}

static const struct pipe_buf_operations user_page_pipe_buf_ops = {
	.can_merge = 0,
	.map = generic_pipe_buf_map,
	.unmap = generic_pipe_buf_unmap,
	.confirm = generic_pipe_buf_confirm,
	.release = page_cache_pipe_buf_release,
	.steal = user_page_pipe_buf_steal,
	.get = generic_pipe_buf_get,
};

/**
 * splice_to_pipe - fill passed data into a pipe
 * @pipe:	pipe to fill
 * @spd:	data to fill
 *
 * Description:
 *    @spd contains a map of pages and len/offset tuples, along with
 *    the struct pipe_buf_operations associated with these pages. This
 *    function will link that data to the pipe.
 *
 */
ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
		       struct splice_pipe_desc *spd)
{
	unsigned int spd_pages = spd->nr_pages;
	int ret, do_wakeup, page_nr;

	ret = 0;
	do_wakeup = 0;
	page_nr = 0;

	if (pipe->inode)
		mutex_lock(&pipe->inode->i_mutex);

	for (;;) {
		if (!pipe->readers) {