Message ID | ccb1551a8d087aa2d6ac7cf9100a0034172a645a.1606938211.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Cleanup error handling in relocation | expand |
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 --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);
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(-)