gfs2: don't use buffer_heads in gfs2_allocate_page_backing
Rewrite gfs2_allocate_page_backing to call gfs2_iomap_get_alloc and operate on struct iomap directly. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
		
							parent
							
								
									7770c93a46
								
							
						
					
					
						commit
						35af80aef9
					
				| @ -363,31 +363,30 @@ static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size) | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * gfs2_allocate_page_backing - Use bmap to allocate blocks |  * gfs2_allocate_page_backing - Allocate blocks for a write fault | ||||||
|  * @page: The (locked) page to allocate backing for |  * @page: The (locked) page to allocate backing for | ||||||
|  * |  * | ||||||
|  * We try to allocate all the blocks required for the page in |  * We try to allocate all the blocks required for the page in one go.  This | ||||||
|  * one go. This might fail for various reasons, so we keep |  * might fail for various reasons, so we keep trying until all the blocks to | ||||||
|  * trying until all the blocks to back this page are allocated. |  * back this page are allocated.  If some of the blocks are already allocated, | ||||||
|  * If some of the blocks are already allocated, thats ok too. |  * that is ok too. | ||||||
|  */ |  */ | ||||||
| 
 |  | ||||||
| static int gfs2_allocate_page_backing(struct page *page) | static int gfs2_allocate_page_backing(struct page *page) | ||||||
| { | { | ||||||
| 	struct inode *inode = page->mapping->host; | 	u64 pos = page_offset(page); | ||||||
| 	struct buffer_head bh; | 	u64 size = PAGE_SIZE; | ||||||
| 	unsigned long size = PAGE_SIZE; |  | ||||||
| 	u64 lblock = page->index << (PAGE_SHIFT - inode->i_blkbits); |  | ||||||
| 
 | 
 | ||||||
| 	do { | 	do { | ||||||
| 		bh.b_state = 0; | 		struct iomap iomap = { }; | ||||||
| 		bh.b_size = size; | 
 | ||||||
| 		gfs2_block_map(inode, lblock, &bh, 1); | 		if (gfs2_iomap_get_alloc(page->mapping->host, pos, 1, &iomap)) | ||||||
| 		if (!buffer_mapped(&bh)) |  | ||||||
| 			return -EIO; | 			return -EIO; | ||||||
| 		size -= bh.b_size; | 
 | ||||||
| 		lblock += (bh.b_size >> inode->i_blkbits); | 		iomap.length = min(iomap.length, size); | ||||||
|  | 		size -= iomap.length; | ||||||
|  | 		pos += iomap.length; | ||||||
| 	} while (size > 0); | 	} while (size > 0); | ||||||
|  | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user