diff options
Diffstat (limited to 'fs/btrfs/tree-log.c')
| -rw-r--r-- | fs/btrfs/tree-log.c | 24 | 
1 files changed, 16 insertions, 8 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 92a368627791..f67721d82e5d 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3165,20 +3165,22 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,  	 */  	mutex_unlock(&root->log_mutex); -	btrfs_init_log_ctx(&root_log_ctx, NULL); - -	mutex_lock(&log_root_tree->log_mutex); -  	if (btrfs_is_zoned(fs_info)) { +		mutex_lock(&fs_info->tree_root->log_mutex);  		if (!log_root_tree->node) {  			ret = btrfs_alloc_log_tree_node(trans, log_root_tree);  			if (ret) { -				mutex_unlock(&log_root_tree->log_mutex); +				mutex_unlock(&fs_info->tree_log_mutex);  				goto out;  			}  		} +		mutex_unlock(&fs_info->tree_root->log_mutex);  	} +	btrfs_init_log_ctx(&root_log_ctx, NULL); + +	mutex_lock(&log_root_tree->log_mutex); +  	index2 = log_root_tree->log_transid % 2;  	list_add_tail(&root_log_ctx.list, &log_root_tree->log_ctxs[index2]);  	root_log_ctx.log_transid = log_root_tree->log_transid; @@ -4136,7 +4138,8 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,  	return ret;  } -static int extent_cmp(void *priv, struct list_head *a, struct list_head *b) +static int extent_cmp(void *priv, const struct list_head *a, +		      const struct list_head *b)  {  	struct extent_map *em1, *em2; @@ -6278,8 +6281,13 @@ again:  		}  		wc.replay_dest->log_root = log; -		btrfs_record_root_in_trans(trans, wc.replay_dest); -		ret = walk_log_tree(trans, log, &wc); +		ret = btrfs_record_root_in_trans(trans, wc.replay_dest); +		if (ret) +			/* The loop needs to continue due to the root refs */ +			btrfs_handle_fs_error(fs_info, ret, +				"failed to record the log root in transaction"); +		else +			ret = walk_log_tree(trans, log, &wc);  		if (!ret && wc.stage == LOG_WALK_REPLAY_ALL) {  			ret = fixup_inode_link_counts(trans, wc.replay_dest,  |