diff options
Diffstat (limited to 'fs/btrfs/tree-log.c')
| -rw-r--r-- | fs/btrfs/tree-log.c | 36 | 
1 files changed, 14 insertions, 22 deletions
| diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index ef9c55bc7907..3d33c4e41e5f 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2713,14 +2713,12 @@ static inline void btrfs_remove_all_log_ctxs(struct btrfs_root *root,  					     int index, int error)  {  	struct btrfs_log_ctx *ctx; +	struct btrfs_log_ctx *safe; -	if (!error) { -		INIT_LIST_HEAD(&root->log_ctxs[index]); -		return; -	} - -	list_for_each_entry(ctx, &root->log_ctxs[index], list) +	list_for_each_entry_safe(ctx, safe, &root->log_ctxs[index], list) { +		list_del_init(&ctx->list);  		ctx->log_ret = error; +	}  	INIT_LIST_HEAD(&root->log_ctxs[index]);  } @@ -2961,13 +2959,9 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,  	mutex_unlock(&root->log_mutex);  out_wake_log_root: -	/* -	 * We needn't get log_mutex here because we are sure all -	 * the other tasks are blocked. -	 */ +	mutex_lock(&log_root_tree->log_mutex);  	btrfs_remove_all_log_ctxs(log_root_tree, index2, ret); -	mutex_lock(&log_root_tree->log_mutex);  	log_root_tree->log_transid_committed++;  	atomic_set(&log_root_tree->log_commit[index2], 0);  	mutex_unlock(&log_root_tree->log_mutex); @@ -2978,10 +2972,8 @@ out_wake_log_root:  	if (waitqueue_active(&log_root_tree->log_commit_wait[index2]))  		wake_up(&log_root_tree->log_commit_wait[index2]);  out: -	/* See above. */ -	btrfs_remove_all_log_ctxs(root, index1, ret); -  	mutex_lock(&root->log_mutex); +	btrfs_remove_all_log_ctxs(root, index1, ret);  	root->log_transid_committed++;  	atomic_set(&root->log_commit[index1], 0);  	mutex_unlock(&root->log_mutex); @@ -3961,7 +3953,7 @@ static int wait_ordered_extents(struct btrfs_trans_handle *trans,  			 * i_mapping flags, so that the next fsync won't get  			 * an outdated io error too.  			 */ -			btrfs_inode_check_errors(inode); +			filemap_check_errors(inode->i_mapping);  			*ordered_io_error = true;  			break;  		} @@ -4198,7 +4190,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,  	 * without writing to the log tree and the fsync must report the  	 * file data write error and not commit the current transaction.  	 */ -	ret = btrfs_inode_check_errors(inode); +	ret = filemap_check_errors(inode->i_mapping);  	if (ret)  		ctx->io_err = ret;  process: @@ -5579,7 +5571,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)  	if (!path)  		return -ENOMEM; -	fs_info->log_root_recovering = 1; +	set_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags);  	trans = btrfs_start_transaction(fs_info->tree_root, 0);  	if (IS_ERR(trans)) { @@ -5592,8 +5584,8 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)  	ret = walk_log_tree(trans, log_root_tree, &wc);  	if (ret) { -		btrfs_handle_fs_error(fs_info, ret, "Failed to pin buffers while " -			    "recovering log root tree."); +		btrfs_handle_fs_error(fs_info, ret, +			"Failed to pin buffers while recovering log root tree.");  		goto error;  	} @@ -5639,8 +5631,8 @@ again:  			free_extent_buffer(log->node);  			free_extent_buffer(log->commit_root);  			kfree(log); -			btrfs_handle_fs_error(fs_info, ret, "Couldn't read target root " -				    "for tree log recovery."); +			btrfs_handle_fs_error(fs_info, ret, +				"Couldn't read target root for tree log recovery.");  			goto error;  		} @@ -5689,7 +5681,7 @@ again:  	free_extent_buffer(log_root_tree->node);  	log_root_tree->log_root = NULL; -	fs_info->log_root_recovering = 0; +	clear_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags);  	kfree(log_root_tree);  	return 0; |