mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	afs: Don't invoke the server to read data beyond EOF
When writing a new page, clear space in the page rather than attempting to load it from the server if the space is beyond the EOF. Signed-off-by: David Howells <dhowells@redhat.com>
This commit is contained in:
		
							parent
							
								
									f51375cd9e
								
							
						
					
					
						commit
						2a0b4f64c9
					
				
					 1 changed files with 11 additions and 0 deletions
				
			
		| 
						 | 
					@ -33,10 +33,21 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
 | 
				
			||||||
			 loff_t pos, unsigned int len, struct page *page)
 | 
								 loff_t pos, unsigned int len, struct page *page)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct afs_read *req;
 | 
						struct afs_read *req;
 | 
				
			||||||
 | 
						size_t p;
 | 
				
			||||||
 | 
						void *data;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_enter(",,%llu", (unsigned long long)pos);
 | 
						_enter(",,%llu", (unsigned long long)pos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (pos >= vnode->vfs_inode.i_size) {
 | 
				
			||||||
 | 
							p = pos & ~PAGE_MASK;
 | 
				
			||||||
 | 
							ASSERTCMP(p + len, <=, PAGE_SIZE);
 | 
				
			||||||
 | 
							data = kmap(page);
 | 
				
			||||||
 | 
							memset(data + p, 0, len);
 | 
				
			||||||
 | 
							kunmap(page);
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *),
 | 
						req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *),
 | 
				
			||||||
		      GFP_KERNEL);
 | 
							      GFP_KERNEL);
 | 
				
			||||||
	if (!req)
 | 
						if (!req)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue