Linux RAID subsystem development
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, Song Liu <song@kernel.org>,
	 Yu Kuai <yukuai3@huawei.com>, Li Nan <linan122@huawei.com>
Cc: linux-raid@vger.kernel.org, linux-block@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH] md/md-llbitmap: Use DIV_ROUND_UP_SECTOR_T
Date: Wed, 10 Sep 2025 13:47:26 -0700	[thread overview]
Message-ID: <20250910-llbitmap-fix-64-div-for-32-bit-v1-1-453a5c8e3e00@kernel.org> (raw)

When building for 32-bit platforms, there are several link (if builtin)
or modpost (if a module) errors due to dividends of type 'sector_t' in
DIV_ROUND_UP:

  arm-linux-gnueabi-ld: drivers/md/md-llbitmap.o: in function `llbitmap_resize':
  drivers/md/md-llbitmap.c:1017:(.text+0xae8): undefined reference to `__aeabi_uldivmod'
  arm-linux-gnueabi-ld: drivers/md/md-llbitmap.c:1020:(.text+0xb10): undefined reference to `__aeabi_uldivmod'
  arm-linux-gnueabi-ld: drivers/md/md-llbitmap.o: in function `llbitmap_end_discard':
  drivers/md/md-llbitmap.c:1114:(.text+0xf14): undefined reference to `__aeabi_uldivmod'
  arm-linux-gnueabi-ld: drivers/md/md-llbitmap.o: in function `llbitmap_start_discard':
  drivers/md/md-llbitmap.c:1097:(.text+0x1808): undefined reference to `__aeabi_uldivmod'
  arm-linux-gnueabi-ld: drivers/md/md-llbitmap.o: in function `llbitmap_read_sb':
  drivers/md/md-llbitmap.c:867:(.text+0x2080): undefined reference to `__aeabi_uldivmod'
  arm-linux-gnueabi-ld: drivers/md/md-llbitmap.o:drivers/md/md-llbitmap.c:895: more undefined references to `__aeabi_uldivmod' follow

Use DIV_ROUND_UP_SECTOR_T instead of DIV_ROUND_UP, which exists to
handle this exact situation.

Fixes: 5ab829f1971d ("md/md-llbitmap: introduce new lockless bitmap")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/md/md-llbitmap.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/md/md-llbitmap.c b/drivers/md/md-llbitmap.c
index 3337d5c7e7e5..1eb434306162 100644
--- a/drivers/md/md-llbitmap.c
+++ b/drivers/md/md-llbitmap.c
@@ -781,7 +781,7 @@ static int llbitmap_init(struct llbitmap *llbitmap)
 
 	while (chunks > space) {
 		chunksize = chunksize << 1;
-		chunks = DIV_ROUND_UP(blocks, chunksize);
+		chunks = DIV_ROUND_UP_SECTOR_T(blocks, chunksize);
 	}
 
 	llbitmap->barrier_idle = DEFAULT_BARRIER_IDLE;
@@ -864,8 +864,8 @@ static int llbitmap_read_sb(struct llbitmap *llbitmap)
 		goto out_put_page;
 	}
 
-	if (chunksize < DIV_ROUND_UP(mddev->resync_max_sectors,
-				     mddev->bitmap_info.space << SECTOR_SHIFT)) {
+	if (chunksize < DIV_ROUND_UP_SECTOR_T(mddev->resync_max_sectors,
+					      mddev->bitmap_info.space << SECTOR_SHIFT)) {
 		pr_err("md/llbitmap: %s: chunksize too small %lu < %llu / %lu",
 		       mdname(mddev), chunksize, mddev->resync_max_sectors,
 		       mddev->bitmap_info.space);
@@ -892,7 +892,7 @@ static int llbitmap_read_sb(struct llbitmap *llbitmap)
 
 	llbitmap->barrier_idle = DEFAULT_BARRIER_IDLE;
 	llbitmap->chunksize = chunksize;
-	llbitmap->chunks = DIV_ROUND_UP(mddev->resync_max_sectors, chunksize);
+	llbitmap->chunks = DIV_ROUND_UP_SECTOR_T(mddev->resync_max_sectors, chunksize);
 	llbitmap->chunkshift = ffz(~chunksize);
 	ret = llbitmap_cache_pages(llbitmap);
 
@@ -1014,10 +1014,10 @@ static int llbitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize)
 		chunksize = llbitmap->chunksize;
 
 	/* If there is enough space, leave the chunksize unchanged. */
-	chunks = DIV_ROUND_UP(blocks, chunksize);
+	chunks = DIV_ROUND_UP_SECTOR_T(blocks, chunksize);
 	while (chunks > mddev->bitmap_info.space << SECTOR_SHIFT) {
 		chunksize = chunksize << 1;
-		chunks = DIV_ROUND_UP(blocks, chunksize);
+		chunks = DIV_ROUND_UP_SECTOR_T(blocks, chunksize);
 	}
 
 	llbitmap->chunkshift = ffz(~chunksize);
@@ -1094,7 +1094,7 @@ static void llbitmap_start_discard(struct mddev *mddev, sector_t offset,
 				   unsigned long sectors)
 {
 	struct llbitmap *llbitmap = mddev->bitmap;
-	unsigned long start = DIV_ROUND_UP(offset, llbitmap->chunksize);
+	unsigned long start = DIV_ROUND_UP_SECTOR_T(offset, llbitmap->chunksize);
 	unsigned long end = (offset + sectors - 1) >> llbitmap->chunkshift;
 	int page_start = (start + BITMAP_DATA_OFFSET) >> PAGE_SHIFT;
 	int page_end = (end + BITMAP_DATA_OFFSET) >> PAGE_SHIFT;
@@ -1111,7 +1111,7 @@ static void llbitmap_end_discard(struct mddev *mddev, sector_t offset,
 				 unsigned long sectors)
 {
 	struct llbitmap *llbitmap = mddev->bitmap;
-	unsigned long start = DIV_ROUND_UP(offset, llbitmap->chunksize);
+	unsigned long start = DIV_ROUND_UP_SECTOR_T(offset, llbitmap->chunksize);
 	unsigned long end = (offset + sectors - 1) >> llbitmap->chunkshift;
 	int page_start = (start + BITMAP_DATA_OFFSET) >> PAGE_SHIFT;
 	int page_end = (end + BITMAP_DATA_OFFSET) >> PAGE_SHIFT;

---
base-commit: 5ab829f1971dc99f2aac10846c378e67fc875abc
change-id: 20250910-llbitmap-fix-64-div-for-32-bit-9885a1d28834

Best regards,
--  
Nathan Chancellor <nathan@kernel.org>


             reply	other threads:[~2025-09-10 20:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-10 20:47 Nathan Chancellor [this message]
2025-09-11  0:23 ` [PATCH] md/md-llbitmap: Use DIV_ROUND_UP_SECTOR_T Jens Axboe

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=20250910-llbitmap-fix-64-div-for-32-bit-v1-1-453a5c8e3e00@kernel.org \
    --to=nathan@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=linan122@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yukuai3@huawei.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