linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Behrens <sbehrens@giantdisaster.de>
To: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 15/26] Btrfs: add a new source file with device replace code
Date: Mon, 12 Nov 2012 18:21:00 +0100	[thread overview]
Message-ID: <50A12FFC.5030807@giantdisaster.de> (raw)
In-Reply-To: <20121109144512.GC6347@gmail.com>

On Fri, 9 Nov 2012 22:45:16 +0800, Liu Bo wrote:
> On Fri, Nov 09, 2012 at 11:19:17AM +0100, Stefan Behrens wrote:
>> On Fri, 9 Nov 2012 08:44:01 +0800, Liu Bo wrote:
>>> On Thu, Nov 08, 2012 at 06:24:36PM +0100, Stefan Behrens wrote:
>>>> On Thu, 8 Nov 2012 22:50:47 +0800, Liu Bo wrote:
>>>>> On Tue, Nov 06, 2012 at 05:38:33PM +0100, Stefan Behrens wrote:
>>>>>> +	trans = btrfs_start_transaction(root, 0);
>>>>>
>>>>> why a start_transaction here?  Any reasons?
>>>>> (same question also for some other places)
>>>>>
>>>>
>>>> Without this transaction, there is outstanding I/O which is not flushed.
>>>> Pending writes that go only to the old disk need to be flushed before
>>>> the mode is switched to write all live data to the source disk and to
>>>> the target disk as well. The copy operation that is part of the scrub
>>>> code works on the commit root for performance reasons. Every write
>>>> request that is performed after the commit root is established needs to
>>>> go to both disks. Those requests that already have the bdev assigned
>>>> (i.e., btrfs_map_bio() was already called) cannot be duplicated anymore
>>>> to write to the new disk as well.
>>>>
>>>> btrfs_dev_replace_finishing() looks similar and goes through a
>>>> transaction commit between the steps where the bdev in the mapping tree
>>>> is swapped and the step when the old bdev is freed. Otherwise the bdev
>>>> would be accessed after being freed.
>>>>
>>>
>>> I see, if you're only about to flush metadata, why not join a transaction?
>>
>> btrfs_join_transaction() would delay the current transaction and enforce
>> that the current transaction is used and not a new one.
>> btrfs_start_transaction() would use either the current transaction, or a
>> new one. It is less interfering.
> 
> hmm...btrfs_start_transaction() would not use the current transaction unless
> you're still in the same task, ie. current->journal_info remains unchanged,
> otherwise it will be blocked by the current transaction(wait_current_trans()).
> 
> If there are several btrfs_start_transaction() being blocked, after the current
> one's commit, one of them will allocate a new transaction, and the rest can join it.
> 
> But btrfs_join_transaction will join the current as much as possible.
> 
> And since here we don't do any reservation and seems to just update chunk/device
> tree(which will use global block rsv directly), I perfer btrfs_join_transaction().
> 

I am still not sure, which one is worse or better:
a) to delay a commit by calling btrfs_join_transaction() which joins and thereby delays a transaction, or
b) to go through one additional transaction.

Here is the log message of the commit that added btrfs_join_transaction(). For me, it sounds like one should use btrfs_join_transaction() only when it is _required_ to join a transaction, e.g. when a low level function is required to join the transaction that some higher level function has started:

commit f9295749388f82c8d2f485e99c72cd7c7876a99b
Author: Chris Mason <chris.mason@oracle.com>
Date:   Thu Jul 17 12:54:14 2008 -0400

    btrfs_start_transaction: wait for commits in progress to finish

    btrfs_commit_transaction has to loop waiting for any writers in the
    transaction to finish before it can proceed.  btrfs_start_transaction
    should be polite and not join a transaction that is in the process
    of being finished off.

    There are a few places that can't wait, basically the ones doing IO that
    might be needed to finish the transaction.  For them, btrfs_join_transaction
    is added.



