mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	9p: saner ->write_end() on failing copy into non-uptodate page
If we had a short copy into an uptodate page, there's no reason whatsoever to zero anything; OTOH, if that page had _not_ been uptodate, we must have been trying to overwrite it completely and got a short copy. In that case, overwriting the end with zeroes, marking uptodate and sending to server is just plain wrong. Just unlock, keep it non-uptodate and return 0. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
		
							parent
							
								
									43388b21e7
								
							
						
					
					
						commit
						77469c3f57
					
				
					 1 changed files with 4 additions and 11 deletions
				
			
		| 
						 | 
					@ -309,18 +309,10 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
 | 
						p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (unlikely(copied < len)) {
 | 
						if (unlikely(copied < len && !PageUptodate(page))) {
 | 
				
			||||||
		/*
 | 
							copied = 0;
 | 
				
			||||||
		 * zero out the rest of the area
 | 
							goto out;
 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		unsigned from = pos & (PAGE_SIZE - 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		zero_user(page, from + copied, len - copied);
 | 
					 | 
				
			||||||
		flush_dcache_page(page);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!PageUptodate(page))
 | 
					 | 
				
			||||||
		SetPageUptodate(page);
 | 
					 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * No need to use i_size_read() here, the i_size
 | 
						 * No need to use i_size_read() here, the i_size
 | 
				
			||||||
	 * cannot change under us because we hold the i_mutex.
 | 
						 * cannot change under us because we hold the i_mutex.
 | 
				
			||||||
| 
						 | 
					@ -330,6 +322,7 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
 | 
				
			||||||
		i_size_write(inode, last_pos);
 | 
							i_size_write(inode, last_pos);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	set_page_dirty(page);
 | 
						set_page_dirty(page);
 | 
				
			||||||
 | 
					out:
 | 
				
			||||||
	unlock_page(page);
 | 
						unlock_page(page);
 | 
				
			||||||
	put_page(page);
 | 
						put_page(page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue