forked from mirrors/linux
		
	readahead: Use a folio in read_pages()
Handle multi-page folios correctly and removes a few calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
		
							parent
							
								
									2ca456c248
								
							
						
					
					
						commit
						a42634a6c0
					
				
					 1 changed files with 12 additions and 13 deletions
				
			
		|  | @ -145,7 +145,7 @@ EXPORT_SYMBOL_GPL(file_ra_state_init); | ||||||
| static void read_pages(struct readahead_control *rac) | static void read_pages(struct readahead_control *rac) | ||||||
| { | { | ||||||
| 	const struct address_space_operations *aops = rac->mapping->a_ops; | 	const struct address_space_operations *aops = rac->mapping->a_ops; | ||||||
| 	struct page *page; | 	struct folio *folio; | ||||||
| 	struct blk_plug plug; | 	struct blk_plug plug; | ||||||
| 
 | 
 | ||||||
| 	if (!readahead_count(rac)) | 	if (!readahead_count(rac)) | ||||||
|  | @ -156,24 +156,23 @@ static void read_pages(struct readahead_control *rac) | ||||||
| 	if (aops->readahead) { | 	if (aops->readahead) { | ||||||
| 		aops->readahead(rac); | 		aops->readahead(rac); | ||||||
| 		/*
 | 		/*
 | ||||||
| 		 * Clean up the remaining pages.  The sizes in ->ra | 		 * Clean up the remaining folios.  The sizes in ->ra | ||||||
| 		 * may be used to size the next readahead, so make sure | 		 * may be used to size the next readahead, so make sure | ||||||
| 		 * they accurately reflect what happened. | 		 * they accurately reflect what happened. | ||||||
| 		 */ | 		 */ | ||||||
| 		while ((page = readahead_page(rac))) { | 		while ((folio = readahead_folio(rac)) != NULL) { | ||||||
| 			rac->ra->size -= 1; | 			unsigned long nr = folio_nr_pages(folio); | ||||||
| 			if (rac->ra->async_size > 0) { | 
 | ||||||
| 				rac->ra->async_size -= 1; | 			rac->ra->size -= nr; | ||||||
| 				delete_from_page_cache(page); | 			if (rac->ra->async_size >= nr) { | ||||||
|  | 				rac->ra->async_size -= nr; | ||||||
|  | 				filemap_remove_folio(folio); | ||||||
| 			} | 			} | ||||||
| 			unlock_page(page); | 			folio_unlock(folio); | ||||||
| 			put_page(page); |  | ||||||
| 		} | 		} | ||||||
| 	} else { | 	} else { | ||||||
| 		while ((page = readahead_page(rac))) { | 		while ((folio = readahead_folio(rac))) | ||||||
| 			aops->readpage(rac->file, page); | 			aops->readpage(rac->file, &folio->page); | ||||||
| 			put_page(page); |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	blk_finish_plug(&plug); | 	blk_finish_plug(&plug); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Matthew Wilcox (Oracle)
						Matthew Wilcox (Oracle)