diff options
Diffstat (limited to 'fs/btrfs/tree-log.c')
| -rw-r--r-- | fs/btrfs/tree-log.c | 17 | 
1 files changed, 13 insertions, 4 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 9e1f2cd5e67a..7e0e6e3029dd 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3298,7 +3298,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,  	struct list_head ordered_sums;  	int skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;  	bool has_extents = false; -	bool need_find_last_extent = (*last_extent == 0); +	bool need_find_last_extent = true;  	bool done = false;  	INIT_LIST_HEAD(&ordered_sums); @@ -3352,8 +3352,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,  		 */  		if (ins_keys[i].type == BTRFS_EXTENT_DATA_KEY) {  			has_extents = true; -			if (need_find_last_extent && -			    first_key.objectid == (u64)-1) +			if (first_key.objectid == (u64)-1)  				first_key = ins_keys[i];  		} else {  			need_find_last_extent = false; @@ -3427,6 +3426,16 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,  	if (!has_extents)  		return ret; +	if (need_find_last_extent && *last_extent == first_key.offset) { +		/* +		 * We don't have any leafs between our current one and the one +		 * we processed before that can have file extent items for our +		 * inode (and have a generation number smaller than our current +		 * transaction id). +		 */ +		need_find_last_extent = false; +	} +  	/*  	 * Because we use btrfs_search_forward we could skip leaves that were  	 * not modified and then assume *last_extent is valid when it really @@ -3537,7 +3546,7 @@ fill_holes:  					       0, 0);  		if (ret)  			break; -		*last_extent = offset + len; +		*last_extent = extent_end;  	}  	/*  	 * Need to let the callers know we dropped the path so they should  | 
