linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Mahoney <jeffm@suse.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>,
	linux-btrfs@vger.kernel.org, Chris Mason <clm@fb.com>,
	David Sterba <dsterba@suse.com>, Josef Bacik <jbacik@fb.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 3/5] btrfs: Use common error handling code in btrfs_update_root()
Date: Mon, 21 Aug 2017 09:09:12 -0400	[thread overview]
Message-ID: <d33b6aa8-422b-507e-b004-923a25d235c9@suse.com> (raw)
In-Reply-To: <287b99e6-6562-ea64-e763-6a6808fee12a@users.sourceforge.net>


[-- Attachment #1.1: Type: text/plain, Size: 2441 bytes --]

On 8/21/17 8:40 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 21 Aug 2017 13:10:15 +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/root-tree.c | 27 +++++++++++----------------
>  1 file changed, 11 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
> index 5b488af6f25e..bc497ba9d9d1 100644
> --- a/fs/btrfs/root-tree.c
> +++ b/fs/btrfs/root-tree.c
> @@ -145,10 +145,8 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
>  		return -ENOMEM;
>  
>  	ret = btrfs_search_slot(trans, root, key, path, 0, 1);
> -	if (ret < 0) {
> -		btrfs_abort_transaction(trans, ret);
> -		goto out;
> -	}
> +	if (ret < 0)
> +		goto abort_transaction;
>  
>  	if (ret != 0) {
>  		btrfs_print_leaf(path->nodes[0]);
> @@ -171,23 +169,17 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
>  		btrfs_release_path(path);
>  		ret = btrfs_search_slot(trans, root, key, path,
>  				-1, 1);
> -		if (ret < 0) {
> -			btrfs_abort_transaction(trans, ret);
> -			goto out;
> -		}
> +		if (ret < 0)
> +			goto abort_transaction;
>  
>  		ret = btrfs_del_item(trans, root, path);
> -		if (ret < 0) {
> -			btrfs_abort_transaction(trans, ret);
> -			goto out;
> -		}
> +		if (ret < 0)
> +			goto abort_transaction;
>  		btrfs_release_path(path);
>  		ret = btrfs_insert_empty_item(trans, root, path,
>  				key, sizeof(*item));
> -		if (ret < 0) {
> -			btrfs_abort_transaction(trans, ret);
> -			goto out;
> -		}
> +		if (ret < 0)
> +			goto abort_transaction;
>  		l = path->nodes[0];
>  		slot = path->slots[0];
>  		ptr = btrfs_item_ptr_offset(l, slot);
> @@ -204,6 +196,9 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
>  out:
>  	btrfs_free_path(path);
>  	return ret;
> +abort_transaction:
> +	btrfs_abort_transaction(trans, ret);
> +	goto out;
>  }
>  
>  int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
> 


-- 
Jeff Mahoney
SUSE Labs


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2017-08-21 13:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21 12:35 [PATCH 0/5] BTRFS: Fine-tuning for five function implementations SF Markus Elfring
2017-08-21 12:37 ` [PATCH 1/5] btrfs: Use common error handling code in tree_mod_log_eb_copy() SF Markus Elfring
2017-08-21 12:38 ` [PATCH 2/5] btrfs: Use common error handling code in __btrfs_free_extent() SF Markus Elfring
2017-08-21 13:07   ` Jeff Mahoney
2017-08-21 13:14     ` Dan Carpenter
2017-08-21 12:40 ` [PATCH 3/5] btrfs: Use common error handling code in btrfs_update_root() SF Markus Elfring
2017-08-21 13:09   ` Jeff Mahoney [this message]
2017-08-21 12:41 ` [PATCH 4/5] btrfs: Use common error handling code in update_ref_path() SF Markus Elfring
2017-08-21 13:08   ` Jeff Mahoney
2017-08-21 13:42     ` Dan Carpenter
2017-08-21 13:52       ` [PATCH v2] " SF Markus Elfring
2017-08-21 12:42 ` [PATCH 5/5] btrfs: Use common error handling code in btrfs_mark_extent_written() SF Markus Elfring
2017-08-21 13:07   ` Jeff Mahoney
2017-08-21 13:24 ` [PATCH 0/5] BTRFS: Fine-tuning for five function implementations David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d33b6aa8-422b-507e-b004-923a25d235c9@suse.com \
    --to=jeffm@suse.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=elfring@users.sourceforge.net \
    --cc=jbacik@fb.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).