>>
>> Since in dev-replace.c it is not required to enforce that a current
>> transaction is joined, btrfs_start_transaction() is the one to choose
>> here, as I understood it.
>>
>> But that's an interesting topic and I would appreciate to get a definite
>> rule which one to choose when.



  reply	other threads:[~2012-11-12 17:21 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-06 16:38 [PATCH 00/26] Btrfs: Add device replace code Stefan Behrens
2012-11-06 16:38 ` [PATCH 01/26] Btrfs: rename the scrub context structure Stefan Behrens
2012-11-06 16:38 ` [PATCH 02/26] Btrfs: remove the block device pointer from the scrub context struct Stefan Behrens
2012-11-06 16:38 ` [PATCH 03/26] Btrfs: make the scrub page array dynamically allocated Stefan Behrens
2012-11-06 16:38 ` [PATCH 04/26] Btrfs: in scrub repair code, optimize the reading of mirrors Stefan Behrens
2012-11-06 16:38 ` [PATCH 05/26] Btrfs: in scrub repair code, simplify alloc error handling Stefan Behrens
2012-11-06 16:38 ` [PATCH 06/26] Btrfs: cleanup scrub bio and worker wait code Stefan Behrens
2012-11-06 16:38 ` [PATCH 07/26] Btrfs: add two more find_device() methods Stefan Behrens
2012-11-08 14:24   ` Liu Bo
2012-11-12 16:50     ` Stefan Behrens
2012-11-06 16:38 ` [PATCH 08/26] Btrfs: Pass fs_info to btrfs_num_copies() instead of mapping_tree Stefan Behrens
2012-11-06 16:38 ` [PATCH 09/26] Btrfs: pass fs_info to btrfs_map_block() " Stefan Behrens
2012-11-06 16:38 ` [PATCH 10/26] Btrfs: add btrfs_scratch_superblock() function Stefan Behrens
2012-11-06 16:38 ` [PATCH 11/26] Btrfs: pass fs_info instead of root Stefan Behrens
2012-11-06 16:38 ` [PATCH 12/26] Btrfs: avoid risk of a deadlock in btrfs_handle_error Stefan Behrens
2012-11-06 16:38 ` [PATCH 13/26] Btrfs: enhance btrfs structures for device replace support Stefan Behrens
2012-11-06 16:38 ` [PATCH 14/26] Btrfs: introduce a btrfs_dev_replace_item type Stefan Behrens
2012-11-06 16:38 ` [PATCH 15/26] Btrfs: add a new source file with device replace code Stefan Behrens
2012-11-08 14:50   ` Liu Bo
2012-11-08 17:24     ` Stefan Behrens
2012-11-09  0:44       ` Liu Bo
2012-11-09 10:19         ` Stefan Behrens
2012-11-09 14:45           ` Liu Bo
2012-11-12 17:21             ` Stefan Behrens [this message]
2012-11-06 16:38 ` [PATCH 16/26] Btrfs: disallow mutually exclusiv admin operations from user mode Stefan Behrens
2012-11-06 16:38 ` [PATCH 17/26] Btrfs: disallow some operations on the device replace target device Stefan Behrens
2012-11-06 16:38 ` [PATCH 18/26] Btrfs: handle errors from btrfs_map_bio() everywhere Stefan Behrens
2012-11-06 16:38 ` [PATCH 19/26] Btrfs: add code to scrub to copy read data to another disk Stefan Behrens
2012-11-07  0:30   ` Tsutomu Itoh
2012-11-07 10:30     ` Stefan Behrens
2012-11-06 16:38 ` [PATCH 20/26] Btrfs: change core code of btrfs to support the device replace operations Stefan Behrens
2012-11-06 16:38 ` [PATCH 21/26] Btrfs: introduce GET_READ_MIRRORS functionality for btrfs_map_block() Stefan Behrens
2012-11-06 16:38 ` [PATCH 22/26] Btrfs: changes to live filesystem are also written to replacement disk Stefan Behrens
2012-11-06 16:38 ` [PATCH 23/26] Btrfs: optionally avoid reads from device replace source drive Stefan Behrens
2012-11-06 16:38 ` [PATCH 24/26] Btrfs: increase BTRFS_MAX_MIRRORS by one for dev replace Stefan Behrens
2012-11-09 10:47   ` David Pottage
2012-11-09 11:23     ` Stefan Behrens
2012-11-06 16:38 ` [PATCH 25/26] Btrfs: allow repair code to include target disk when searching mirrors Stefan Behrens
2012-11-06 16:38 ` [PATCH 26/26] Btrfs: add support for device replace ioctls Stefan Behrens
     [not found] ` <CAGy7UtjR+kZoBYWaeg=-jHbJHQh4pe3Jt5cwX-rTQEBHFkQ-YQ@mail.gmail.com>
2012-11-06 18:57   ` [PATCH 00/26] Btrfs: Add device replace code Stefan Behrens
2012-11-06 19:20     ` Hugo Mills
2012-11-06 22:48       ` Zach Brown
2012-11-07 10:29         ` Stefan Behrens
2012-11-07  2:14 ` Tsutomu Itoh
2012-11-07 13:12   ` Stefan Behrens
2012-11-08 12:50     ` Goffredo Baroncelli
2012-11-08 17:31       ` Stefan Behrens
2012-11-08 18:41         ` Goffredo Baroncelli
2012-11-09 10:02         ` Michael Kjörling
2012-11-13 16:25           ` Bart Noordervliet
2012-11-14 11:42             ` Stefan Behrens
2012-11-08  0:59 ` Chris Mason

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=50A12FFC.5030807@giantdisaster.de \
    --to=sbehrens@giantdisaster.de \
    --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).