From: Jack Wang <jinpu.wang@ionos.com>
To: Nilay Shroff <nilay@linux.ibm.com>, abd.masalkhi@gmail.com
Cc: linux-raid <linux-raid@vger.kernel.org>,
linux-block <linux-block@vger.kernel.org>,
Song Liu <song@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>,
Damien Le Moal <dlemoal@kernel.org>, Yu Kuai <yukuai@fygo.io>,
tom.leiming@gmail.com, Jack Wang <jinpu.wang@cloud.ionos.com>
Subject: [PATCH 1/6] block: add queue_limits_start_update_trylock()
Date: Mon, 7 Sep 2026 15:39:24 +0200 [thread overview]
Message-ID: <20260907133929.1081540-2-jinpu.wang@ionos.com> (raw)
In-Reply-To: <20260907133929.1081540-1-jinpu.wang@ionos.com>
From: Jack Wang <jinpu.wang@cloud.ionos.com>
Some callers must not wait for q->limits_lock, because they hold
something the current holder waits for. md is one: its
check_sb_changes() runs with reconfig_mutex held, while a
queue_attr_store() holding limits_lock waits in blk_mq_freeze_queue()
for I/O that can be waiting for a superblock update needing that mutex.
Add a trylock variant of queue_limits_start_update() for them.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
---
include/linux/blkdev.h | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 4f7905c3412b..b75e85291e29 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1101,6 +1101,32 @@ queue_limits_start_update(struct request_queue *q)
mutex_lock(&q->limits_lock);
return q->limits;
}
+
+/**
+ * queue_limits_start_update_trylock - try to start an atomic update of queue
+ * limits
+ * @q: queue to update
+ * @lim: returns a snapshot of the current limits on success
+ *
+ * Like queue_limits_start_update(), but fails instead of waiting when another
+ * update is in flight. For callers that must not block on q->limits_lock
+ * because they hold something its current owner is waiting for.
+ *
+ * Context: process context.
+ */
+static inline bool
+queue_limits_start_update_trylock(struct request_queue *q,
+ struct queue_limits *lim)
+ __cond_acquires(true, &q->limits_lock)
+{
+ if (!mutex_trylock(&q->limits_lock))
+ return false;
+
+ *lim = q->limits;
+
+ return true;
+}
+
int queue_limits_commit_update_frozen(struct request_queue *q,
struct queue_limits *lim) __releases(&q->limits_lock);
int queue_limits_commit_update(struct request_queue *q,
--
2.43.0
next prev parent reply other threads:[~2026-09-07 13:39 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 13:39 [PATCH 0/6] md: don't wait for q->limits_lock while md holds back I/O Jack Wang
2026-09-07 13:39 ` Jack Wang [this message]
2026-09-09 6:29 ` [PATCH 1/6] block: add queue_limits_start_update_trylock() Christoph Hellwig
2026-09-09 10:35 ` Jinpu Wang
2026-09-07 13:39 ` [PATCH 2/6] md: pass a queue_limits down to ->hot_add_disk() Jack Wang
2026-09-07 13:56 ` sashiko-bot
2026-09-08 4:43 ` Jinpu Wang
2026-09-07 13:39 ` [PATCH 3/6] md: don't wait for q->limits_lock in check_sb_changes() Jack Wang
2026-09-07 13:56 ` sashiko-bot
2026-09-08 4:41 ` Jinpu Wang
2026-09-07 13:39 ` [PATCH 4/6] md: pass a queue_limits through the rdev sysfs stores Jack Wang
2026-09-07 13:39 ` [PATCH 5/6] md: don't wait for q->limits_lock in mddev_update_io_opt() Jack Wang
2026-09-07 13:39 ` [PATCH 6/6] md: take q->limits_lock before locking and suspending the array Jack Wang
2026-09-07 14:00 ` sashiko-bot
2026-09-08 4:44 ` Jinpu Wang
2026-09-08 11:15 ` [PATCH 0/6] md: don't wait for q->limits_lock while md holds back I/O Nilay Shroff
2026-09-08 12:09 ` Jinpu Wang
2026-09-08 18:25 ` Nilay Shroff
2026-09-09 4:25 ` Jinpu Wang
2026-09-08 18:37 ` Abd-Alrhman Masalkhi
2026-09-08 21:51 ` Abd-Alrhman Masalkhi
2026-09-09 4:28 ` Jinpu Wang
2026-09-08 17:00 ` Johannes Thumshirn
2026-09-09 6:30 ` 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=20260907133929.1081540-2-jinpu.wang@ionos.com \
--to=jinpu.wang@ionos.com \
--cc=abd.masalkhi@gmail.com \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=jinpu.wang@cloud.ionos.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=nilay@linux.ibm.com \
--cc=song@kernel.org \
--cc=tom.leiming@gmail.com \
--cc=yukuai@fygo.io \
/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