All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: gregkh@linuxfoundation.org
Cc: fdmanana@suse.com, anand.jain@oracle.com, dsterba@suse.com,
	nborisov@suse.com, stable@vger.kernel.org
Subject: Re: FAILED: patch "[PATCH] btrfs: fix a block group ref counter leak after failure to" failed to apply to 4.19-stable tree
Date: Thu, 2 Jul 2020 11:40:09 -0400	[thread overview]
Message-ID: <20200702154009.GA2722994@sasha-vm> (raw)
In-Reply-To: <1593428443202151@kroah.com>

On Mon, Jun 29, 2020 at 01:00:43PM +0200, gregkh@linuxfoundation.org wrote:
>
>The patch below does not apply to the 4.19-stable tree.
>If someone wants it applied there, or to any other stable or longterm
>tree, then please email the backport, including the original git commit
>id to <stable@vger.kernel.org>.
>
>thanks,
>
>greg k-h
>
>------------------ original commit in Linus's tree ------------------
>
>From 9fecd13202f520f3f25d5b1c313adb740fe19773 Mon Sep 17 00:00:00 2001
>From: Filipe Manana <fdmanana@suse.com>
>Date: Mon, 1 Jun 2020 19:12:06 +0100
>Subject: [PATCH] btrfs: fix a block group ref counter leak after failure to
> remove block group
>
>When removing a block group, if we fail to delete the block group's item
>from the extent tree, we jump to the 'out' label and end up decrementing
>the block group's reference count once only (by 1), resulting in a counter
>leak because the block group at that point was already removed from the
>block group cache rbtree - so we have to decrement the reference count
>twice, once for the rbtree and once for our lookup at the start of the
>function.
>
>There is a second bug where if removing the free space tree entries (the
>call to remove_block_group_free_space()) fails we end up jumping to the
>'out_put_group' label but end up decrementing the reference count only
>once, when we should have done it twice, since we have already removed
>the block group from the block group cache rbtree. This happens because
>the reference count decrement for the rbtree reference happens after
>attempting to remove the free space tree entries, which is far away from
>the place where we remove the block group from the rbtree.
>
>To make things less error prone, decrement the reference count for the
>rbtree immediately after removing the block group from it. This also
>eleminates the need for two different exit labels on error, renaming
>'out_put_label' to just 'out' and removing the old 'out'.
>
>Fixes: f6033c5e333238 ("btrfs: fix block group leak when removing fails")
>CC: stable@vger.kernel.org # 4.4+
>Reviewed-by: Nikolay Borisov <nborisov@suse.com>
>Reviewed-by: Anand Jain <anand.jain@oracle.com>
>Signed-off-by: Filipe Manana <fdmanana@suse.com>
>Reviewed-by: David Sterba <dsterba@suse.com>
>Signed-off-by: David Sterba <dsterba@suse.com>

On older branches, btrfs_remove_block_group() lived in
fs/btrfs/extent-tree.c. I've fixed up the patch and queued it for
4.19-4.9. The 4.4 backport needs some attention.

-- 
Thanks,
Sasha

      reply	other threads:[~2020-07-02 15:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29 11:00 FAILED: patch "[PATCH] btrfs: fix a block group ref counter leak after failure to" failed to apply to 4.19-stable tree gregkh
2020-07-02 15:40 ` Sasha Levin [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=20200702154009.GA2722994@sasha-vm \
    --to=sashal@kernel.org \
    --cc=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=fdmanana@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=nborisov@suse.com \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.