mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	nfs: nfs_file_write() should check for writeback errors
The NFS_CONTEXT_ERROR_WRITE flag (as well as the check of said flag) was removed by commit6fbda89b25. The absence of an error check allows writes to be continually queued up for a server that may no longer be able to handle them. Fix it by adding an error check using the generic error reporting functions. Fixes:6fbda89b25("NFS: Replace custom error reporting mechanism with generic one") Signed-off-by: Scott Mayhew <smayhew@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
		
							parent
							
								
									67dd23f9e6
								
							
						
					
					
						commit
						ce368536dd
					
				
					 1 changed files with 9 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -591,12 +591,14 @@ static const struct vm_operations_struct nfs_file_vm_ops = {
 | 
			
		|||
	.page_mkwrite = nfs_vm_page_mkwrite,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int nfs_need_check_write(struct file *filp, struct inode *inode)
 | 
			
		||||
static int nfs_need_check_write(struct file *filp, struct inode *inode,
 | 
			
		||||
				int error)
 | 
			
		||||
{
 | 
			
		||||
	struct nfs_open_context *ctx;
 | 
			
		||||
 | 
			
		||||
	ctx = nfs_file_open_context(filp);
 | 
			
		||||
	if (nfs_ctx_key_to_expire(ctx, inode))
 | 
			
		||||
	if (nfs_error_is_fatal_on_server(error) ||
 | 
			
		||||
	    nfs_ctx_key_to_expire(ctx, inode))
 | 
			
		||||
		return 1;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -607,6 +609,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 | 
			
		|||
	struct inode *inode = file_inode(file);
 | 
			
		||||
	unsigned long written = 0;
 | 
			
		||||
	ssize_t result;
 | 
			
		||||
	errseq_t since;
 | 
			
		||||
	int error;
 | 
			
		||||
 | 
			
		||||
	result = nfs_key_timeout_notify(file, inode);
 | 
			
		||||
	if (result)
 | 
			
		||||
| 
						 | 
				
			
			@ -631,6 +635,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 | 
			
		|||
	if (iocb->ki_pos > i_size_read(inode))
 | 
			
		||||
		nfs_revalidate_mapping(inode, file->f_mapping);
 | 
			
		||||
 | 
			
		||||
	since = filemap_sample_wb_err(file->f_mapping);
 | 
			
		||||
	nfs_start_io_write(inode);
 | 
			
		||||
	result = generic_write_checks(iocb, from);
 | 
			
		||||
	if (result > 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -649,7 +654,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 | 
			
		|||
		goto out;
 | 
			
		||||
 | 
			
		||||
	/* Return error values */
 | 
			
		||||
	if (nfs_need_check_write(file, inode)) {
 | 
			
		||||
	error = filemap_check_wb_err(file->f_mapping, since);
 | 
			
		||||
	if (nfs_need_check_write(file, inode, error)) {
 | 
			
		||||
		int err = nfs_wb_all(inode);
 | 
			
		||||
		if (err < 0)
 | 
			
		||||
			result = err;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue