mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	udf: convert to new aops
Convert udf to new aops. Also seem to have fixed pagecache corruption in udf_adinicb_commit_write -- page was marked uptodate when it is not. Also, fixed the silly setup where prepare_write was doing a kmap to be used in commit_write: just do kmap_atomic in write_end. Use libfs helpers to make this easier. Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: <bfennema@falcon.csc.calpoly.edu> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									82b9d1d0da
								
							
						
					
					
						commit
						be021ee41a
					
				
					 2 changed files with 22 additions and 26 deletions
				
			
		| 
						 | 
					@ -76,36 +76,29 @@ static int udf_adinicb_writepage(struct page *page, struct writeback_control *wb
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int udf_adinicb_prepare_write(struct file *file, struct page *page,
 | 
					static int udf_adinicb_write_end(struct file *file,
 | 
				
			||||||
				     unsigned offset, unsigned to)
 | 
								struct address_space *mapping,
 | 
				
			||||||
 | 
								loff_t pos, unsigned len, unsigned copied,
 | 
				
			||||||
 | 
								struct page *page, void *fsdata)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	kmap(page);
 | 
						struct inode *inode = mapping->host;
 | 
				
			||||||
	return 0;
 | 
						unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
 | 
				
			||||||
}
 | 
						char *kaddr;
 | 
				
			||||||
 | 
					 | 
				
			||||||
static int udf_adinicb_commit_write(struct file *file, struct page *page,
 | 
					 | 
				
			||||||
				    unsigned offset, unsigned to)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct inode *inode = page->mapping->host;
 | 
					 | 
				
			||||||
	char *kaddr = page_address(page);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						kaddr = kmap_atomic(page, KM_USER0);
 | 
				
			||||||
	memcpy(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + offset,
 | 
						memcpy(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + offset,
 | 
				
			||||||
	       kaddr + offset, to - offset);
 | 
							kaddr + offset, copied);
 | 
				
			||||||
	mark_inode_dirty(inode);
 | 
						kunmap_atomic(kaddr, KM_USER0);
 | 
				
			||||||
	SetPageUptodate(page);
 | 
					
 | 
				
			||||||
	kunmap(page);
 | 
						return simple_write_end(file, mapping, pos, len, copied, page, fsdata);
 | 
				
			||||||
	/* only one page here */
 | 
					 | 
				
			||||||
	if (to > inode->i_size)
 | 
					 | 
				
			||||||
		inode->i_size = to;
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct address_space_operations udf_adinicb_aops = {
 | 
					const struct address_space_operations udf_adinicb_aops = {
 | 
				
			||||||
	.readpage	= udf_adinicb_readpage,
 | 
						.readpage	= udf_adinicb_readpage,
 | 
				
			||||||
	.writepage	= udf_adinicb_writepage,
 | 
						.writepage	= udf_adinicb_writepage,
 | 
				
			||||||
	.sync_page	= block_sync_page,
 | 
						.sync_page	= block_sync_page,
 | 
				
			||||||
	.prepare_write	= udf_adinicb_prepare_write,
 | 
						.write_begin = simple_write_begin,
 | 
				
			||||||
	.commit_write	= udf_adinicb_commit_write,
 | 
						.write_end = udf_adinicb_write_end,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 | 
					static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -133,10 +133,13 @@ static int udf_readpage(struct file *file, struct page *page)
 | 
				
			||||||
	return block_read_full_page(page, udf_get_block);
 | 
						return block_read_full_page(page, udf_get_block);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int udf_prepare_write(struct file *file, struct page *page,
 | 
					static int udf_write_begin(struct file *file, struct address_space *mapping,
 | 
				
			||||||
			     unsigned from, unsigned to)
 | 
								loff_t pos, unsigned len, unsigned flags,
 | 
				
			||||||
 | 
								struct page **pagep, void **fsdata)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return block_prepare_write(page, from, to, udf_get_block);
 | 
						*pagep = NULL;
 | 
				
			||||||
 | 
						return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
 | 
				
			||||||
 | 
									udf_get_block);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static sector_t udf_bmap(struct address_space *mapping, sector_t block)
 | 
					static sector_t udf_bmap(struct address_space *mapping, sector_t block)
 | 
				
			||||||
| 
						 | 
					@ -148,8 +151,8 @@ const struct address_space_operations udf_aops = {
 | 
				
			||||||
	.readpage	= udf_readpage,
 | 
						.readpage	= udf_readpage,
 | 
				
			||||||
	.writepage	= udf_writepage,
 | 
						.writepage	= udf_writepage,
 | 
				
			||||||
	.sync_page	= block_sync_page,
 | 
						.sync_page	= block_sync_page,
 | 
				
			||||||
	.prepare_write	= udf_prepare_write,
 | 
						.write_begin		= udf_write_begin,
 | 
				
			||||||
	.commit_write	= generic_commit_write,
 | 
						.write_end		= generic_write_end,
 | 
				
			||||||
	.bmap		= udf_bmap,
 | 
						.bmap		= udf_bmap,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue