linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com,
	Josef Bacik <jbacik@fb.com>
Subject: Re: [PATCH] btrfs: fix deadlock when writing out space cache
Date: Mon, 20 Nov 2017 18:22:51 +0100	[thread overview]
Message-ID: <20171120172251.GC3553@twin.jikos.cz> (raw)
In-Reply-To: <1510780852-8862-1-git-send-email-josef@toxicpanda.com>

On Wed, Nov 15, 2017 at 04:20:52PM -0500, Josef Bacik wrote:
> From: Josef Bacik <jbacik@fb.com>
> 
> If we fail to prepare our pages for whatever reason (out of memory in
> our case) we need to make sure to drop the block_group->data_rwsem,
> otherwise hilarity ensues.
> 
> Signed-off-by: Josef Bacik <jbacik@fb.com>
> ---
>  fs/btrfs/free-space-cache.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index cdc9f4015ec3..a6c643275210 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -1263,8 +1263,12 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
>  
>  	/* Lock all pages first so we can lock the extent safely. */
>  	ret = io_ctl_prepare_pages(io_ctl, inode, 0);
> -	if (ret)
> +	if (ret) {
> +		if (block_group &&
> +		    (block_group->flags & BTRFS_BLOCK_GROUP_DATA))
> +			up_write(&block_group->data_rwsem);
>  		goto out;

The unlocking sequence is in the exit block but does not have a label.
It would be better to reuse the code.

      parent reply	other threads:[~2017-11-20 17:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15 21:20 [PATCH] btrfs: fix deadlock when writing out space cache Josef Bacik
2017-11-15 21:29 ` Omar Sandoval
2017-11-15 23:46 ` Liu Bo
2017-11-16  1:52   ` Chris Mason
2017-11-16  8:09 ` Nikolay Borisov
2017-11-16 13:50   ` Chris Mason
2017-11-16 13:53     ` Nikolay Borisov
2017-11-20 17:22 ` 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=20171120172251.GC3553@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=jbacik@fb.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.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).