mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	Btrfs: Optimise NFS readdir hack slightly; don't call readdir() again when done
Date: Sun, 17 Aug 2008 17:12:56 +0100 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
		
							parent
							
								
									49593bfa57
								
							
						
					
					
						commit
						f2322b1c65
					
				
					 1 changed files with 7 additions and 4 deletions
				
			
		| 
						 | 
					@ -2040,6 +2040,7 @@ struct nfshack_dirent {
 | 
				
			||||||
struct nfshack_readdir {
 | 
					struct nfshack_readdir {
 | 
				
			||||||
	char		*dirent;
 | 
						char		*dirent;
 | 
				
			||||||
	size_t		used;
 | 
						size_t		used;
 | 
				
			||||||
 | 
						int		full;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2052,8 +2053,10 @@ static int btrfs_nfshack_filldir(void *__buf, const char *name, int namlen,
 | 
				
			||||||
	unsigned int reclen;
 | 
						unsigned int reclen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	reclen = ALIGN(sizeof(struct nfshack_dirent) + namlen, sizeof(u64));
 | 
						reclen = ALIGN(sizeof(struct nfshack_dirent) + namlen, sizeof(u64));
 | 
				
			||||||
	if (buf->used + reclen > PAGE_SIZE)
 | 
						if (buf->used + reclen > PAGE_SIZE) {
 | 
				
			||||||
 | 
							buf->full = 1;
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	de->namlen = namlen;
 | 
						de->namlen = namlen;
 | 
				
			||||||
	de->offset = offset;
 | 
						de->offset = offset;
 | 
				
			||||||
| 
						 | 
					@ -2080,11 +2083,11 @@ static int btrfs_nfshack_readdir(struct file *file, void *dirent,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	offset = file->f_pos;
 | 
						offset = file->f_pos;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (1) {
 | 
						do {
 | 
				
			||||||
		unsigned int reclen;
 | 
							unsigned int reclen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		buf.used = 0;
 | 
							buf.used = 0;
 | 
				
			||||||
 | 
							buf.full = 0;
 | 
				
			||||||
		err = btrfs_real_readdir(file, &buf, btrfs_nfshack_filldir);
 | 
							err = btrfs_real_readdir(file, &buf, btrfs_nfshack_filldir);
 | 
				
			||||||
		if (err)
 | 
							if (err)
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
| 
						 | 
					@ -2108,7 +2111,7 @@ static int btrfs_nfshack_readdir(struct file *file, void *dirent,
 | 
				
			||||||
			size -= reclen;
 | 
								size -= reclen;
 | 
				
			||||||
			de = (struct nfshack_dirent *)((char *)de + reclen);
 | 
								de = (struct nfshack_dirent *)((char *)de + reclen);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						} while (buf.full);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 done:
 | 
					 done:
 | 
				
			||||||
	free_page((unsigned long)buf.dirent);
 | 
						free_page((unsigned long)buf.dirent);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue