From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>, dsterba@suse.cz
Cc: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2] btrfs: make btrfs_truncate_block() zero folio range for certain subpage corner cases
Date: Wed, 16 Apr 2025 09:27:09 +0930 [thread overview]
Message-ID: <408fff7f-00a9-41ec-91e6-168dcffb2de6@gmx.com> (raw)
In-Reply-To: <CAHp75Vf3Z=qQPKkALhCbSSCd9VYiYYZ4xVJ9aT=sYKW7tbPd2A@mail.gmail.com>
在 2025/4/16 03:51, Andy Shevchenko 写道:
> On Tue, Apr 15, 2025 at 9:18 PM David Sterba <dsterba@suse.cz> wrote:
>> On Mon, Apr 14, 2025 at 01:40:11PM +0300, Andy Shevchenko wrote:
>>> On Mon, Apr 14, 2025 at 4:20 AM Qu Wenruo <quwenruo.btrfs@gmx.com> wrote:
>>>> 在 2025/4/13 04:05, Andy Shevchenko 写道:
>>>>> Fri, Apr 11, 2025 at 02:44:01PM +0930, Qu Wenruo kirjoitti:
>
> [...]
>
>>>>>> + block_start = round_down(clamp_start, block_size);
>>>>>> + block_end = round_up(clamp_end + 1, block_size) - 1;
>>>>>
>>>>> LKP rightfully complains, I believe you want to use ALIGN*() macros instead.
>>>>
>>>> Personally speaking I really want to explicitly show whether it's
>>>> rounding up or down.
>>>>
>>>> And unfortunately the ALIGN() itself doesn't show that (meanwhile the
>>>> ALIGN_DOWN() is pretty fine).
>>>>
>>>> Can I just do a forced conversion on the @blocksize to fix the warning?
>>>
>>> ALIGN*() are for pointers, the round_*() are for integers. So, please
>>> use ALIGN*().
>>
>> clamp_start and blocksize are integers and there's a lot of use of ALIGN
>> with integers too. There's no documentation saying it should be used for
>> pointers, I can see PTR_ALIGN that does the explicit cast to unsigned
>> logn and then passes it to ALIGN (as integer).
>
> Yes, because the unsigned long is natural holder for the addresses and
> due to some APIs use it instead of pointers (for whatever reasons) the
> PTR_ALIGN() does that. But you see the difference? round_*() expect
> _the same_ types of the arguments, while ALIGN*() do not. That is what
> makes it so.
>
>> Historically in the btrfs code the use of ALIGN and round_* is basically
>> 50/50 so we don't have a consistent style, although we'd like to. As the
>> round_up and round_down are clear I'd rather keep using them in new
>> code.
>
> And how do you suggest avoiding the warning, please?
By fixing the typo, @block_size -> @blocksize.
The original warning is not about the type difference, but that
@block_size is a function pointer.
We have tons of round_down()/round_up() usage inside btrfs, with
different types.
E.g. btrfs_check_data_free_space(), which is calling
round_down()/round_up() against u64 and u32, and do you got any warnings?
Thanks,
Qu
next prev parent reply other threads:[~2025-04-15 23:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 5:13 [PATCH 0/2] btrfs: fix corner cases for subpage generic/363 failures Qu Wenruo
2025-04-11 5:14 ` [PATCH 1/2] btrfs: make btrfs_truncate_block() to zero involved blocks in a folio Qu Wenruo
2025-04-11 7:02 ` Qu Wenruo
2025-04-11 5:14 ` [PATCH 2/2] btrfs: make btrfs_truncate_block() zero folio range for certain subpage corner cases Qu Wenruo
2025-04-12 5:12 ` kernel test robot
2025-04-12 5:54 ` kernel test robot
2025-04-12 18:35 ` Andy Shevchenko
2025-04-14 1:20 ` Qu Wenruo
2025-04-14 3:37 ` Qu Wenruo
2025-04-14 10:40 ` Andy Shevchenko
2025-04-15 18:18 ` David Sterba
2025-04-15 18:21 ` Andy Shevchenko
2025-04-15 23:57 ` Qu Wenruo [this message]
2025-04-16 5:57 ` Andy Shevchenko
2025-04-16 8:28 ` 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=408fff7f-00a9-41ec-91e6-168dcffb2de6@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=andy.shevchenko@gmail.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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