From: Miao Xie <miaoxie@huawei.com>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>, <dsterba@suse.cz>,
<linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs: Don't call btrfs_start_transaction() on frozen fs to avoid deadlock.
Date: Tue, 20 Jan 2015 16:16:06 +0800 [thread overview]
Message-ID: <54BE0EC6.8060707@huawei.com> (raw)
In-Reply-To: <54BDC8B3.2030602@cn.fujitsu.com>
On Tue, 20 Jan 2015 11:17:07 +0800, Qu Wenruo wrote:
>>>>>> --- a/fs/btrfs/super.c
>>>>>> +++ b/fs/btrfs/super.c
>>>>>> @@ -1000,6 +1000,14 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
>>>>>> */
>>>>>> if (fs_info->pending_changes == 0)
>>>>>> return 0;
>>>>>> + /*
>>>>>> + * Test if the fs is frozen, or start_trasaction
>>>>>> + * will deadlock on itself.
>>>>>> + */
>>>>>> + if (__sb_start_write(sb, SB_FREEZE_FS, false))
>>>>>> + __sb_end_write(sb, SB_FREEZE_FS);
>>>>>> + else
>>>>>> + return 0;
>>>>> I'm not sure this is the right fix. We should use either
>>>>> mnt_want_write_file or sb_start_write around the start/commit functions.
>>>>> The fs may be frozen already, but we also have to catch transition to
>>>>> that state, or RO remount.
>>>> But the deadlock between s_umount and frozen level is a larger problem...
>>>>
>>>> Even Miao mentioned that we can start a transaction in btrfs_freeze(), but
>>>> there is still possibility that
>>>> we try to change the feature of the frozen btrfs and do sync, again the
>>>> deadlock will happen.
>>>> Although handling in btrfs_freeze() is also needed, but can't resolve all the
>>>> problem.
>>>>
>>>> IMHO the fix is still needed, or at least as a workaround until we find a real
>>>> root solution for it
>>>> (If nobody want to revert the patchset)
>>>>
>>>> BTW, what about put the pending changes to a workqueue? If we don't start
>>>> transaction under
>>>> s_umount context like sync_fs()
>> I don't like this fix.
>> I think we should deal with those pending changes when we freeze a filesystem.
>> or we break the rule of fs freeze.
> I am afraid handling it in btrfs_freeze() won't help.
> Case like freeze() -> change_feature -> sync() -> unfreeze() will still deadlock
> in sync().
We should not change feature after the fs is freezed.
> Even cleared the pending changes in freeze(), it can still be set through sysfs
> interface even the fs is frozen.
>
> And in fact, if we put the things like attach/create a transaction into a
> workqueue, we will not break
> the freeze rule.
> Since if the fs is frozen, there is no running transaction and we need to create
> a new one,
> that will call sb_start_intwrite(), which will sleep until the fs is unfreeze.
I read the pending change code just now, and I found the pending change is just
used for changing the mount option now, so I think as a work-around fix we
needn't start a new transaction to handle the pending flags which are set after
the current transaction is committed, because the data on the disk is
integrated.
Thanks
Miao
>
> Thanks,
> Qu
>>
>> Thanks
>> Miao
>>
>>>> Thanks,
>>>> Qu
>>>>> Also, returning 0 is not right, the ioctl actually skipped the expected
>>>>> work.
>>>>>
>>>>>> trans = btrfs_start_transaction(root, 0);
>>>>>> } else {
>>>>>> return PTR_ERR(trans);
>>> .
>>>
>
> .
>
next prev parent reply other threads:[~2015-01-20 8:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-19 7:42 [PATCH] btrfs: Don't call btrfs_start_transaction() on frozen fs to avoid deadlock Qu Wenruo
2015-01-19 14:06 ` David Sterba
2015-01-20 2:51 ` Qu Wenruo
2015-01-20 2:53 ` Qu Wenruo
2015-01-20 3:06 ` Miao Xie
2015-01-20 3:17 ` Qu Wenruo
2015-01-20 8:16 ` Miao Xie [this message]
2015-01-20 0:19 ` Miao Xie
2015-01-20 0:26 ` Qu Wenruo
2015-01-20 17:13 ` David Sterba
2015-01-21 0:58 ` Qu Wenruo
2015-01-21 1:05 ` Chris Mason
2015-01-21 1:09 ` Qu Wenruo
2015-01-21 1:10 ` Chris Mason
2015-01-21 3:10 ` Miao Xie
2015-01-21 3:15 ` Qu Wenruo
2015-01-21 3:26 ` Miao Xie
2015-01-21 3:53 ` Qu Wenruo
2015-01-21 7:04 ` Miao Xie
2015-01-21 7:47 ` Qu Wenruo
2015-01-21 8:46 ` Miao Xie
2015-01-23 17:39 ` David Sterba
2015-01-23 18:21 ` Chris Mason
2015-01-23 16:59 ` David Sterba
2015-01-26 0:31 ` Miao Xie
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=54BE0EC6.8060707@huawei.com \
--to=miaoxie@huawei.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo@cn.fujitsu.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).