public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Qu Wenruo <quwenruo.btrfs@gmx.com>, 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 10:28:31 +0200	[thread overview]
Message-ID: <20250416082831.GA13877@suse.cz> (raw)
In-Reply-To: <CAHp75VdJoPKoYu=fOZYPV6Cd+rgcWVM9_NDJ-Gyu3O33tS447w@mail.gmail.com>

On Wed, Apr 16, 2025 at 08:57:40AM +0300, Andy Shevchenko wrote:
> On Wed, Apr 16, 2025 at 2:57 AM Qu Wenruo <quwenruo.btrfs@gmx.com> wrote:
> > 在 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.
> 
> Ah, if it's that simple, of course, round_*() is okay to go.
> My only worries are about explicit castings to "fix" such a warning.

Both ALIGN and round_* seem to be fine with different types, there are
the tricks with masking lower bits and the alignment is explicitly cast
to the target type. Most offten we have u64 as target type and u32 as
the alignment.

      reply	other threads:[~2025-04-16  8:28 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
2025-04-16  5:57               ` Andy Shevchenko
2025-04-16  8:28                 ` David Sterba [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=20250416082831.GA13877@suse.cz \
    --to=dsterba@suse.cz \
    --cc=andy.shevchenko@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.com \
    --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