From: robbieko <robbieko@synology.com>
To: fdmanana@gmail.com
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: fix infinite loop when tree log recovery
Date: Thu, 01 Dec 2016 09:42:23 +0800 [thread overview]
Message-ID: <ecb6ff393956132565b191bdc38875b0@synology.com> (raw)
In-Reply-To: <CAL3q7H7F=fiETSd5SVwq=EPP9gKK0-tRvwA_N6N=yFrujKGYMA@mail.gmail.com>
Hi Filipe,
Thank you for your review.
I have seen your modified change log with below
Btrfs: fix tree search logic when replaying directory entry deletes
Btrfs: fix deadlock caused by fsync when logging directory entries
Btrfs: fix enospc in hole punching
So what's the next step ?
modify patch change log and then send again ?
Thanks.
robbieko
Filipe Manana 於 2016-12-01 00:53 寫到:
> On Fri, Oct 7, 2016 at 10:30 AM, robbieko <robbieko@synology.com>
> wrote:
>> From: Robbie Ko <robbieko@synology.com>
>>
>> if log tree like below:
>> leaf N:
>> ...
>> item 240 key (282 DIR_LOG_ITEM 0) itemoff 8189 itemsize 8
>> dir log end 1275809046
>> leaf N+1:
>> item 0 key (282 DIR_LOG_ITEM 3936149215) itemoff 16275
>> itemsize 8
>> dir log end 18446744073709551615
>> ...
>>
>> when start_ret > 1275809046, but slot[0] never >= nritems,
>> so never go to next leaf.
>
> This doesn't explain how the infinite loop happens. Nor exactly how
> any problem happens.
>
> It's important to have detailed information in the change logs. I
> understand that english isn't your native tongue (it's not mine
> either, and I'm far from mastering it), but that's not an excuse to
> not express all the important information in detail (we can all live
> with grammar errors and typos, and we all do such errors frequently).
>
> I've added this patch to my branch at
> https://git.kernel.org/cgit/linux/kernel/git/fdmanana/linux.git/log/?h=for-chris-4.10
> but with a modified changelog and subject.
>
> The results of the wrong logic that decides when to move to the next
> leaf are unpredictable, and it won't always result in an infinite
> loop. We are accessing a slot that doesn't point to an item, to a
> memory location containing garbage to something unexpected, and in the
> worst case that location is beyond the last page of the extent buffer.
>
> Thanks.
>
>
>>
>> Signed-off-by: Robbie Ko <robbieko@synology.com>
>> ---
>> fs/btrfs/tree-log.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
>> index ef9c55b..e63dd99 100644
>> --- a/fs/btrfs/tree-log.c
>> +++ b/fs/btrfs/tree-log.c
>> @@ -1940,12 +1940,11 @@ static noinline int find_dir_range(struct
>> btrfs_root *root,
>> next:
>> /* check the next slot in the tree to see if it is a valid
>> item */
>> nritems = btrfs_header_nritems(path->nodes[0]);
>> + path->slots[0]++;
>> if (path->slots[0] >= nritems) {
>> ret = btrfs_next_leaf(root, path);
>> if (ret)
>> goto out;
>> - } else {
>> - path->slots[0]++;
>> }
>>
>> btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
>> --
>> 1.9.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs"
>> in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-12-01 1:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-07 9:30 [PATCH] Btrfs: fix infinite loop when tree log recovery robbieko
2016-11-30 16:53 ` Filipe Manana
2016-12-01 1:42 ` robbieko [this message]
2016-12-01 11:14 ` Filipe Manana
2016-12-02 1:32 ` robbieko
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=ecb6ff393956132565b191bdc38875b0@synology.com \
--to=robbieko@synology.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).