public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: fdmanana@kernel.org
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: fix qgroup double free after failure to reserve metadata for delalloc
Date: Thu, 17 Oct 2019 20:14:33 +0200	[thread overview]
Message-ID: <20191017181432.GN2751@twin.jikos.cz> (raw)
In-Reply-To: <20191015095439.6511-1-fdmanana@kernel.org>

On Tue, Oct 15, 2019 at 10:54:39AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> If we fail to reserve metadata for delalloc operations we end up releasing
> the previously reserved qgroup amount twice, once explicitly under the
> 'out_qgroup' label by calling btrfs_qgroup_free_meta_prealloc() and once
> again, under label 'out_fail', by calling btrfs_inode_rsv_release() with a
> value of 'true' for its 'qgroup_free' argument, which results in
> btrfs_qgroup_free_meta_prealloc() being called again, so we end up having
> a double free.
> 
> Also if we fail to reserve the necessary qgroup amount, we jump to the
> label 'out_fail', which calls btrfs_inode_rsv_release() and that in turns
> calls btrfs_qgroup_free_meta_prealloc(), even though we weren't able to
> reserve any qgroup amount. So we freed some amount we never reserved.
> 
> So fix this by removing the call to btrfs_inode_rsv_release() in the
> failure path, since it's not necessary at all as we haven't changed the
> inode's block reserve in any way at this point.
> 
> Fixes: c8eaeac7b73434 ("btrfs: reserve delalloc metadata differently")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Thanks, added to 5.4-rc queue.

      reply	other threads:[~2019-10-17 18:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15  9:54 [PATCH] Btrfs: fix qgroup double free after failure to reserve metadata for delalloc fdmanana
2019-10-17 18:14 ` David Sterba [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=20191017181432.GN2751@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=fdmanana@kernel.org \
    --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