From: Liu Bo <bo.li.liu@oracle.com>
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: Wed, 15 Nov 2017 15:46:06 -0800 [thread overview]
Message-ID: <20171115234606.GA23320@dhcp-whq-twvpn-1-vpnpool-10-159-153-242.vpn.oracle.com> (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.
>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Thanks,
-liubo
> 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;
> + }
>
> lock_extent_bits(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
> &cached_state);
> --
> 2.7.5
>
> --
> 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
next prev parent reply other threads:[~2017-11-15 23:46 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 [this message]
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
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=20171115234606.GA23320@dhcp-whq-twvpn-1-vpnpool-10-159-153-242.vpn.oracle.com \
--to=bo.li.liu@oracle.com \
--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 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.