mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	btrfs: fix comment about nbytes increase at replay_one_extent()
The comment is wrong about the part where it says a prealloc extent does not contribute to an inode's nbytes - it does. Only holes don't contribute and that's what we are checking for, as prealloc extents always have a disk_bytenr different from 0. So fix the comment and re-organize the code to not set nbytes twice and set it to the extent item's number of bytes only if it doesn't represent a hole - in case it's a hole we have already initialized nbytes to 0 when we declared it. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
		
							parent
							
								
									2d83ed6c6c
								
							
						
					
					
						commit
						a35b3dd59b
					
				
					 1 changed files with 4 additions and 9 deletions
				
			
		| 
						 | 
					@ -740,15 +740,10 @@ static noinline int replay_one_extent(struct walk_control *wc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (found_type == BTRFS_FILE_EXTENT_REG ||
 | 
						if (found_type == BTRFS_FILE_EXTENT_REG ||
 | 
				
			||||||
	    found_type == BTRFS_FILE_EXTENT_PREALLOC) {
 | 
						    found_type == BTRFS_FILE_EXTENT_PREALLOC) {
 | 
				
			||||||
 | 
							extent_end = start + btrfs_file_extent_num_bytes(wc->log_leaf, item);
 | 
				
			||||||
 | 
							/* Holes don't take up space. */
 | 
				
			||||||
 | 
							if (btrfs_file_extent_disk_bytenr(wc->log_leaf, item) != 0)
 | 
				
			||||||
			nbytes = btrfs_file_extent_num_bytes(wc->log_leaf, item);
 | 
								nbytes = btrfs_file_extent_num_bytes(wc->log_leaf, item);
 | 
				
			||||||
		extent_end = start + nbytes;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/*
 | 
					 | 
				
			||||||
		 * We don't add to the inodes nbytes if we are prealloc or a
 | 
					 | 
				
			||||||
		 * hole.
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		if (btrfs_file_extent_disk_bytenr(wc->log_leaf, item) == 0)
 | 
					 | 
				
			||||||
			nbytes = 0;
 | 
					 | 
				
			||||||
	} else if (found_type == BTRFS_FILE_EXTENT_INLINE) {
 | 
						} else if (found_type == BTRFS_FILE_EXTENT_INLINE) {
 | 
				
			||||||
		size = btrfs_file_extent_ram_bytes(wc->log_leaf, item);
 | 
							size = btrfs_file_extent_ram_bytes(wc->log_leaf, item);
 | 
				
			||||||
		nbytes = btrfs_file_extent_ram_bytes(wc->log_leaf, item);
 | 
							nbytes = btrfs_file_extent_ram_bytes(wc->log_leaf, item);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue