From: Arnd Bergmann <arnd@kernel.org>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>, Qu Wenruo <wqu@suse.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Anand Jain <anand.jain@oracle.com>,
Filipe Manana <fdmanana@suse.com>, Li Zetao <lizetao1@huawei.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] btrfs: replace 64-bit division with a shift
Date: Tue, 25 Feb 2025 20:44:11 +0100 [thread overview]
Message-ID: <20250225194416.3076650-2-arnd@kernel.org> (raw)
In-Reply-To: <20250225194416.3076650-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
folio_size() is not a compile-time constant, so in some configurations,
the DIV_ROUND_UP() turns into a 64-bit division that is not allowed
on 32-bit architectures.
x86_64-linux-ld: fs/btrfs/extent_io.o: in function `writepage_delalloc':
extent_io.c:(.text+0x2b6e): undefined reference to `__udivdi3'
This is probably not the correct solution, but it should illustrate
the issue. A trivial fix would be DIV64_U64_ROUND_UP(), which of course
is very expensive. Maybe there should be a DIV_ROUND_UP_FOLIO macro?
Fixes: aba063bf9336 ("btrfs: prepare extent_io.c for future larger folio support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/btrfs/extent_io.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 7dc996e7e249..e4ba4fa3f48c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1505,8 +1505,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,
* delalloc_end is already one less than the total length, so
* we don't subtract one from folio_size().
*/
- delalloc_to_write +=
- DIV_ROUND_UP(delalloc_end + 1 - page_start, folio_size(folio));
+ delalloc_to_write += (delalloc_end + 1 - page_start + folio_size(folio) - 1) >> folio_order(folio);
/*
* If all ranges are submitted asynchronously, we just need to account
--
2.39.5
next prev parent reply other threads:[~2025-02-25 19:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 19:44 [PATCH 1/2] btrfs: use min_t() for mismatched type comparison Arnd Bergmann
2025-02-25 19:44 ` Arnd Bergmann [this message]
2025-02-25 21:22 ` Qu Wenruo
2025-02-25 21:28 ` Arnd Bergmann
2025-02-26 14:13 ` David Laight
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=20250225194416.3076650-2-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=anand.jain@oracle.com \
--cc=arnd@arndb.de \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=fdmanana@suse.com \
--cc=johannes.thumshirn@wdc.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizetao1@huawei.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