All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>, Song Liu <song@kernel.org>,
	Yu Kuai <yukuai3@huawei.com>
Cc: dm-devel@lists.linux.dev, linux-block@vger.kernel.org,
	linux-raid@vger.kernel.org
Subject: [PATCH 02/14] block: add a queue_limits_stack_bdev helper
Date: Wed, 28 Feb 2024 14:56:41 -0800	[thread overview]
Message-ID: <20240228225653.947152-3-hch@lst.de> (raw)
In-Reply-To: <20240228225653.947152-1-hch@lst.de>

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>
---
 block/blk-settings.c   | 25 +++++++++++++++++++++++++
 include/linux/blkdev.h |  2 ++
 2 files changed, 27 insertions(+)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 1989a177be201b..865fe4ebbf9b83 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -891,6 +891,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)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index dd510ad7ce4b45..285e82723d641f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -924,6 +924,8 @@ extern void blk_set_queue_depth(struct request_queue *q, unsigned int depth);
 extern void blk_set_stacking_limits(struct queue_limits *lim);
 extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
 			    sector_t offset);
+void queue_limits_stack_bdev(struct queue_limits *t, struct block_device *bdev,
+		sector_t offset, const char *pfx);
 extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
 			      sector_t offset);
 extern void blk_queue_update_dma_pad(struct request_queue *, unsigned int);
-- 
2.39.2


  parent reply	other threads:[~2024-02-28 22:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 22:56 atomic queue limit updates for stackable devices v3 Christoph Hellwig
2024-02-28 22:56 ` [PATCH 01/14] block: add a queue_limits_set helper Christoph Hellwig
2024-02-28 22:56 ` Christoph Hellwig [this message]
2024-02-28 22:56 ` [PATCH 03/14] dm: use queue_limits_set Christoph Hellwig
2024-02-28 22:56 ` [PATCH 04/14] md: add a mddev_trace_remap helper Christoph Hellwig
2024-02-28 22:56 ` [PATCH 05/14] md: add a mddev_add_trace_msg helper Christoph Hellwig
2024-02-28 22:56 ` [PATCH 06/14] md: add a mddev_is_dm helper Christoph Hellwig
2024-02-28 22:56 ` [PATCH 07/14] md: add queue limit helpers Christoph Hellwig
2024-02-28 22:56 ` [PATCH 08/14] md/raid0: use the atomic queue limit update APIs Christoph Hellwig
2024-02-28 22:56 ` [PATCH 09/14] md/raid1: " Christoph Hellwig
2024-02-28 22:56 ` [PATCH 10/14] md/raid5: " Christoph Hellwig
2024-02-28 22:56 ` [PATCH 11/14] md/raid10: " Christoph Hellwig
2024-02-28 22:56 ` [PATCH 12/14] md: don't initialize queue limits Christoph Hellwig
2024-02-28 22:56 ` [PATCH 13/14] md: remove mddev->queue Christoph Hellwig
2024-02-28 22:56 ` [PATCH 14/14] block: remove disk_stack_limits Christoph Hellwig
2024-02-29 19:40 ` atomic queue limit updates for stackable devices v3 Christoph Hellwig
2024-03-01 15:55 ` (subset) " Jens Axboe
2024-03-02  4:14   ` Song Liu

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=20240228225653.947152-3-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.