linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miao Xie <miaox@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/5] Btrfs: fix missing flush when committing a transaction
Date: Thu, 01 Nov 2012 18:18:19 +0800	[thread overview]
Message-ID: <50924C6B.8090609@cn.fujitsu.com> (raw)
In-Reply-To: <20121101085959.GD2554@liubo.cn.oracle.com>

On Thu, 1 Nov 2012 17:00:00 +0800, Liu Bo wrote:
> On Thu, Nov 01, 2012 at 04:16:43PM +0800, Miao Xie wrote:
>> On thu, 1 Nov 2012 16:04:27 +0800, Liu Bo wrote:
>>> (sorry, forgot to cc linux-btrfs.)
>>> On Thu, Nov 01, 2012 at 03:51:41PM +0800, Miao Xie wrote:
>>>> On Thu, 1 Nov 2012 15:44:43 +0800, Liu Bo wrote:
>>>>> On Thu, Nov 01, 2012 at 03:33:14PM +0800, Miao Xie wrote:
>>>>>> Consider the following case:
>>>>>> 	Task1				Task2
>>>>>> 	start_transaction
>>>>>> 					commit_transaction
>>>>>> 					  check pending snapshots list and the
>>>>>> 					  list is empty.
>>>>>> 	add pending snapshot into list
>>>>>> 					  skip the delalloc flush
>>>>>> 	end_transaction
>>>>>> 					  ...
>>>>>>
>>>>>> And then the problem that the snapshot is different with the source subvolume
>>>>>> happen.
>>>>>>
>>>>>
>>>>> This is weird, create_snapshot() will first add pending snapshot into
>>>>> list and then commit the transaction itself, regardless of if the
>>>>> snapshot is different with others or not.
>>>>
>>>> But the transaction may be committed by the other task, and the snapshot
>>>> creation task just wait until it ends.
>>>>
>>>
>>> It's possible that a commit tranaction becomes a end transaction when it
>>> finds itself is already in commit.
>>>
>>> So if snapshot creation starts the transaction, it will increment the
>>> transaction's num_writers, why does not the other task wait for its
>>> end_transacion?
>>>
>>> I doubt if this can really happen anyway...
>>>
>>> Can you elaborate the situation more?
>>
>> Task1					Task2
>> start_transaction
>> 					start_transaction
>> 					commit_transaction
>> 					  set in_commit to 1
>> 					  check pending snapshots list and the list is empty.
>> add pending snapshot into list
>> 					  skip the delalloc flush
>> commit_transaction
>>   find in_commit is 1
>>   end_transaction (num_writer--)
>>   wait_for_commit
>> 					  num_writer is 1
>> 				  	  continue committing the transaction
>> 					  ...
>>
> 
> Make sense.
> 
> Then I think we'd better put the flush part right after setting 'trans_no_join = 1'

No, or the flusher will be blocked when it joins an transaction.

> since snapshot creation may also join an existing transaction.

It is impossible because btrfs_start_transaction is different from btrfs_join_transaction,
it will be blocked when transaction->blocked is 1. Snapshot creation uses btrfs_start_transaction.

Thanks
Miao

      reply	other threads:[~2012-11-01 10:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-01  7:33 [PATCH 2/5] Btrfs: fix missing flush when committing a transaction Miao Xie
     [not found] ` <20121101074443.GC1591@liubo.cn.oracle.com>
     [not found]   ` <50922A0D.80103@cn.fujitsu.com>
2012-11-01  8:04     ` Liu Bo
2012-11-01  8:16       ` Miao Xie
2012-11-01  9:00         ` Liu Bo
2012-11-01 10:18           ` Miao Xie [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=50924C6B.8090609@cn.fujitsu.com \
    --to=miaox@cn.fujitsu.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).