linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Mason <clm@fb.com>
To: Nikolay Borisov <nborisov@suse.com>,
	Josef Bacik <josef@toxicpanda.com>, <linux-btrfs@vger.kernel.org>,
	<kernel-team@fb.com>
Cc: Josef Bacik <jbacik@fb.com>
Subject: Re: [PATCH] btrfs: fix deadlock when writing out space cache
Date: Thu, 16 Nov 2017 08:50:13 -0500	[thread overview]
Message-ID: <cda921a3-0f24-1e51-5fa7-ecf74f4a85de@fb.com> (raw)
In-Reply-To: <7281db4c-6d0f-c463-ba1a-fc77b356d906@suse.com>



On 11/16/2017 03:09 AM, Nikolay Borisov wrote:
> 
> 
> On 15.11.2017 23:20, 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;
>> +	}
> 
> Which function after out: label causes a deadlock - btrfs_update_inode
> (unlikely) or invalidate_inode_pages2?

Neither, out: just doesn't drop the data_rwsem mutex, so it leaves the 
block group locked.

-chris

  reply	other threads:[~2017-11-16 13:50 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 [this message]
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=cda921a3-0f24-1e51-5fa7-ecf74f4a85de@fb.com \
    --to=clm@fb.com \
    --cc=jbacik@fb.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /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).