mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Curtin <ericcurtin17@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: "Eric Curtin" <eric.curtin@docker.com>,
	"Philipp Reisner" <philipp.reisner@linbit.com>,
	"Lars Ellenberg" <lars.ellenberg@linbit.com>,
	"Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>,
	"Jens Axboe" <axboe@kernel.dk>,
	drbd-dev@lists.linux.dev, linux-block@vger.kernel.org
Subject: [RFC PATCH v2 08/13] drbd: Use PAGE_SHIFT_MIN in preprocessor checks
Date: Wed,  2 Dec 2026 03:16:29 +0000	[thread overview]
Message-ID: <20261202031647.1690622-9-ericcurtin17@gmail.com> (raw)
In-Reply-To: <20261202031647.1690622-1-ericcurtin17@gmail.com>

From: Eric Curtin <eric.curtin@docker.com>

With arm64 boot-time page size selection PAGE_SHIFT is not a
compile-time constant and cannot be evaluated by the preprocessor.

Check the AL extent/bitmap block relationship in drbd_actlog.c and the
DRBD_MAX_BIO_SIZE limit in drbd_int.h against PAGE_SHIFT_MIN, so that
the build fails if the assumption could be violated by any supported
page size.

Drop the "ambiguous BITS_PER_PAGE" #error from drbd_bitmap.c. It
compared a macro against an expression of PAGE_SHIFT in #if, which can
no longer be evaluated, and it only guarded against a conflicting
definition of BITS_PER_PAGE in other headers.

Signed-off-by: Eric Curtin <eric.curtin@docker.com>
---
 drivers/block/drbd/drbd_actlog.c | 2 +-
 drivers/block/drbd/drbd_bitmap.c | 4 ----
 drivers/block/drbd/drbd_int.h    | 2 +-
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index b3dbf6c76e98..086b8efce9ae 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -277,7 +277,7 @@ bool drbd_al_begin_io_prepare(struct drbd_device *device, struct drbd_interval *
 	return need_transaction;
 }
 
-#if (PAGE_SHIFT + 3) < (AL_EXTENT_SHIFT - BM_BLOCK_SHIFT)
+#if (PAGE_SHIFT_MIN + 3) < (AL_EXTENT_SHIFT - BM_BLOCK_SHIFT)
 /* Currently BM_BLOCK_SHIFT, BM_EXT_SHIFT and AL_EXTENT_SHIFT
  * are still coupled, or assume too much about their relation.
  * Code below will not work if this is violated.
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index 65ea6ec66bfd..7d715dcaf982 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -473,10 +473,6 @@ void drbd_bm_cleanup(struct drbd_device *device)
 #ifndef BITS_PER_PAGE
 #define BITS_PER_PAGE		(1UL << (PAGE_SHIFT + 3))
 #define BITS_PER_PAGE_MASK	(BITS_PER_PAGE - 1)
-#else
-# if BITS_PER_PAGE != (1UL << (PAGE_SHIFT + 3))
-#  error "ambiguous BITS_PER_PAGE"
-# endif
 #endif
 #define BITS_PER_LONG_MASK	(BITS_PER_LONG - 1)
 static int bm_clear_surplus(struct drbd_bitmap *b)
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 48b45c3142f7..2db7f596a68d 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -1261,7 +1261,7 @@ struct bm_extent {
  * A followup commit may allow even bigger BIO sizes,
  * once we thought that through. */
 #define DRBD_MAX_BIO_SIZE (1U << 20)
-#if DRBD_MAX_BIO_SIZE > (BIO_MAX_VECS << PAGE_SHIFT)
+#if DRBD_MAX_BIO_SIZE > (BIO_MAX_VECS << PAGE_SHIFT_MIN)
 #error Architecture not supported: DRBD_MAX_BIO_SIZE > BIO_MAX_SIZE
 #endif
 #define DRBD_MAX_BIO_SIZE_SAFE (1U << 12)       /* Works always = 4k */

  parent reply	other threads:[~2026-12-02  3:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  3:16 [RFC PATCH v2 00/13] block/storage: Prepare for boot-time page size selection on arm64 Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 01/13] scsi: core: Add dma_boundary_page for page-size DMA boundaries Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 02/13] mtd: mtdswap: Initialise mtdswap_ops with a page size variable Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 03/13] mmc: mmc_test: Allocate the scratch buffer with the test buffer Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 04/13] md: Remove compile-time PAGE_SIZE use in md, dm and bcache Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 05/13] zram: Remove PAGE_SIZE use in preprocessor conditionals Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 06/13] xen/blkback: Size indirect_pages for the largest page size Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 07/13] null_blk: Size the nullb_page bitmap for PAGE_SIZE_MAX Eric Curtin
2026-12-02  3:16 ` Eric Curtin [this message]
2026-12-02  3:16 ` [RFC PATCH v2 09/13] nvme: Check the DSM range buffer against PAGE_SIZE_MIN Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 10/13] dm: Initialise swap_bios from the runtime PAGE_SIZE Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 11/13] virtio: Handle boot-time PAGE_SIZE in balloon, blk and 9p transport Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 12/13] ata: sata_sil24: Use flexible arrays for the command block SGEs Eric Curtin
2026-12-02  3:16 ` [RFC PATCH v2 13/13] mm: Use PAGE_SIZE_MIN/MAX where a compile-time constant is required Eric Curtin

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=20261202031647.1690622-9-ericcurtin17@gmail.com \
    --to=ericcurtin17@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=christoph.boehmwalder@linbit.com \
    --cc=drbd-dev@lists.linux.dev \
    --cc=eric.curtin@docker.com \
    --cc=lars.ellenberg@linbit.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=philipp.reisner@linbit.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

all inboxes | Powered by JetHome®