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 04/11] md: add queue limit helpers
Date: Sun, 3 Mar 2024 07:01:43 -0700 [thread overview]
Message-ID: <20240303140150.5435-5-hch@lst.de> (raw)
In-Reply-To: <20240303140150.5435-1-hch@lst.de>
Add a few helpers that wrap the block queue limits API for use in MD.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed--by: Song Liu <song@kernel.org>
Tested-by: Song Liu <song@kernel.org>
---
drivers/md/md.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
drivers/md/md.h | 3 +++
2 files changed, 48 insertions(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 9ce4b5f2324dab..9a7f3d2b8c2d16 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5731,6 +5731,51 @@ static const struct kobj_type md_ktype = {
int mdp_major = 0;
+/* stack the limit for all rdevs into lim */
+void mddev_stack_rdev_limits(struct mddev *mddev, struct queue_limits *lim)
+{
+ struct md_rdev *rdev;
+
+ rdev_for_each(rdev, mddev) {
+ queue_limits_stack_bdev(lim, rdev->bdev, rdev->data_offset,
+ mddev->gendisk->disk_name);
+ }
+}
+EXPORT_SYMBOL_GPL(mddev_stack_rdev_limits);
+
+/* apply the extra stacking limits from a new rdev into mddev */
+int mddev_stack_new_rdev(struct mddev *mddev, struct md_rdev *rdev)
+{
+ struct queue_limits lim;
+
+ if (mddev_is_dm(mddev))
+ return 0;
+
+ lim = queue_limits_start_update(mddev->queue);
+ queue_limits_stack_bdev(&lim, rdev->bdev, rdev->data_offset,
+ mddev->gendisk->disk_name);
+ return queue_limits_commit_update(mddev->queue, &lim);
+}
+EXPORT_SYMBOL_GPL(mddev_stack_new_rdev);
+
+/* update the optimal I/O size after a reshape */
+void mddev_update_io_opt(struct mddev *mddev, unsigned int nr_stripes)
+{
+ struct queue_limits lim;
+
+ if (mddev_is_dm(mddev))
+ return;
+
+ /* don't bother updating io_opt if we can't suspend the array */
+ if (mddev_suspend(mddev, false) < 0)
+ return;
+ lim = queue_limits_start_update(mddev->gendisk->queue);
+ lim.io_opt = lim.io_min * nr_stripes;
+ queue_limits_commit_update(mddev->gendisk->queue, &lim);
+ mddev_resume(mddev);
+}
+EXPORT_SYMBOL_GPL(mddev_update_io_opt);
+
static void mddev_delayed_delete(struct work_struct *ws)
{
struct mddev *mddev = container_of(ws, struct mddev, del_work);
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 786b0eebd1cad6..003db35b4b5926 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -872,6 +872,9 @@ void md_autostart_arrays(int part);
int md_set_array_info(struct mddev *mddev, struct mdu_array_info_s *info);
int md_add_new_disk(struct mddev *mddev, struct mdu_disk_info_s *info);
int do_md_run(struct mddev *mddev);
+void mddev_stack_rdev_limits(struct mddev *mddev, struct queue_limits *lim);
+int mddev_stack_new_rdev(struct mddev *mddev, struct md_rdev *rdev);
+void mddev_update_io_opt(struct mddev *mddev, unsigned int nr_stripes);
extern const struct block_device_operations md_fops;
--
2.39.2
next prev parent reply other threads:[~2024-03-03 14:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-03 14:01 atomic queue limit updates for md v4 Christoph Hellwig
2024-03-03 14:01 ` [PATCH 01/11] md: add a mddev_trace_remap helper Christoph Hellwig
2024-03-03 14:01 ` [PATCH 02/11] md: add a mddev_add_trace_msg helper Christoph Hellwig
2024-03-03 14:01 ` [PATCH 03/11] md: add a mddev_is_dm helper Christoph Hellwig
2024-03-03 14:01 ` Christoph Hellwig [this message]
2024-03-03 14:01 ` [PATCH 05/11] md/raid0: use the atomic queue limit update APIs Christoph Hellwig
2024-03-03 14:01 ` [PATCH 06/11] md/raid1: " Christoph Hellwig
2024-03-03 14:01 ` [PATCH 07/11] md/raid5: " Christoph Hellwig
2024-03-03 14:01 ` [PATCH 08/11] md/raid10: " Christoph Hellwig
2024-03-03 14:01 ` [PATCH 09/11] md: don't initialize queue limits Christoph Hellwig
2024-03-03 14:01 ` [PATCH 10/11] md: remove mddev->queue Christoph Hellwig
2024-03-03 14:01 ` [PATCH 11/11] block: remove disk_stack_limits Christoph Hellwig
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=20240303140150.5435-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).