linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Liu Bo <bo.li.liu@oracle.com>
To: fdmanana@kernel.org
Cc: linux-btrfs@vger.kernel.org, Filipe Manana <fdmanana@suse.com>
Subject: Re: [PATCH] Btrfs: fix transaction handle leak on failure to create hard link
Date: Tue, 5 Jan 2016 18:33:41 -0800	[thread overview]
Message-ID: <20160106023341.GC23191@localhost.localdomain> (raw)
In-Reply-To: <1452011582-9460-1-git-send-email-fdmanana@kernel.org>

On Tue, Jan 05, 2016 at 04:33:02PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> If we failed to create a hard link we were not always releasing the
> the transaction handle we got before, resulting in a memory leak and
> preventing any other tasks from being able to commit the current
> transaction.
> Fix this by always releasing our transaction handle.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Thanks,

-liubo
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
>  fs/btrfs/inode.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 5dbc07a..018c2a6 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -6488,7 +6488,7 @@ out_unlock_inode:
>  static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
>  		      struct dentry *dentry)
>  {
> -	struct btrfs_trans_handle *trans;
> +	struct btrfs_trans_handle *trans = NULL;
>  	struct btrfs_root *root = BTRFS_I(dir)->root;
>  	struct inode *inode = d_inode(old_dentry);
>  	u64 index;
> @@ -6514,6 +6514,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
>  	trans = btrfs_start_transaction(root, 5);
>  	if (IS_ERR(trans)) {
>  		err = PTR_ERR(trans);
> +		trans = NULL;
>  		goto fail;
>  	}
>  
> @@ -6547,9 +6548,10 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
>  		btrfs_log_new_name(trans, inode, NULL, parent);
>  	}
>  
> -	btrfs_end_transaction(trans, root);
>  	btrfs_balance_delayed_items(root);
>  fail:
> +	if (trans)
> +		btrfs_end_transaction(trans, root);
>  	if (drop_inode) {
>  		inode_dec_link_count(inode);
>  		iput(inode);
> -- 
> 2.1.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2016-01-06  2:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05 16:33 [PATCH] Btrfs: fix transaction handle leak on failure to create hard link fdmanana
2016-01-06  2:33 ` Liu Bo [this message]

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=20160106023341.GC23191@localhost.localdomain \
    --to=bo.li.liu@oracle.com \
    --cc=fdmanana@kernel.org \
    --cc=fdmanana@suse.com \
    --cc=linux-btrfs@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).