summaryrefslogtreecommitdiff
path: root/block/blk-settings.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-02-28 14:56:41 -0800
committerJens Axboe <axboe@kernel.dk>2024-03-01 08:54:42 -0700
commitc1373f1cf452e4c7553a9d3bc05d87ec15c4f85f (patch)
tree5f44e2107953b9b53f94f2452f45b93fa2509a53 /block/blk-settings.c
parent631d4efb8009df64deae8c1382b8cf43879a4e22 (diff)
block: add a queue_limits_stack_bdev helper
Add a small wrapper around blk_stack_limits that allows passing a bdev for the bottom device and prints an error in case of misaligned device. The name fits into the new queue limits API and the intent is to eventually replace disk_stack_limits. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20240228225653.947152-3-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-settings.c')
-rw-r--r--block/blk-settings.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 1989a177be20..865fe4ebbf9b 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -892,6 +892,31 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
EXPORT_SYMBOL(blk_stack_limits);
/**
+ * queue_limits_stack_bdev - adjust queue_limits for stacked devices
+ * @t: the stacking driver limits (top device)
+ * @bdev: the underlying block device (bottom)
+ * @offset: offset to beginning of data within component device
+ * @pfx: prefix to use for warnings logged
+ *
+ * Description:
+ * This function is used by stacking drivers like MD and DM to ensure
+ * that all component devices have compatible block sizes and
+ * alignments. The stacking driver must provide a queue_limits
+ * struct (top) and then iteratively call the stacking function for
+ * all component (bottom) devices. The stacking function will
+ * attempt to combine the values and ensure proper alignment.
+ */
+void queue_limits_stack_bdev(struct queue_limits *t, struct block_device *bdev,
+ sector_t offset, const char *pfx)
+{
+ if (blk_stack_limits(t, &bdev_get_queue(bdev)->limits,
+ get_start_sect(bdev) + offset))
+ pr_notice("%s: Warning: Device %pg is misaligned\n",
+ pfx, bdev);
+}
+EXPORT_SYMBOL_GPL(queue_limits_stack_bdev);
+
+/**
* disk_stack_limits - adjust queue limits for stacked drivers
* @disk: MD/DM gendisk (top)
* @bdev: the underlying block device (bottom)