From: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
To: Dave Chinner <david@fromorbit.com>,
fstests <fstests@vger.kernel.org>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH] common/populate: Ensure that S_IFDIR.FMT_BTREE is in btree format
Date: Thu, 8 Dec 2022 14:29:31 +0800 [thread overview]
Message-ID: <09be45f9-bbb1-24e0-bf23-7a327062c469@linux.alibaba.com> (raw)
In-Reply-To: <20221207214831.GI2703033@dread.disaster.area>
On 2022/12/8 05:48, Dave Chinner wrote:
> On Wed, Dec 07, 2022 at 10:11:49AM +0800, Gao Xiang wrote:
>> On Wed, Dec 07, 2022 at 10:34:17AM +1100, Dave Chinner wrote:
>>> On Fri, Dec 02, 2022 at 10:23:07AM +0800, Gao Xiang wrote:
>>>>>> + [ "$nexts" -gt "$(((isize - 176) / 16))" ] && break
>>>>>
>>>>> Only need to calculate this once if you declare this at the top:
>>>>>
>>>>> # We need enough extents to guarantee that the data fork is in
>>>>> # btree format. Cycling the mount to use xfs_db is too slow, so
>>>>> # watch for when the extent count exceeds the space after the
>>>>> # inode core.
>>>>> local max_nextents="$(((isize - 176) / 16))"
>>>>>
>>>>> and then you can do:
>>>>>
>>>>> [[ $nexts -gt $max_nextents ]] && break
>>>>>
>>>>> Also not a fan of hardcoding 176 around fstests, but I don't know how
>>>>> we'd detect that at all.
>>>>>
>>>>> # Number of bytes reserved for only the inode record, excluding the
>>>>> # immediate fork areas.
>>>>> _xfs_inode_core_bytes()
>>>>> {
>>>>> echo 176
>>>>> }
>>>>>
>>>>> I guess? Or extract it from tests/xfs/122.out?
>>>>
>>>> Thanks for your comments.
>>>>
>>>> I guess hard-coded 176 in _xfs_inode_core_bytes() is fine for now
>>>> (It seems a bit weird to extract a number from a test expected result..)
>>>
>>> Which is wrong when testing a v4 filesystem - in that case the inode
>>> core size is 96 bytes and so max extents may be larger on v4
>>> filesystems than v5 filesystems....
>>
>> Do we really care v4 fs for now since it's deprecated?...
>
> Yes, there are still lots of v4 filesystems in production
> environments. There shouldn't be many new ones, but there is a long
> tail of existing storage containing v4 filesystems that we must not
> break.
>
> We have to support v4 filesystems for another few years yet, hence
> we still need solid test coverage on them to ensure we don't
> accidentally break something that is going to bite users before they
> migrate to newer filesystems....
>
>> Darrick once also
>> suggested using (isize / 16) but it seems it could take unnecessary time to
>> prepare.. Or we could just use (isize - 96) / 16 to keep v4 work.
>
> It's taken me longer to write this email than it does to write the
> code to make it work properly. e.g.:
>
> xfs_info $scratch | sed -ne 's/.*crc=\([01]\).*/\1/p'
>
> And now we have 0 = v4, 1 = v5, and it's trivial to return the
> correct inode size.
>
> You can even do this trivially with grep:
>
> xfs_info $scratch | grep -wq "crc=1"
> if [ $? -eq 0 ]; then
> echo 176
> else
> echo 96
> fi
>
> and now the return value tells us if we have a v4 or v5 filesystem.
>
> -Dave.
Hi, David
I have written new versions, please see:
https://lore.kernel.org/fstests/20221207093147.1634425-1-ZiyangZhang@linux.alibaba.com/
Regards,
Zhang
prev parent reply other threads:[~2022-12-08 6:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 8:12 [PATCH] common/populate: Ensure that S_IFDIR.FMT_BTREE is in btree format Gao Xiang
2022-12-01 15:52 ` Darrick J. Wong
2022-12-02 2:23 ` Gao Xiang
2022-12-06 23:34 ` Dave Chinner
2022-12-07 2:11 ` Gao Xiang
2022-12-07 2:17 ` Darrick J. Wong
2022-12-07 21:48 ` Dave Chinner
2022-12-08 6:29 ` Ziyang Zhang [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=09be45f9-bbb1-24e0-bf23-7a327062c469@linux.alibaba.com \
--to=ziyangzhang@linux.alibaba.com \
--cc=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@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