[Devel] [PATCH vz9] Check queue_flags size at compile time

Alexander Atanasov alexander.atanasov at virtuozzo.com
Thu Jan 5 19:50:58 MSK 2023


QUEUE_STANDBY_EN flag made the used bits more than 31 so it is now
required that queue_flags is a 64 bits. Add compile time check to
ensure it is.

https://jira.sw.ru/browse/PSBM-144163
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
 drivers/md/dm-ploop-target.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 35aa5960fe89..97b1830d9b10 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -407,6 +407,10 @@ static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	ti->private = ploop;
 	ploop->ti = ti;
 
+	BUILD_BUG_ON_MSG(
+		sizeof(ploop_blk_queue(ploop)->queue_flags) * 8 < BITS_PER_LONG
+		|| BITS_PER_LONG < 64,
+		"queue_flags require 64 bit storage variable");
 	/*
 	 * static branch and standby_en bit act as two fuses.
 	 * we only touch standby bit if both are set.
-- 
2.31.1



More information about the Devel mailing list