Message ID | 6b80c4787250be970ff8bb1c1f261492cafba7df.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: > If we error out cow'ing the root node when doing a replace_path then we > simply unlock and free the buffer and return the error. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Qu Wenruo <wqu@suse.com> One unrelated thing inlined below. > --- > 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 b872a64de8bb..52d6e7ab4265 100644 > --- a/fs/btrfs/relocation.c > +++ b/fs/btrfs/relocation.c > @@ -1222,7 +1222,11 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, > if (cow) { > ret = btrfs_cow_block(trans, dest, eb, NULL, 0, &eb, > BTRFS_NESTING_COW); Is it only me that such btrfs_cow_block() call using eb and source and again eb as dest looks pretty strange? Although I have seen a lot of callers in ctree.c doing the same thing, in fact, ALL btrfs_cow_block() calls uses the same eb for its source and dest. Either it means we can remove one parameter of btrfs_cow_block() or it's really confusing and we should avoid such use case. Anyway, it would be another patch. Thanks, Qu > - BUG_ON(ret); > + if (ret) { > + btrfs_tree_unlock(eb); > + free_extent_buffer(eb); > + return ret; > + } > } > > if (next_key) { >
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index b872a64de8bb..52d6e7ab4265 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1222,7 +1222,11 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, if (cow) { ret = btrfs_cow_block(trans, dest, eb, NULL, 0, &eb, BTRFS_NESTING_COW); - BUG_ON(ret); + if (ret) { + btrfs_tree_unlock(eb); + free_extent_buffer(eb); + return ret; + } } if (next_key) {
If we error out cow'ing the root node when doing a replace_path then we simply unlock and free the buffer and return the error. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/relocation.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)