linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: fdmanana@gmail.com
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 2/6] btrfs: Improve comments around nocow path
Date: Wed, 7 Aug 2019 11:16:07 +0300	[thread overview]
Message-ID: <df7b35d1-da0d-c99a-40dc-44c8ccd8d985@suse.com> (raw)
In-Reply-To: <CAL3q7H7VnX7ez5VeYbKFk=W1s_1AeS0hYpmVPvZ4af4NJerjUw@mail.gmail.com>



On 6.08.19 г. 13:09 ч., Filipe Manana wrote:
> On Mon, Aug 5, 2019 at 3:48 PM Nikolay Borisov <nborisov@suse.com> wrote:

<snip>

>> @@ -1371,23 +1376,39 @@ static noinline int run_delalloc_nocow(struct inode *inode,
>>
>>                 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
>>
>> +               /* Didn't find anything for our INO */
>>                 if (found_key.objectid > ino)
>>                         break;
>> +               /*
>> +                * Found a different inode or no extents for our file,
>> +                * goto next slot
> 
> No. This does not mean that there are no extents for the file. If
> there weren't any, we would break instead of iterating to the next
> slot.
> One example described at
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1d512cb77bdbda80f0dd0620a3b260d697fd581d

I see, thanks for the pointer. How about the following :

/*
                 * Keep searching until we find an EXTENT ITEM or are
sure
                 * there are no more extents for this inode

                 */

While it doesn't mention the race condition this check, coupled with the
next one (where we break if type > EXTENT_DATA_KEY), it reflects reality
close enough?


> 
>> +                */
>>                 if (WARN_ON_ONCE(found_key.objectid < ino) ||
>>                     found_key.type < BTRFS_EXTENT_DATA_KEY) {
>>                         path->slots[0]++;
>>                         goto next_slot;
>>                 }
>> +
>> +               /* Found key is not EXTENT_DATA_KEY or starts after req range */
>>                 if (found_key.type > BTRFS_EXTENT_DATA_KEY ||
>>                     found_key.offset > end)
>>                         break;
>>
>> +               /*
>> +                * If the found extent starts after requested offset, then
>> +                * adjust extent_end to be right before this extent begins
>> +                */
>>                 if (found_key.offset > cur_offset) {
>>                         extent_end = found_key.offset;
>>                         extent_type = 0;
>>                         goto out_check;
>>                 }
>>
>> +
>> +               /*
>> +                * Found extent which begins before our range and has the
>> +                * potential to intersect it.
>> +                */
>>                 fi = btrfs_item_ptr(leaf, path->slots[0],
>>                                     struct btrfs_file_extent_item);
>>                 extent_type = btrfs_file_extent_type(leaf, fi);
<snip>

  reply	other threads:[~2019-08-07  8:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05 14:47 [PATCH 0/6] Refactor nocow path Nikolay Borisov
2019-08-05 14:47 ` [PATCH 1/6] btrfs: Refactor run_delalloc_nocow Nikolay Borisov
2019-08-21  7:42   ` [PATCH v2 1/2] " Nikolay Borisov
2019-08-21 15:03     ` David Sterba
2019-08-05 14:47 ` [PATCH 2/6] btrfs: Improve comments around nocow path Nikolay Borisov
2019-08-06 10:09   ` Filipe Manana
2019-08-07  8:16     ` Nikolay Borisov [this message]
2019-08-07  8:26       ` Filipe Manana
2019-08-21  7:42   ` [PATCH v2 2/2] " Nikolay Borisov
2019-08-21 15:10     ` David Sterba
2019-08-05 14:47 ` [PATCH 3/6] btrfs: Simplify run_delalloc_nocow Nikolay Borisov
2019-08-06  9:01   ` Johannes Thumshirn
2019-08-05 14:47 ` [PATCH 4/6] btrfs: Streamline code in run_delalloc_nocow in case of inline extents Nikolay Borisov
2019-08-21 15:17   ` David Sterba
2019-08-05 14:47 ` [PATCH 5/6] btrfs: Simplify extent type check Nikolay Borisov
2019-08-06 10:14   ` Filipe Manana
2019-08-21 15:40   ` David Sterba
2019-08-21 23:47     ` Qu Wenruo
2019-08-22  5:58       ` Nikolay Borisov
2019-08-22 14:25     ` [PATCH] btrfs: Streamline code in run_delalloc_nocow Nikolay Borisov
2019-08-23 17:27       ` David Sterba
2019-08-05 14:47 ` [PATCH 6/6] btrfs: Remove BUG_ON from run_delalloc_nocow Nikolay Borisov
2019-08-06 10:34   ` Filipe Manana
2019-08-07  8:18     ` Nikolay Borisov
2019-08-21 15:55       ` David Sterba
2019-08-22 14:24         ` [PATCH v2] " Nikolay Borisov
2019-08-23 17:28           ` David Sterba
2019-08-19 16:42 ` [PATCH 0/6] Refactor nocow path David Sterba
2019-08-21 15:59 ` 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=df7b35d1-da0d-c99a-40dc-44c8ccd8d985@suse.com \
    --to=nborisov@suse.com \
    --cc=fdmanana@gmail.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).