forked from mirrors/linux
		
	ext4: use ext4_write_inode() when fsyncing w/o a journal
In no-journal mode, we previously used __generic_file_fsync() in no-journal mode. This triggers a lockdep warning, and in addition, it's not safe to depend on the inode writeback mechanism in the case ext4. We can solve both problems by calling ext4_write_inode() directly. Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
This commit is contained in:
		
							parent
							
								
									e86807862e
								
							
						
					
					
						commit
						ad211f3e94
					
				
					 1 changed files with 9 additions and 4 deletions
				
			
		|  | @ -116,8 +116,16 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) | ||||||
| 		goto out; | 		goto out; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	ret = file_write_and_wait_range(file, start, end); | ||||||
|  | 	if (ret) | ||||||
|  | 		return ret; | ||||||
|  | 
 | ||||||
| 	if (!journal) { | 	if (!journal) { | ||||||
| 		ret = __generic_file_fsync(file, start, end, datasync); | 		struct writeback_control wbc = { | ||||||
|  | 			.sync_mode = WB_SYNC_ALL | ||||||
|  | 		}; | ||||||
|  | 
 | ||||||
|  | 		ret = ext4_write_inode(inode, &wbc); | ||||||
| 		if (!ret) | 		if (!ret) | ||||||
| 			ret = ext4_sync_parent(inode); | 			ret = ext4_sync_parent(inode); | ||||||
| 		if (test_opt(inode->i_sb, BARRIER)) | 		if (test_opt(inode->i_sb, BARRIER)) | ||||||
|  | @ -125,9 +133,6 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) | ||||||
| 		goto out; | 		goto out; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	ret = file_write_and_wait_range(file, start, end); |  | ||||||
| 	if (ret) |  | ||||||
| 		return ret; |  | ||||||
| 	/*
 | 	/*
 | ||||||
| 	 * data=writeback,ordered: | 	 * data=writeback,ordered: | ||||||
| 	 *  The caller's filemap_fdatawrite()/wait will sync the data. | 	 *  The caller's filemap_fdatawrite()/wait will sync the data. | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Theodore Ts'o
						Theodore Ts'o