Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
* [RFC PATCH v2 08/13] drbd: Use PAGE_SHIFT_MIN in preprocessor checks
       [not found] <20261202031647.1690622-1-ericcurtin17@gmail.com>
@ 2026-12-02  3:16 ` Eric Curtin
  0 siblings, 0 replies; only message in thread
From: Eric Curtin @ 2026-12-02  3:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Eric Curtin, Philipp Reisner, Lars Ellenberg,
	Christoph Böhmwalder, Jens Axboe, drbd-dev, linux-block

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 */

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-02  3:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261202031647.1690622-1-ericcurtin17@gmail.com>
2026-12-02  3:16 ` [RFC PATCH v2 08/13] drbd: Use PAGE_SHIFT_MIN in preprocessor checks Eric Curtin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox