mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	ext4: Make ext4_write_inline_data_end() use folio
ext4_write_inline_data_end() is completely converted to work with folio. Also all callers of ext4_write_inline_data_end() already works on folio except ext4_da_write_end(). Mostly for consistency and saving few instructions maybe, this patch just converts ext4_da_write_end() to work with folio which makes the last caller of ext4_write_inline_data_end() also converted to work with folio. We then make ext4_write_inline_data_end() take folio instead of page. Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Link: https://lore.kernel.org/r/1bcea771720ff451a5a59b3f1bcd5fae51cb7ce7.1684122756.git.ritesh.list@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
		
							parent
							
								
									80be8c5cc9
								
							
						
					
					
						commit
						d19500da4b
					
				
					 3 changed files with 17 additions and 15 deletions
				
			
		| 
						 | 
					@ -3480,10 +3480,8 @@ extern int ext4_try_to_write_inline_data(struct address_space *mapping,
 | 
				
			||||||
					 struct inode *inode,
 | 
										 struct inode *inode,
 | 
				
			||||||
					 loff_t pos, unsigned len,
 | 
										 loff_t pos, unsigned len,
 | 
				
			||||||
					 struct page **pagep);
 | 
										 struct page **pagep);
 | 
				
			||||||
extern int ext4_write_inline_data_end(struct inode *inode,
 | 
					int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
 | 
				
			||||||
				      loff_t pos, unsigned len,
 | 
								       unsigned copied, struct folio *folio);
 | 
				
			||||||
				      unsigned copied,
 | 
					 | 
				
			||||||
				      struct page *page);
 | 
					 | 
				
			||||||
extern int ext4_da_write_inline_data_begin(struct address_space *mapping,
 | 
					extern int ext4_da_write_inline_data_begin(struct address_space *mapping,
 | 
				
			||||||
					   struct inode *inode,
 | 
										   struct inode *inode,
 | 
				
			||||||
					   loff_t pos, unsigned len,
 | 
										   loff_t pos, unsigned len,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -741,9 +741,8 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
 | 
					int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
 | 
				
			||||||
			       unsigned copied, struct page *page)
 | 
								       unsigned copied, struct folio *folio)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct folio *folio = page_folio(page);
 | 
					 | 
				
			||||||
	handle_t *handle = ext4_journal_current_handle();
 | 
						handle_t *handle = ext4_journal_current_handle();
 | 
				
			||||||
	int no_expand;
 | 
						int no_expand;
 | 
				
			||||||
	void *kaddr;
 | 
						void *kaddr;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1287,7 +1287,8 @@ static int ext4_write_end(struct file *file,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ext4_has_inline_data(inode) &&
 | 
						if (ext4_has_inline_data(inode) &&
 | 
				
			||||||
	    ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA))
 | 
						    ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA))
 | 
				
			||||||
		return ext4_write_inline_data_end(inode, pos, len, copied, page);
 | 
							return ext4_write_inline_data_end(inode, pos, len, copied,
 | 
				
			||||||
 | 
											  folio);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
 | 
						copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
