All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] block: add a helper to cancel atomic queue limit updates
@ 2024-03-27 17:21 ` Christoph Hellwig
  2024-03-27 17:21   ` [PATCH 2/2] nvme: cancel the queue limit update when nvme_update_zone_info fails Christoph Hellwig
  2024-03-28  3:03   ` [PATCH 1/2] block: add a helper to cancel atomic queue limit updates Kanchan Joshi
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2024-03-27 17:21 UTC (permalink / raw)
  To: axboe; +Cc: kbusch, sagi, linux-nvme, linux-block

Drivers might have to perform complex actions to determine queue limits,
and those might fail.  Add a helper to cancel a queue limit update
that can be called in those cases.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/blkdev.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f9b87c39cab047..39fedc8ef9c41f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -892,6 +892,19 @@ int queue_limits_commit_update(struct request_queue *q,
 		struct queue_limits *lim);
 int queue_limits_set(struct request_queue *q, struct queue_limits *lim);
 
+/**
+ * queue_limits_cancel_update - cancel an atomic update of queue limits
+ * @q:		queue to update
+ *
+ * This functions cancels an atomic update of the queue limits started by
+ * queue_limits_start_update() and should be used when an error occurs after
+ * starting update.
+ */
+static inline void queue_limits_cancel_update(struct request_queue *q)
+{
+	mutex_lock(&q->limits_lock);
+}
+
 /*
  * Access functions for manipulating queue properties
  */
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] nvme: cancel the queue limit update when nvme_update_zone_info fails
  2024-03-27 17:21 ` [PATCH 1/2] block: add a helper to cancel atomic queue limit updates Christoph Hellwig
@ 2024-03-27 17:21   ` Christoph Hellwig
  2024-03-27 18:01     ` Keith Busch
  2024-03-28  3:03   ` [PATCH 1/2] block: add a helper to cancel atomic queue limit updates Kanchan Joshi
  1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2024-03-27 17:21 UTC (permalink / raw)
  To: axboe; +Cc: kbusch, sagi, linux-nvme, linux-block, Kanchan Joshi

Starting an atomic queue limits update takes a mutex and thus needs
to be finished, or with the newly added helper, canceled to not leak
the lock critical section.

Fixes: 9b130d681443 ("nvme: use the atomic queue limits update API")
Reported-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 943d72bdd794ca..f8a9565bee41d2 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2115,6 +2115,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
 	    ns->head->ids.csi == NVME_CSI_ZNS) {
 		ret = nvme_update_zone_info(ns, lbaf, &lim);
 		if (ret) {
+			queue_limits_cancel_update(ns->disk->queue);
 			blk_mq_unfreeze_queue(ns->disk->queue);
 			goto out;
 		}
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] nvme: cancel the queue limit update when nvme_update_zone_info fails
  2024-03-27 17:21   ` [PATCH 2/2] nvme: cancel the queue limit update when nvme_update_zone_info fails Christoph Hellwig
@ 2024-03-27 18:01     ` Keith Busch
  0 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2024-03-27 18:01 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: axboe, sagi, linux-nvme, linux-block, Kanchan Joshi

On Wed, Mar 27, 2024 at 06:21:45PM +0100, Christoph Hellwig wrote:
> @@ -2115,6 +2115,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
>  	    ns->head->ids.csi == NVME_CSI_ZNS) {
>  		ret = nvme_update_zone_info(ns, lbaf, &lim);
>  		if (ret) {
> +			queue_limits_cancel_update(ns->disk->queue);

Could you instead move nvme_update_zone_info() outside the
queue_limits_start_update()? That way we wouldn't need to "cancel" the
update. You'd just need to save a copy of "mor" and "mar" in the ns
instead of writing these directly to the queue_limits.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] block: add a helper to cancel atomic queue limit updates
  2024-03-27 17:21 ` [PATCH 1/2] block: add a helper to cancel atomic queue limit updates Christoph Hellwig
  2024-03-27 17:21   ` [PATCH 2/2] nvme: cancel the queue limit update when nvme_update_zone_info fails Christoph Hellwig
@ 2024-03-28  3:03   ` Kanchan Joshi
  1 sibling, 0 replies; 4+ messages in thread
From: Kanchan Joshi @ 2024-03-28  3:03 UTC (permalink / raw)
  To: Christoph Hellwig, axboe; +Cc: kbusch, sagi, linux-nvme, linux-block

On 3/27/2024 10:51 PM, Christoph Hellwig wrote:
> Drivers might have to perform complex actions to determine queue limits,
> and those might fail.  Add a helper to cancel a queue limit update
> that can be called in those cases.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   include/linux/blkdev.h | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index f9b87c39cab047..39fedc8ef9c41f 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -892,6 +892,19 @@ int queue_limits_commit_update(struct request_queue *q,
>   		struct queue_limits *lim);
>   int queue_limits_set(struct request_queue *q, struct queue_limits *lim);
>   
> +/**
> + * queue_limits_cancel_update - cancel an atomic update of queue limits
> + * @q:		queue to update
> + *
> + * This functions cancels an atomic update of the queue limits started by
> + * queue_limits_start_update() and should be used when an error occurs after
> + * starting update.
> + */
> +static inline void queue_limits_cancel_update(struct request_queue *q)
> +{
> +	mutex_lock(&q->limits_lock);

mutex_unlock is needed here.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-28  3:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20240327172205epcas5p356fffa2ae1916fa1479c2c75e4215cd1@epcas5p3.samsung.com>
2024-03-27 17:21 ` [PATCH 1/2] block: add a helper to cancel atomic queue limit updates Christoph Hellwig
2024-03-27 17:21   ` [PATCH 2/2] nvme: cancel the queue limit update when nvme_update_zone_info fails Christoph Hellwig
2024-03-27 18:01     ` Keith Busch
2024-03-28  3:03   ` [PATCH 1/2] block: add a helper to cancel atomic queue limit updates Kanchan Joshi

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.