Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1716431
| From | Jeff Mahoney <jeffm@suse.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/5] btrfs: Use common error handling code in __btrfs_free_extent() |
| Date | 2017-08-21 15:10 +0200 |
| Message-ID | <ugUCT-4Nm-45@gated-at.bofh.it> (permalink) |
| References | <ugU9P-4ml-11@gated-at.bofh.it> <ugU9Q-4ml-27@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
On 8/21/17 8:38 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 21 Aug 2017 10:03:00 +0200
>
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
>
> This issue was detected by using the Coccinelle software.
btrfs_abort_transaction dumps __FILE__:__LINE__ in the log so this patch
makes the code more difficult to debug.
-Jeff
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> fs/btrfs/extent-tree.c | 69 ++++++++++++++++++++------------------------------
> 1 file changed, 27 insertions(+), 42 deletions(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 116c5615d6c2..c6b7aca88491 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -6913,10 +6913,9 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
> ret = remove_extent_backref(trans, info, path, NULL,
> refs_to_drop,
> is_data, &last_ref);
> - if (ret) {
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> - }
> + if (ret)
> + goto abort_transaction;
> +
> btrfs_release_path(path);
> path->leave_spinning = 1;
>
> @@ -6962,10 +6961,9 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
> if (ret > 0)
> btrfs_print_leaf(path->nodes[0]);
> }
> - if (ret < 0) {
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> - }
> + if (ret < 0)
> + goto abort_transaction;
> +
> extent_slot = path->slots[0];
> }
> } else if (WARN_ON(ret == -ENOENT)) {
> @@ -6974,11 +6972,9 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
> "unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu",
> bytenr, parent, root_objectid, owner_objectid,
> owner_offset);
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> + goto abort_transaction;
> } else {
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> + goto abort_transaction;
> }
>
> leaf = path->nodes[0];
> @@ -6988,10 +6984,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
> BUG_ON(found_extent || extent_slot != path->slots[0]);
> ret = convert_extent_item_v0(trans, info, path, owner_objectid,
> 0);
> - if (ret < 0) {
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> - }
> + if (ret < 0)
> + goto abort_transaction;
>
> btrfs_release_path(path);
> path->leave_spinning = 1;
> @@ -7008,10 +7002,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
> ret, bytenr);
> btrfs_print_leaf(path->nodes[0]);
> }
> - if (ret < 0) {
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> - }
> + if (ret < 0)
> + goto abort_transaction;
>
> extent_slot = path->slots[0];
> leaf = path->nodes[0];
> @@ -7035,8 +7027,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
> "trying to drop %d refs but we only have %Lu for bytenr %Lu",
> refs_to_drop, refs, bytenr);
> ret = -EINVAL;
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> + goto abort_transaction;
> }
> refs -= refs_to_drop;
>
> @@ -7057,10 +7048,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
> ret = remove_extent_backref(trans, info, path,
> iref, refs_to_drop,
> is_data, &last_ref);
> - if (ret) {
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> - }
> + if (ret)
> + goto abort_transaction;
> }
> } else {
> if (found_extent) {
> @@ -7078,37 +7067,33 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
> last_ref = 1;
> ret = btrfs_del_items(trans, extent_root, path, path->slots[0],
> num_to_del);
> - if (ret) {
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> - }
> + if (ret)
> + goto abort_transaction;
> +
> btrfs_release_path(path);
>
> if (is_data) {
> ret = btrfs_del_csums(trans, info, bytenr, num_bytes);
> - if (ret) {
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> - }
> + if (ret)
> + goto abort_transaction;
> }
>
> ret = add_to_free_space_tree(trans, info, bytenr, num_bytes);
> - if (ret) {
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> - }
> + if (ret)
> + goto abort_transaction;
>
> ret = update_block_group(trans, info, bytenr, num_bytes, 0);
> - if (ret) {
> - btrfs_abort_transaction(trans, ret);
> - goto out;
> - }
> + if (ret)
> + goto abort_transaction;
> }
> btrfs_release_path(path);
>
> out:
> btrfs_free_path(path);
> return ret;
> +abort_transaction:
> + btrfs_abort_transaction(trans, ret);
> + goto out;
> }
>
> /*
>
--
Jeff Mahoney
SUSE Labs
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/5] BTRFS: Fine-tuning for five function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 14:40 +0200
[PATCH 2/5] btrfs: Use common error handling code in __btrfs_free_extent() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 14:40 +0200
Re: [PATCH 2/5] btrfs: Use common error handling code in __btrfs_free_extent() Jeff Mahoney <jeffm@suse.com> - 2017-08-21 15:10 +0200
Re: [PATCH 2/5] btrfs: Use common error handling code in __btrfs_free_extent() Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-21 15:20 +0200
[PATCH 4/5] btrfs: Use common error handling code in update_ref_path() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 14:50 +0200
Re: [PATCH 4/5] btrfs: Use common error handling code in update_ref_path() Jeff Mahoney <jeffm@suse.com> - 2017-08-21 15:10 +0200
Re: [PATCH 4/5] btrfs: Use common error handling code in update_ref_path() Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-21 15:50 +0200
[PATCH v2] btrfs: Use common error handling code in update_ref_path() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 16:00 +0200
[PATCH 5/5] btrfs: Use common error handling code in btrfs_mark_extent_written() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 14:50 +0200
Re: [PATCH 5/5] btrfs: Use common error handling code in btrfs_mark_extent_written() Jeff Mahoney <jeffm@suse.com> - 2017-08-21 15:10 +0200
[PATCH 3/5] btrfs: Use common error handling code in btrfs_update_root() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-21 14:50 +0200
Re: [PATCH 3/5] btrfs: Use common error handling code in btrfs_update_root() Jeff Mahoney <jeffm@suse.com> - 2017-08-21 15:10 +0200
Re: [PATCH 0/5] BTRFS: Fine-tuning for five function implementations David Sterba <dsterba@suse.cz> - 2017-08-21 15:30 +0200
csiph-web