| 
						 | 
					@ -1395,7 +1396,8 @@ static int ext4_journalled_write_end(struct file *file,
 | 
				
			||||||
	BUG_ON(!ext4_handle_valid(handle));
 | 
						BUG_ON(!ext4_handle_valid(handle));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ext4_has_inline_data(inode))
 | 
						if (ext4_has_inline_data(inode))
 | 
				
			||||||
		return ext4_write_inline_data_end(inode, pos, len, copied, page);
 | 
							return ext4_write_inline_data_end(inode, pos, len, copied,
 | 
				
			||||||
 | 
											  folio);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (unlikely(copied < len) && !folio_test_uptodate(folio)) {
 | 
						if (unlikely(copied < len) && !folio_test_uptodate(folio)) {
 | 
				
			||||||
		copied = 0;
 | 
							copied = 0;
 | 
				
			||||||
| 
						 | 
					@ -2942,15 +2944,15 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
 | 
				
			||||||
 * Check if we should update i_disksize
 | 
					 * Check if we should update i_disksize
 | 
				
			||||||
 * when write to the end of file but not require block allocation
 | 
					 * when write to the end of file but not require block allocation
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static int ext4_da_should_update_i_disksize(struct page *page,
 | 
					static int ext4_da_should_update_i_disksize(struct folio *folio,
 | 
				
			||||||
					    unsigned long offset)
 | 
										    unsigned long offset)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct buffer_head *bh;
 | 
						struct buffer_head *bh;
 | 
				
			||||||
	struct inode *inode = page->mapping->host;
 | 
						struct inode *inode = folio->mapping->host;
 | 
				
			||||||
	unsigned int idx;
 | 
						unsigned int idx;
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bh = page_buffers(page);
 | 
						bh = folio_buffers(folio);
 | 
				
			||||||
	idx = offset >> inode->i_blkbits;
 | 
						idx = offset >> inode->i_blkbits;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < idx; i++)
 | 
						for (i = 0; i < idx; i++)
 | 
				
			||||||
| 
						 | 
					@ -2970,17 +2972,19 @@ static int ext4_da_write_end(struct file *file,
 | 
				
			||||||
	loff_t new_i_size;
 | 
						loff_t new_i_size;
 | 
				
			||||||
	unsigned long start, end;
 | 
						unsigned long start, end;
 | 
				
			||||||
	int write_mode = (int)(unsigned long)fsdata;
 | 
						int write_mode = (int)(unsigned long)fsdata;
 | 
				
			||||||
 | 
						struct folio *folio = page_folio(page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (write_mode == FALL_BACK_TO_NONDELALLOC)
 | 
						if (write_mode == FALL_BACK_TO_NONDELALLOC)
 | 
				
			||||||
		return ext4_write_end(file, mapping, pos,
 | 
							return ext4_write_end(file, mapping, pos,
 | 
				
			||||||
				      len, copied, page, fsdata);
 | 
									      len, copied, &folio->page, fsdata);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	trace_ext4_da_write_end(inode, pos, len, copied);
 | 
						trace_ext4_da_write_end(inode, pos, len, copied);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (write_mode != CONVERT_INLINE_DATA &&
 | 
						if (write_mode != CONVERT_INLINE_DATA &&
 | 
				
			||||||
	    ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA) &&
 | 
						    ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA) &&
 | 
				
			||||||
	    ext4_has_inline_data(inode))
 | 
						    ext4_has_inline_data(inode))
 | 
				
			||||||
		return ext4_write_inline_data_end(inode, pos, len, copied, page);
 | 
							return ext4_write_inline_data_end(inode, pos, len, copied,
 | 
				
			||||||
 | 
											  folio);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (unlikely(copied < len) && !PageUptodate(page))
 | 
						if (unlikely(copied < len) && !PageUptodate(page))
 | 
				
			||||||
		copied = 0;
 | 
							copied = 0;
 | 
				
			||||||
| 
						 | 
					@ -3004,10 +3008,11 @@ static int ext4_da_write_end(struct file *file,
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	new_i_size = pos + copied;
 | 
						new_i_size = pos + copied;
 | 
				
			||||||
	if (copied && new_i_size > inode->i_size &&
 | 
						if (copied && new_i_size > inode->i_size &&
 | 
				
			||||||
	    ext4_da_should_update_i_disksize(page, end))
 | 
						    ext4_da_should_update_i_disksize(folio, end))
 | 
				
			||||||
		ext4_update_i_disksize(inode, new_i_size);
 | 
							ext4_update_i_disksize(inode, new_i_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return generic_write_end(file, mapping, pos, len, copied, page, fsdata);
 | 
						return generic_write_end(file, mapping, pos, len, copied, &folio->page,
 | 
				
			||||||
 | 
									 fsdata);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue