diff mbox series

[v3,38/54] btrfs: handle the loop btrfs_cow_block error in replace_path

Message ID ccb1551a8d087aa2d6ac7cf9100a0034172a645a.1606938211.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Cleanup error handling in relocation | expand

Commit Message

Josef Bacik Dec. 2, 2020, 7:50 p.m. UTC
As we loop through the path to replace it, we will have to cow each node
we hit on the path down to the lowest_level.  If this fails we simply
unlock and free the block and break from the loop.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/relocation.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Qu Wenruo Dec. 3, 2020, 5:11 a.m. UTC | #1
On 2020/12/3 上午3:50, Josef Bacik wrote:
> As we loop through the path to replace it, we will have to cow each node
> we hit on the path down to the lowest_level.  If this fails we simply
> unlock and free the block and break from the loop.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

There are two btrfs_cow_block() calls in replace_path().
It would be better to handle them in the same patch.

Thanks,
Qu
> ---
>  fs/btrfs/relocation.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 52d6e7ab4265..781908f3a3af 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -1286,7 +1286,11 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
>  				ret = btrfs_cow_block(trans, dest, eb, parent,
>  						      slot, &eb,
>  						      BTRFS_NESTING_COW);
> -				BUG_ON(ret);
> +				if (ret) {
> +					btrfs_tree_unlock(eb);
> +					free_extent_buffer(eb);
> +					break;
> +				}
>  			}
>  
>  			btrfs_tree_unlock(parent);
>
diff mbox series

Patch

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 52d6e7ab4265..781908f3a3af 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1286,7 +1286,11 @@  int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
 				ret = btrfs_cow_block(trans, dest, eb, parent,
 						      slot, &eb,
 						      BTRFS_NESTING_COW);
-				BUG_ON(ret);
+				if (ret) {
+					btrfs_tree_unlock(eb);
+					free_extent_buffer(eb);
+					break;
+				}
 			}
 
 			btrfs_tree_unlock(parent);